/* ===================== Παιχνίδια προγραμματισμού ===================== */
/* Φόντο: img/code_bg.jpg (εργαστήριο ρομπότ) με ελαφρύ λευκό φίλτρο */
.code-wrap { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(340px, 46%) 1fr; gap: 12px; padding: 12px; background: linear-gradient(rgba(255,255,255,.38), rgba(255,255,255,.38)), url('../img/code_bg.jpg') center/cover no-repeat; }
.code-left { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.code-right { position: relative; min-width: 0; background: #fff; border-radius: 18px; box-shadow: inset 0 0 0 3px #e0e0e0; overflow: hidden; display: flex; flex-direction: column; }
.code-editor { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.code-editor > .arrow-pad, .code-editor > .seq-editor { flex: 1; height: auto; min-height: 0; }

/* Μπάρα βοήθειας: εμφανές, παλλόμενο κουμπί «επόμενο βήμα» + διακόπτης ίχνους */
.code-helpbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: linear-gradient(90deg, #fff3e0, #ffe0b2); border-bottom: 3px solid #ffcc80; flex: none; }
.code-hint-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 6px 16px; border-radius: 26px; border: 0;
  background: linear-gradient(#ffb300, #f57c00); color: #fff; font-family: inherit; font-weight: 800; font-size: 19px; cursor: pointer;
  box-shadow: 0 5px 0 #bf360c, 0 0 0 0 rgba(255,152,0,.6); animation: code-hint-pulse 1.8s ease-in-out infinite;
}
.code-hint-btn .e { font-size: 28px; line-height: 1; animation: code-hint-swing 1.8s ease-in-out infinite; }
.code-hint-btn:hover { filter: brightness(1.08); }
.code-hint-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #bf360c; }
.code-hint-btn.do { background: linear-gradient(#66bb6a, #2e7d32); box-shadow: 0 5px 0 #1b5e20, 0 0 0 0 rgba(76,175,80,.6); animation: code-hint-pulse-green 1.2s ease-in-out infinite; }
.code-hint-btn.flash { animation: code-hint-bump .5s 4; }
.code-hint-btn .n { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px; background: #fff; color: #e65100; font-size: 17px; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.code-hint-btn.do .n { color: #2e7d32; }
.code-hint-btn.off { background: linear-gradient(#bdbdbd, #9e9e9e); box-shadow: 0 5px 0 #616161; animation: none; cursor: default; font-size: 16px; }
.code-hint-btn.off .e { animation: none; }
.code-hint-btn.off .n { color: #757575; }
@keyframes code-hint-pulse { 0%, 100% { box-shadow: 0 5px 0 #bf360c, 0 0 0 0 rgba(255,152,0,.65); } 50% { box-shadow: 0 5px 0 #bf360c, 0 0 0 12px rgba(255,152,0,0); } }
@keyframes code-hint-pulse-green { 0%, 100% { box-shadow: 0 5px 0 #1b5e20, 0 0 0 0 rgba(76,175,80,.7); } 50% { box-shadow: 0 5px 0 #1b5e20, 0 0 0 12px rgba(76,175,80,0); } }
@keyframes code-hint-swing { 0%, 100% { transform: rotate(-12deg) scale(1); } 50% { transform: rotate(12deg) scale(1.15); } }
@keyframes code-hint-bump { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.code-trail-btn {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px; border-radius: 22px; border: 3px solid #bdbdbd; background: #fff;
  font-family: inherit; font-weight: 700; font-size: 16px; color: #616161; cursor: pointer;
}
.code-trail-btn .e { font-size: 22px; }
.code-trail-btn .sw { width: 42px; height: 22px; border-radius: 11px; background: #cfd8dc; position: relative; transition: background .2s; }
.code-trail-btn .sw i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.code-trail-btn.on { border-color: #43a047; color: #1b5e20; background: #e8f5e9; }
.code-trail-btn.on .sw { background: #43a047; }
.code-trail-btn.on .sw i { left: 23px; }

/* Ίχνος στον λαβύρινθο */
.mz-tr { position: absolute; left: 3px; top: 3px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 9px; background: rgba(33,150,243,.9); color: #fff; font-size: 11px; font-weight: 800; line-height: 16px; text-align: center; font-style: normal; z-index: 2; pointer-events: none; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.mz-tr-end { position: absolute; right: 2px; bottom: 2px; font-size: calc(var(--cs) * .4); font-style: normal; z-index: 2; pointer-events: none; animation: popin .3s; }
.mz-tr-end.win { filter: drop-shadow(0 0 3px #fff); }
.mz-tr-bump { position: absolute; left: 2px; bottom: 2px; font-size: calc(var(--cs) * .34); font-style: normal; z-index: 2; pointer-events: none; }

.code-goal { background: #fff8e1; border: 3px solid #ffd54f; border-radius: 16px; padding: 8px 14px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.code-goal b { color: #e65100; }
.code-board { position: relative; flex: 1; min-height: 160px; border-radius: 18px; overflow: hidden; background: linear-gradient(#b3e5fc, #e1f5fe); box-shadow: inset 0 0 0 3px rgba(255,255,255,.7); }
.code-board-inner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1; }
.code-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.code-controls .big-btn { font-size: 18px; padding: 9px 16px; margin: 0; }
.code-controls .big-btn:disabled { opacity: .55; }
.code-count { margin-left: auto; font-weight: 700; background: #fff; padding: 6px 12px; border-radius: 14px; border: 2px solid #bdbdbd; color: #616161; }
.code-count.full { border-color: #e53935; color: #c62828; }
.code-msg { min-height: 30px; font-size: 17px; font-weight: 600; padding: 6px 12px; border-radius: 12px; line-height: 1.3; }
.code-msg.ok { background: #c8e6c9; color: #1b5e20; }
.code-msg.bad { background: #ffcdd2; color: #b71c1c; }
.code-msg.hint { background: #fff3e0; color: #e65100; }
.code-msg.bump { animation: bump .4s; }

/* Πλέγμα */
.mz-grid { position: relative; display: grid; gap: 0; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 24px rgba(0,0,0,.25); }
.mz-cell { width: var(--cs); height: var(--cs); display: flex; align-items: center; justify-content: center; font-size: calc(var(--cs) * .62); line-height: 1; position: relative; }
.mz-cell.floor { background: var(--floor, #f5f5f5); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.mz-cell.floor.alt { background: var(--floor2, #eeeeee); }
.mz-cell.wall { background: var(--wallbg, #2e7d32); }
.mz-cell.t-X { background: #ffccbc; }
.mz-cell.t-X .mz-item { animation: flame .7s ease-in-out infinite alternate; }
.mz-cell.t-E .mz-item { animation: bob 1.4s ease-in-out infinite; }
.mz-cell.t-K .mz-item, .mz-cell.t-T .mz-item { animation: twinkle-item 1.2s ease-in-out infinite alternate; }
.mz-cell.t-G .mz-item { animation: flag-wave 1.2s ease-in-out infinite; }
.mz-cell.t-D .mz-item { filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.mz-cell.taken .mz-item { animation: catch .5s forwards; }
.mz-cell.opened { background: #dcedc8; }
.mz-robot { position: absolute; width: var(--cs); height: var(--cs); left: 0; top: 0; display: flex; align-items: center; justify-content: center; transition: left .25s ease-in-out, top .25s ease-in-out; z-index: 3; }
.mz-robot .hero-av svg { border-width: 2px; }
.mz-dir { position: absolute; font-size: calc(var(--cs) * .34); line-height: 1; color: #fff; text-shadow: 0 0 3px #000, 0 0 6px #000; transition: transform .2s; }
.mz-dir.d0 { top: -2px; left: 50%; transform: translateX(-50%); }
.mz-dir.d1 { right: -2px; top: 50%; transform: translateY(-50%); }
.mz-dir.d2 { bottom: -2px; left: 50%; transform: translateX(-50%); }
.mz-dir.d3 { left: -2px; top: 50%; transform: translateY(-50%); }
.mz-robot.bump { animation: shake-plain .4s; }
.mz-robot.dead { animation: robot-dead .9s forwards; }
.mz-robot.happy { animation: robot-happy .6s ease-in-out 3; }

/* Θέματα δαπέδου/τοίχων */
.theme-forest .mz-grid { --floor: #e8f5e9; --floor2: #dcedc8; --wallbg: #2e7d32; }
.theme-castle .mz-grid { --floor: #fff3e0; --floor2: #ffe0b2; --wallbg: #8d6e63; }
.theme-space .mz-grid { --floor: #5c6bc0; --floor2: #3f51b5; --wallbg: #1a237e; }
.theme-desert .mz-grid { --floor: #fff8e1; --floor2: #ffecb3; --wallbg: #a1887f; }
.theme-ice .mz-grid { --floor: #e1f5fe; --floor2: #b3e5fc; --wallbg: #4fc3f7; }
.theme-dungeon .mz-grid { --floor: #d7ccc8; --floor2: #bcaaa4; --wallbg: #4e342e; }
.theme-night .mz-grid { --floor: #cfd8dc; --floor2: #b0bec5; --wallbg: #263238; }
.theme-volcano .mz-grid { --floor: #ffccbc; --floor2: #ffab91; --wallbg: #4e342e; }
.theme-space .code-board { background: radial-gradient(circle at 30% 30%, #283593, #0d0d2b 70%); }
.theme-night .code-board, .theme-dungeon .code-board { background: linear-gradient(#1a237e, #283593); }
.theme-desert .code-board { background: linear-gradient(#81d4fa, #fff3c4 70%, #ffe082); }
.theme-volcano .code-board { background: linear-gradient(#37474f, #6d4c41 60%, #bf360c); }
.theme-ice .code-board { background: linear-gradient(#e1f5fe, #b3e5fc); }
.theme-forest .code-board { background: linear-gradient(#81d4fa, #c5e1a5 70%, #aed581); }
.theme-castle .code-board { background: linear-gradient(#90caf9, #ffe0b2 70%, #ffcc80); }

/* Βελάκια στην οθόνη */
.arrow-pad { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.arrow-pad .row { display: flex; gap: 8px; }
.arrow-pad button { width: 84px; height: 84px; font-size: 44px; border-radius: 22px; border: 0; background: #42a5f5; color: #fff; box-shadow: 0 6px 0 #1565c0; transition: transform .1s; }
.arrow-pad button:hover { filter: brightness(1.1); }
.arrow-pad button:active { transform: translateY(4px); box-shadow: 0 2px 0 #1565c0; }
.arrow-pad p { color: #757575; font-weight: 600; margin: 10px 0 0; }

/* Πρόγραμμα από κάρτες */
.seq-editor { height: 100%; display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.seq-title { font-weight: 700; font-size: 20px; color: #ef6c00; }
.seq-strip { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 12px; background: #fff8e1; border: 3px dashed #ffb74d; border-radius: 16px; overflow-y: auto; }
.seq-empty { color: #bdbdbd; font-weight: 600; }
.seq-card { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; font-size: 34px; background: #fff; border: 3px solid #ffb74d; border-radius: 14px; box-shadow: 0 3px 0 #ef6c00; animation: popin .25s; position: relative; }
.seq-card::before { content: counter(step); counter-increment: step; position: absolute; top: -8px; left: -8px; width: 20px; height: 20px; border-radius: 50%; background: #ef6c00; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.seq-strip { counter-reset: step; }
.seq-card.active { background: #ffe082; transform: scale(1.12); border-color: #43a047; }
.seq-palette { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.seq-palette button { width: 64px; height: 64px; font-size: 34px; border-radius: 18px; border: 0; background: #42a5f5; color: #fff; box-shadow: 0 5px 0 #1565c0; transition: transform .1s; }
.seq-palette button:active { transform: translateY(3px); box-shadow: 0 2px 0 #1565c0; }
.seq-palette button.del { background: #ef5350; box-shadow: 0 5px 0 #b71c1c; font-size: 26px; }

/* Blockly */
.blockly-host { position: absolute; inset: 0; }
.blocklyToolboxDiv { background: #f5f5f5; }
.blocklyFlyout { font-family: var(--font); }
.blocklyTreeLabel { font-family: var(--font); font-size: 16px; font-weight: 600; }
.blocklyText { font-family: var(--font) !important; }

/* Animations */
@keyframes flame { from { transform: scale(.9) rotate(-4deg); } to { transform: scale(1.1) rotate(4deg); } }
@keyframes twinkle-item { from { transform: scale(.9); filter: brightness(1); } to { transform: scale(1.1); filter: brightness(1.4) drop-shadow(0 0 6px #fff176); } }
@keyframes flag-wave { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(6deg); } }
@keyframes robot-dead { 0% { transform: rotate(0) scale(1); opacity: 1; } 100% { transform: rotate(540deg) scale(.2); opacity: 0; } }
@keyframes robot-happy { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

@media (max-width: 900px) {
  .code-wrap { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* Πάνελ αριθμού επαναλήψεων (field_stepper στο μπλοκ «επανέλαβε … φορές») */
.cg-stepper { padding: 10px 12px; font-family: var(--font); text-align: center; user-select: none; }
.cg-step-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.cg-step-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: #43a047; color: #fff; font-size: 32px; font-weight: 900; line-height: 1; cursor: pointer; box-shadow: 0 4px 0 #2e7d32; font-family: inherit; }
.cg-step-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.cg-step-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #2e7d32; }
.cg-step-btn:disabled { opacity: .35; cursor: default; }
.cg-step-val { min-width: 70px; font-size: 40px; font-weight: 900; color: #2e7d32; background: #f1f8e9; border: 3px solid #a5d6a7; border-radius: 14px; padding: 2px 10px; }
.cg-step-chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.cg-step-chip { height: 36px; border-radius: 10px; border: 2px solid #c8e6c9; background: #fff; color: #2e7d32; font-size: 18px; font-weight: 800; cursor: pointer; font-family: inherit; }
.cg-step-chip:hover { background: #e8f5e9; }
.cg-step-chip.sel { background: #43a047; border-color: #43a047; color: #fff; }
.cg-step-hint { margin-top: 6px; font-size: 13px; font-weight: 700; color: #78909c; }

/* Διαδραστική βοήθεια (js/codehelp.js): αναβόσβημα κελιού-στόχου, κάρτας, μπλοκ στην εργαλειοθήκη/χώρο εργασίας */
.mz-cell.hintflash { animation: cg-cell-flash .45s 6; z-index: 2; }
@keyframes cg-cell-flash { 0%, 100% { box-shadow: inset 0 0 0 0 transparent; } 50% { box-shadow: inset 0 0 0 5px #ff5722; } }
.seq-card.hintflash { animation: cg-card-flash .45s 6; }
@keyframes cg-card-flash { 0%, 100% { transform: scale(1); border-color: #ffb74d; } 50% { transform: scale(1.18); border-color: #f44336; box-shadow: 0 0 0 4px #ff8a65; } }
.arrow-pad button.flash, .seq-palette button.flash { animation: tf-flash .5s 6; }
g.cg-flash { animation: cg-block-flash .5s 6; }
@keyframes cg-block-flash { 0%, 100% { filter: none; } 50% { filter: drop-shadow(0 0 4px #ff9800) drop-shadow(0 0 10px #ff9800) brightness(1.25); } }

/* Κάρτα σκορ επιπέδου (μέσα στο παράθυρο «Μπράβο»): κορδέλα «Το επίπεδο ολοκληρώθηκε!» με 1–3 αστέρια */
.score-card { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 2px 0 10px; }
.code-win-stars { display: flex; align-items: flex-end; gap: 6px; margin-bottom: -22px; position: relative; z-index: 2; }
.cw-star { font-size: 60px; line-height: 1; filter: grayscale(1) brightness(1.1) drop-shadow(0 3px 3px rgba(0,0,0,.35)); opacity: .8; transform: scale(.85); }
.cw-star:nth-child(2) { font-size: 80px; margin-bottom: 8px; }
.cw-star.earned { animation: cw-star-pop .55s cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes cw-star-pop {
  0% { filter: grayscale(1) brightness(1.1); opacity: .8; transform: scale(.3) rotate(-30deg); }
  60% { filter: none; opacity: 1; transform: scale(1.35) rotate(8deg); }
  100% { filter: drop-shadow(0 0 10px #ffd54f) drop-shadow(0 4px 4px rgba(0,0,0,.3)); opacity: 1; transform: scale(1) rotate(0); }
}
/* Κόκκινο αστέρι-bonus (χωρίς ίχνος): εμφανίζεται δεξιά από τα τρία, με δική του εμφάνιση */
.cw-bonus { position: absolute; right: -78px; top: -6px; display: flex; flex-direction: column; align-items: center; gap: 0; transform: scale(0); animation: cw-bonus-pop .6s cubic-bezier(.2, 1.6, .5, 1) both; }
.cw-bonus b { font-size: 58px; line-height: 1; color: #e53935; -webkit-text-stroke: 2px #ffd54f; text-shadow: 0 0 12px #ff7043, 0 4px 4px rgba(0,0,0,.3); animation: cw-bonus-glow 1.2s ease-in-out infinite alternate; }
.cw-bonus small { font-size: 12px; font-weight: 800; color: #b71c1c; background: #ffebee; border: 2px solid #ef9a9a; border-radius: 10px; padding: 1px 7px; white-space: nowrap; margin-top: -4px; }
@keyframes cw-bonus-pop { 0% { transform: scale(0) rotate(-90deg); opacity: 0; } 60% { transform: scale(1.3) rotate(15deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes cw-bonus-glow { from { text-shadow: 0 0 6px #ff7043, 0 4px 4px rgba(0,0,0,.3); } to { text-shadow: 0 0 18px #ff5722, 0 0 30px #ffab91, 0 4px 4px rgba(0,0,0,.3); } }
.code-win-score span.bonus { background: #ffebee; border-color: #ef9a9a; color: #b71c1c; }
@media (max-width: 900px) { .cw-bonus { right: -62px; } .cw-bonus b { font-size: 42px; } }
.code-win-ribbon {
  background: linear-gradient(#8bc34a, #43a047); color: #fff; font-weight: 900; font-size: 30px; padding: 16px 40px; border-radius: 26px;
  border: 4px solid #2e7d32; box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 8px 0 #1b5e20, 0 14px 30px rgba(0,0,0,.25);
  text-shadow: 0 3px 0 #2e7d32; animation: popin .45s cubic-bezier(.2, 1.4, .5, 1);
}
.code-win-score { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; font-weight: 700; font-size: 16px; }
.code-win-score span { background: #fff8e1; color: #37474f; padding: 6px 14px; border-radius: 16px; border: 2px solid #ffd54f; }
.code-win-tip { color: #546e7a; font-weight: 600; font-size: 15px; text-align: center; max-width: 480px; }
@media (max-width: 900px) { .code-win-ribbon { font-size: 22px; padding: 12px 22px; } .cw-star { font-size: 44px; } .cw-star:nth-child(2) { font-size: 58px; } }

/* ---- Γωνία με κύκλο (field_angle_dial, js/codegames.js): σύρε τη χελώνα στη γωνία ---- */
/* Το «κουτί» του Blockly κόβει στα 300px με μπάρα κύλισης — για τον κύκλο το αφήνουμε να μεγαλώσει */
.blocklyDropDownContent.cg-dial-host { max-height: none !important; overflow: hidden !important; }
.cg-dial { padding: 6px 10px 10px; font-family: var(--font); text-align: center; user-select: none; touch-action: none; }
.cg-dial-q { font-size: 14px; font-weight: 800; color: #e65100; margin-bottom: 2px; }
.cg-dial-svg { display: block; margin: 0 auto; touch-action: none; cursor: grab; }
.cg-dial-svg:active { cursor: grabbing; }
.cg-dial-tick { font-size: 12px; font-weight: 700; fill: #78909c; text-anchor: middle; font-family: var(--font); }
.cg-dial-tick.now { fill: #2e7d32; font-size: 13px; font-weight: 800; }
.cg-dial-turtle { font-size: 18px; text-anchor: middle; pointer-events: none; }
.cg-d-num { font-size: 22px; font-weight: 900; fill: #e65100; text-anchor: middle; font-family: var(--font); pointer-events: none; }
.cg-dial-ok { height: 32px; border-radius: 10px; border: 0; background: #43a047; color: #fff; font-size: 17px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 #2e7d32; font-family: inherit; }
.cg-dial-ok:active { transform: translateY(2px); box-shadow: 0 1px 0 #2e7d32; }
.cg-dial-name { font-size: 14px; font-weight: 800; color: #6d4c41; min-height: 17px; }
.cg-dial-chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 4px; }
.cg-dial-chip { height: 32px; border-radius: 10px; border: 2px solid #ffe0b2; background: #fff; color: #e65100; font-size: 15px; font-weight: 800; cursor: pointer; font-family: inherit; }
.cg-dial-chip:hover { background: #fff8e1; }
.cg-dial-chip.sel { background: #fb8c00; border-color: #fb8c00; color: #fff; }

