/* יונתן וממלכת הבלוקים — ממשק בסגנון פיקסלים ובלוקים */
:root {
  color-scheme: dark;
  --ink: #ffffff;
  --shadow: #3f3f3f;
  --panel: rgba(30, 30, 38, .86);
  --stone: #8b8b8b;
  --wood: #b08850;
  --grass: #5fa83c;
  --gold: #ffd23a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Rubik', 'Arial Hebrew', Arial, sans-serif;
  --pix: 'Press Start 2P', 'Courier New', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #5aa8e8; color: var(--ink); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
[hidden] { display: none !important; }
button { font-family: inherit; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
h1, h2 { margin: 0; font-weight: 900; text-shadow: 3px 3px 0 var(--shadow); }

/* כפתורי בלוק: שוליים חדים, הדגשה מלמעלה וצל מלמטה */
.mc-btn {
  position: relative; cursor: pointer; color: #fff; font-weight: 700; font-size: 18px; min-height: 48px; padding: 8px 18px;
  background: #7d7d7d; border: 3px solid #1a1a1a; border-radius: 0;
  box-shadow: inset 3px 3px 0 #b9b9b9, inset -3px -3px 0 #545454; text-shadow: 2px 2px 0 #3a3a3a;
}
.mc-btn:hover { background: #8f95c9; box-shadow: inset 3px 3px 0 #c6caf0, inset -3px -3px 0 #5a5f96; }
.mc-btn:active { transform: translateY(2px); }
.mc-btn.big { font-size: 22px; min-height: 60px; padding: 10px 28px; }
.mc-btn.small { font-size: 15px; min-height: 42px; padding: 6px 12px; }
.mc-btn.green { background: #4f9a31; box-shadow: inset 3px 3px 0 #8fd46a, inset -3px -3px 0 #2f6a1b; }
.mc-btn.wood { background: #a07a45; box-shadow: inset 3px 3px 0 #d1ad73, inset -3px -3px 0 #6d5028; }
.mc-btn.red { background: #b8342e; box-shadow: inset 3px 3px 0 #e2706a, inset -3px -3px 0 #7a1f1b; }
.mc-btn.off { opacity: .55; text-decoration: line-through; }
.link-btn { background: none; border: 0; color: #e8e8e8; text-decoration: underline; cursor: pointer; font-size: 15px; padding: 6px; }

/* מסכים */
.screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(112px + var(--safe-b)); overflow: auto; }
.card { width: min(560px, 100%); padding: 22px 20px; background: var(--panel); border: 4px solid #1a1a1a; box-shadow: inset 4px 4px 0 rgba(255, 255, 255, .12), inset -4px -4px 0 rgba(0, 0, 0, .35), 0 10px 0 rgba(0, 0, 0, .25); display: grid; gap: 14px; justify-items: center; text-align: center; }
.title-card h1 { font-size: clamp(42px, 12vw, 64px); line-height: 1; color: var(--gold); }
.title-card h1 span { display: block; font-size: .5em; color: #fff; margin-top: 6px; }
.logo { display: grid; grid-template-columns: repeat(2, 38px); gap: 4px; }
.logo i { width: 38px; height: 38px; border: 3px solid #1a1a1a; }
.logo i:nth-child(1) { background: linear-gradient(#5fa83c 40%, #8a5a32 40%); }
.logo i:nth-child(2) { background: #55d8d2; }
.logo i:nth-child(3) { background: #f2c230; }
.logo i:nth-child(4) { background: #b08850; }
.hello { margin: 0; font-size: 26px; font-weight: 900; }
.sub { margin: 0; font-size: 18px; color: #e6e6e6; max-width: 30ch; }
.settings, .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.reset { display: grid; gap: 8px; }
.reset p { margin: 0; }

.guide-row { display: flex; align-items: center; gap: 12px; }
.guide-img { width: 56px; height: 56px; image-rendering: pixelated; border: 3px solid #1a1a1a; background: #1b3a5a; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 16px; color: #eee; }
.stats b, .counters b { font-family: var(--pix); font-size: 13px; font-weight: 400; }
.worlds { display: grid; gap: 10px; width: 100%; }
.world {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: start;
  padding: 10px 12px; cursor: pointer; color: #fff; border: 3px solid #1a1a1a; box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .25), inset -3px -3px 0 rgba(0, 0, 0, .3);
}
.world .wnum { grid-row: span 2; width: 40px; height: 40px; display: grid; place-items: center; background: rgba(0, 0, 0, .3); font-family: var(--pix); font-size: 16px; }
.world .wname { font-size: 20px; font-weight: 900; text-shadow: 2px 2px 0 rgba(0, 0, 0, .45); }
.world .wtopic { grid-column: 2; font-size: 14px; opacity: .95; }
.world .wstars { grid-row: 1 / span 2; grid-column: 3; font-size: 22px; letter-spacing: 2px; }
.world .wstars i { font-style: normal; color: rgba(0, 0, 0, .35); } .world .wstars i.on { color: var(--gold); text-shadow: 2px 2px 0 #7a5a00; }
.world .wprog { grid-column: 2; font-size: 12px; background: rgba(0, 0, 0, .3); padding: 2px 6px; justify-self: start; }
.world.meadow { background: #4f9a31; } .world.forest { background: #2f6e2a; } .world.desert { background: #c9a653; } .world.cave { background: #4a4858; } .world.castle { background: #7a5ad0; }
.world.locked { filter: grayscale(.8) brightness(.6); cursor: default; }
.world:not(.locked):hover { filter: brightness(1.12); }

.done-card h2 { font-size: 30px; color: var(--gold); }
.stars { font-size: 56px; letter-spacing: 6px; } .stars i { font-style: normal; color: rgba(255, 255, 255, .2); } .stars i.on { color: var(--gold); text-shadow: 3px 3px 0 #7a5a00; animation: star .5s ease both; }
.stars i:nth-child(2) { animation-delay: .3s; } .stars i:nth-child(3) { animation-delay: .6s; }
@keyframes star { from { transform: scale(0) rotate(-40deg); } }
.house { place-items: start center; }
.house-card { width: min(520px, 100%); }
.house-card h2 { font-size: 24px; color: var(--gold); }
.house-card p { margin: 0; }

/* ממשק בעולם */
.topbar { position: fixed; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; z-index: 5; display: flex; align-items: center; gap: 10px; }
.wtitle { flex: 1; display: grid; justify-items: center; gap: 4px; background: var(--panel); border: 3px solid #1a1a1a; padding: 4px 10px; }
.wtitle span { font-weight: 900; font-size: 17px; text-shadow: 2px 2px 0 var(--shadow); }
.progress { display: flex; gap: 3px; direction: rtl; }
.progress i { width: 16px; height: 12px; background: #3a3a3a; border: 2px solid #1a1a1a; }
.progress i.done { background: var(--grass); } .progress i.now { background: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { background: #fff5b0; } }
.counters { display: grid; gap: 2px; background: var(--panel); border: 3px solid #1a1a1a; padding: 4px 10px; font-size: 15px; white-space: nowrap; }

.panel {
  position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); z-index: 6; transform: translateX(-50%); width: min(620px, calc(100% - 16px));
  background: var(--panel); border: 4px solid #1a1a1a; box-shadow: inset 4px 4px 0 rgba(255, 255, 255, .12), inset -4px -4px 0 rgba(0, 0, 0, .35); padding: 12px 14px 14px; display: grid; gap: 10px;
  animation: rise .25s steps(4) both;
}
@keyframes rise { from { transform: translate(-50%, 40px); opacity: 0; } }
.qhead { display: flex; justify-content: space-between; align-items: center; font-size: 15px; color: #ddd; }
.qlevel { padding: 2px 8px; border: 2px solid #1a1a1a; font-size: 13px; font-weight: 700; }
.qlevel.t0 { background: #4f9a31; } .qlevel.t1 { background: #c9a653; } .qlevel.t2 { background: #b8342e; }
.eq { text-align: center; font-family: var(--pix); font-size: clamp(26px, 8vw, 44px); line-height: 1.4; color: #fff; text-shadow: 4px 4px 0 var(--shadow); }
.eq .qmark { color: var(--gold); animation: blink2 1s steps(2) infinite; }
@keyframes blink2 { 50% { opacity: .4; } }
.word { margin: 0; font-size: clamp(19px, 5vw, 22px); line-height: 1.5; font-weight: 700; text-align: center; }
.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.choice {
  min-height: 64px; cursor: pointer; color: #fff; font-family: var(--pix); font-size: clamp(18px, 5vw, 24px);
  background: #a07a45; border: 3px solid #1a1a1a; box-shadow: inset 3px 3px 0 #d1ad73, inset -3px -3px 0 #6d5028; text-shadow: 3px 3px 0 #4a3418;
}
.choice:hover:not(:disabled) { filter: brightness(1.12); }
.choice:active:not(:disabled) { transform: translateY(2px); }
.choice.right { background: #4f9a31; box-shadow: inset 3px 3px 0 #8fd46a, inset -3px -3px 0 #2f6a1b; animation: pop .4s ease; }
.choice.wrong { background: #6a3a36; box-shadow: none; opacity: .55; animation: shake .35s; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.tools { display: flex; gap: 8px; justify-content: center; }
.hint { background: rgba(0, 0, 0, .35); border: 3px solid #1a1a1a; padding: 10px; display: grid; gap: 6px; }
.hint p { margin: 0; font-size: 16px; text-align: center; }
.hint-vis .row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 3px; direction: ltr; }
.cube { display: inline-block; width: 18px; height: 18px; border: 2px solid #1a1a1a; box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .35); position: relative; }
.cube.g, .rod.g { background: #5fa83c; } .cube.b, .rod.b { background: #3f76e4; } .cube.r, .rod.r { background: #d9463b; }
.cube.empty { background: transparent; border-style: dashed; border-color: #ddd; box-shadow: none; }
.cube.x::after { content: '✕'; position: absolute; inset: -4px 0 0; color: #ff4a3a; font-size: 18px; font-weight: 900; text-align: center; line-height: 22px; }
.rod { display: inline-block; width: 16px; height: 110px; border: 2px solid #1a1a1a; background-image: repeating-linear-gradient(0deg, transparent 0 9px, rgba(0, 0, 0, .45) 9px 11px) !important; }
.rod.g { background-color: #5fa83c; } .rod.b { background-color: #3f76e4; } .rod.r { background-color: #d9463b; }
.to { display: inline-flex; gap: 3px; align-items: flex-end; flex-wrap: wrap; }
.gap { width: 10px; } .gap5 { width: 4px; }
.op { font-family: var(--pix); font-size: 20px; margin: 0 6px; align-self: center; }
.legend .rod { height: 18px; width: 12px; background-image: none !important; vertical-align: middle; } .legend .cube { width: 12px; height: 12px; vertical-align: middle; }
.hint-tip { color: #ffe9a0; }

/* בועת הקריינית */
.bubble {
  position: fixed; left: 50%; top: calc(84px + var(--safe-t)); z-index: 20; transform: translateX(-50%); width: min(560px, calc(100% - 16px));
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #fffbe8; color: #2a2150; border: 3px solid #1a1a1a; box-shadow: 4px 4px 0 rgba(0, 0, 0, .35);
}
.bubble.pop { animation: bpop .3s steps(3); }
@keyframes bpop { from { transform: translate(-50%, -8px) scale(.96); } }
.bubble p { margin: 0; flex: 1; font-size: 17px; font-weight: 700; line-height: 1.4; }
.bubble .guide-img { width: 46px; height: 46px; flex: none; }
.bubble .say { width: 40px; height: 40px; cursor: pointer; background: #ffd23a; border: 3px solid #1a1a1a; font-size: 18px; flex: none; }
.screen:not([hidden]) ~ .bubble { top: auto; bottom: calc(10px + var(--safe-b)); }

.toast { position: fixed; left: 50%; top: 44%; z-index: 25; transform: translate(-50%, 0) scale(.8); opacity: 0; pointer-events: none; font-family: var(--pix); font-size: 20px; color: #fff; text-shadow: 3px 3px 0 #1a1a1a; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, -20px) scale(1); }

@media (max-width: 600px) {
  .choices { grid-template-columns: repeat(2, 1fr); }
  .choice { min-height: 58px; }
  .bubble p { font-size: 15px; }
  .wtitle span { font-size: 15px; }
  .progress i { width: 12px; height: 10px; }
  #btnMap { font-size: 13px; padding: 4px 8px; }
  .rod { height: 90px; width: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
