/* =====================================================================
   STYLE.CSS — how the page looks (studio, HUD, classroom card, About)
   Colours are kept as "CSS variables" at the top so they're easy to change.
   ===================================================================== */
:root {
    --bg: #141833; --panel: rgba(20, 24, 51, 0.82); --line: rgba(255, 255, 255, 0.12);
    --text: #eef0ff; --muted: #a8aed6; --accent: #ffd23f; --accent2: #7c5cff; --good: #3ddc84; --bad: #ff5e6c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: 'Nunito', system-ui, sans-serif; }
button { font-family: 'Fredoka', 'Nunito', sans-serif; cursor: pointer; border: 0; border-radius: 12px; padding: 9px 14px; font-size: 15px; background: var(--accent); color: #231a00; font-weight: 600; transition: transform .1s, filter .15s; }
button:hover { filter: brightness(1.08); } button:active { transform: scale(.96); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: rgba(255, 255, 255, 0.1); color: var(--text); border: 1px solid var(--line); }
kbd { font-family: inherit; background: rgba(255,255,255,.15); border-radius: 6px; padding: 0 6px; font-size: 13px; }
[hidden] { display: none !important; }

/* ---------------- Studio ---------------- */
#studio { position: fixed; inset: 0; display: flex; z-index: 20; }
#studio-stage { position: relative; flex: 1; min-width: 0; }
#studio-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.studio-top { position: absolute; top: 14px; left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.studio-top > * { pointer-events: auto; }
.studio-top h1 { margin: 0; font-family: 'Fredoka', sans-serif; font-size: 30px; text-shadow: 0 3px 12px rgba(0,0,0,.5); }
.studio-top h1 span { background: var(--accent2); color: #fff; padding: 2px 10px; border-radius: 10px; font-size: 18px; vertical-align: middle; }
#welcome { position: absolute; top: 64px; left: 18px; background: rgba(61,220,132,.18); border: 1px solid var(--good); padding: 8px 14px; border-radius: 12px; font-weight: 700; }
#anim-bar { position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; background: var(--panel); padding: 8px; border-radius: 16px; max-width: 94%; }
#anim-bar button { background: rgba(255,255,255,.08); color: var(--text); padding: 7px 11px; font-size: 14px; }
#anim-bar button.on { background: var(--accent2); color: #fff; }
#anim-bar .sep { width: 1px; background: var(--line); margin: 0 4px; }
.drag-hint { position: absolute; bottom: 14px; width: 100%; text-align: center; color: var(--muted); font-size: 13px; }
#studio-panel { width: 380px; max-width: 46vw; background: #1b2045; border-left: 1px solid var(--line); overflow-y: auto; padding: 16px 18px 24px; }
#studio-panel section { margin-bottom: 16px; }
#studio-panel h3 { font-family: 'Fredoka', sans-serif; margin: 0 0 8px; font-size: 17px; }
#studio-panel h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
#studio-panel h4 { margin: 10px 0 6px; font-size: 13px; color: var(--muted); }
#name-input, #chat-input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.07); color: var(--text); font-size: 15px; font-family: inherit; outline: none; }
#name-input:focus, #chat-input:focus { border-color: var(--accent); }
.seg, .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.seg button, .chips button { background: rgba(255,255,255,.08); color: var(--text); padding: 7px 12px; font-size: 14px; }
.seg button.on, .chips button.on { background: var(--accent2); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); }
.sw.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.slider { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; font-size: 14px; margin: 3px 0; }
.slider input { width: 100%; accent-color: var(--accent2); }
#map-cards { display: grid; gap: 8px; }
.map-card { text-align: left; background: rgba(255,255,255,.06); color: var(--text); border: 2px solid transparent; padding: 10px 12px 10px 58px; position: relative; font-weight: 400; }
.map-card b { display: block; font-size: 16px; margin-bottom: 2px; }
.map-card span { font-family: 'Nunito', sans-serif; font-size: 13px; color: var(--muted); }
.map-card::before { position: absolute; left: 12px; top: 12px; font-size: 32px; }
.map-card.eden::before { content: '🌳'; } .map-card.israel::before { content: '🏛️'; }
.map-card.on { border-color: var(--accent); background: rgba(255,210,63,.1); }
.panel-actions { display: flex; gap: 8px; position: sticky; bottom: -24px; background: #1b2045; padding: 10px 0; }
.panel-actions #enter-btn { flex: 1; font-size: 17px; }
#studio-status { color: var(--accent); min-height: 20px; font-weight: 700; font-size: 14px; }

/* ---------------- HUD ---------------- */
#game canvas { position: fixed; inset: 0; display: block; }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-size: 14px; }
#hud button, #hud input, #hud #lesson-card, #hud #joystick { pointer-events: auto; }
#stats { position: absolute; top: 12px; left: 12px; background: var(--panel); padding: 10px 14px; border-radius: 14px; min-width: 190px; }
#score-line, #ticks-line { font-family: 'Fredoka', sans-serif; font-size: 17px; }
#ticks-line { color: var(--good); }
#speed-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; pointer-events: auto; }
#speed-bar button { background: rgba(255,255,255,.1); color: var(--text); padding: 5px 8px; font-size: 13px; border-radius: 9px; }
#speed-bar button.on { background: var(--accent); color: #231a00; }
#map-wrap { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#minimap { width: 150px; height: 150px; border-radius: 50%; border: 3px solid rgba(255,255,255,.6); background: #0003; }
#dial { background: var(--panel); border-radius: 12px; padding: 4px 10px; display: flex; align-items: center; gap: 8px; font-family: 'Fredoka', sans-serif; }
#dial-arc { width: 34px; height: 17px; border-radius: 34px 34px 0 0; background: linear-gradient(90deg, #26307a, #ff9a76, #ffd23f); position: relative; overflow: hidden; }
#dial-needle { position: absolute; left: 16px; bottom: 0; width: 2px; height: 16px; background: #fff; transform-origin: bottom center; }
#leaderboard { position: absolute; top: 230px; right: 12px; width: 210px; background: var(--panel); border-radius: 14px; padding: 8px 12px; }
#leaderboard h4 { margin: 4px 0; font-family: 'Fredoka', sans-serif; font-size: 14px; color: var(--muted); }
#leaderboard ol { margin: 0 0 6px; padding: 0; list-style: none; }
#leaderboard li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#leaderboard li.me .nm { color: var(--accent); font-weight: 700; }
#leaderboard li.empty { color: var(--muted); font-size: 12px; }
#leaderboard .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
#leaderboard .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#leaderboard .tk { color: var(--good); font-weight: 700; }
#leaderboard .sc { min-width: 40px; text-align: right; }
#chat { position: absolute; left: 12px; bottom: 60px; width: 320px; max-width: 60vw; }
#chat-log { max-height: 150px; overflow-y: auto; font-size: 13px; text-shadow: 0 1px 3px #000; margin-bottom: 6px; }
#chat-log .sys { color: var(--accent); }
#chat-input { background: var(--panel); }
#emote-bar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 6px; }
#emote-bar button { background: var(--panel); color: #fff; font-size: 20px; padding: 6px 11px; }
#emote-bar button.on { background: var(--accent2); }
#help { position: absolute; left: 12px; bottom: 16px; color: var(--muted); font-size: 12px; text-shadow: 0 1px 2px #000; }
#action-btn { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); font-size: 18px; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.06); } }
#toast { position: absolute; top: 90px; left: 50%; transform: translate(-50%, -20px); background: var(--panel); padding: 10px 18px; border-radius: 14px; font-family: 'Fredoka', sans-serif; font-size: 18px; opacity: 0; transition: .3s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { border: 2px solid var(--good); } #toast.bad { border: 2px solid var(--bad); }
#joystick { position: absolute; left: 24px; bottom: 90px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.25); display: none; touch-action: none; }
#knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.6); }
body.touch #joystick { display: block; }
body.touch #help { display: none; }
body.touch #chat { bottom: 220px; width: 240px; }

/* name tags and speech bubbles */
#tags { position: absolute; inset: 0; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; will-change: transform; }
.tag > span { background: rgba(10, 12, 30, .6); padding: 2px 8px; border-radius: 8px; border-bottom: 3px solid; font-weight: 700; font-size: 13px; white-space: nowrap; }
.bubble { display: none; background: #fff; color: #1b1b2f; padding: 8px 12px; border-radius: 14px; max-width: 260px; font-size: 14px; font-weight: 700; position: relative; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.bubble.show { display: block; }
.bubble::after { content: ''; position: absolute; bottom: -8px; left: 50%; margin-left: -8px; border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; }

/* ---------------- Classroom question card ---------------- */
#lesson-card { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(620px, 94vw); background: rgba(250, 248, 240, .97); color: #1b1b2f; border-radius: 20px; padding: 16px 20px; box-shadow: 0 12px 40px rgba(0,0,0,.45); z-index: 3; }
#lesson-teacher { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
#lesson-body p { font-family: 'Fredoka', sans-serif; font-size: 22px; margin: 0 0 12px; }
#lesson-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#lesson-options button { background: #fff; color: #1b1b2f; border: 2px solid #d8d4e8; text-align: left; font-size: 17px; padding: 10px 12px; }
#lesson-options button:hover:not(:disabled) { border-color: var(--accent2); }
#lesson-options button.picked { border-color: var(--accent2); }
#lesson-options button.right { background: #d9fbe6; border-color: #22a55a; }
#lesson-options button.wrong { background: #ffe0e3; border-color: #e0334a; }
#lesson-result { margin-top: 10px; font-size: 15px; font-weight: 700; }
#lesson-result.good { color: #1c8a4a; } #lesson-result.bad { color: #b3263a; }
.lesson-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.lesson-buttons .ghost { color: #1b1b2f; border-color: #cfcbe0; background: #fff; }

/* ---------------- About window ---------------- */
#about-modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 25, .7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.about-box { position: relative; width: min(820px, 100%); max-height: 92vh; background: #1d2250; border: 1px solid var(--line); border-radius: 22px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.about-scroll { overflow-y: auto; padding: 26px 30px; line-height: 1.55; }
.about-scroll h2 { font-family: 'Fredoka', sans-serif; margin: 0 0 8px; font-size: 28px; }
.about-scroll h3 { font-family: 'Fredoka', sans-serif; color: var(--accent); margin: 26px 0 6px; font-size: 21px; scroll-margin-top: 10px; }
.about-scroll .lead { font-size: 17px; }
.about-scroll code { background: rgba(255,255,255,.1); padding: 1px 6px; border-radius: 6px; font-size: 14px; }
.about-scroll pre { background: #0f1230; padding: 12px 14px; border-radius: 12px; overflow-x: auto; font-size: 13px; line-height: 1.45; }
.about-scroll ul { padding-left: 22px; } .about-scroll li { margin: 4px 0; }
#about-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
#about-toc a { background: rgba(255,255,255,.08); color: var(--text); text-decoration: none; padding: 5px 10px; border-radius: 10px; font-size: 13px; }
#about-toc a:hover { background: var(--accent2); }
#about-close { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.1); color: #fff; padding: 6px 11px; z-index: 2; }
#about-go { margin-top: 18px; font-size: 18px; }

@media (max-width: 760px) {
    #studio { flex-direction: column; }
    #studio-stage { flex: none; height: 44vh; }
    #studio-panel { width: 100%; max-width: none; flex: 1; border-left: 0; border-top: 1px solid var(--line); }
    .studio-top h1 { font-size: 22px; }
    #anim-bar { bottom: 30px; padding: 5px; gap: 4px; } #anim-bar button { padding: 5px 8px; font-size: 12px; }
    #leaderboard { top: auto; bottom: 240px; width: 170px; font-size: 12px; }
    #minimap { width: 110px; height: 110px; }
    #lesson-body p { font-size: 18px; } #lesson-options { grid-template-columns: 1fr; }
}
