/* Clock Climb — styles. Bright and sunny: a sky-blue bar, a cream page, and
   the clock standing in a meadow under a sky that follows the time. The short
   hour hand is blue, the long minute hand orange, everywhere. */
:root {
  --bg: #fdf6e3;
  --panel: #ffffff;
  --text: #2a2420;
  --muted: #6b625a;
  --line: #e4dccb;
  --blue: #2f8fe0;
  --blue-dark: #1a4f8f;
  --hour: #2457a6;
  --minute: #e2622c;
  --go: #2fa35a;
  --go-dark: #23824a;
  --sun: #ffd23f;
  --right: #2fa35a;
  --wrong: #d0402e;
  --tc: #2f6fe0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button {
  font: inherit; font-weight: 700; border: 2px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 8px 16px; cursor: pointer; touch-action: manipulation;
}
button:disabled { cursor: default; }
button.go { background: var(--go); border-color: var(--go-dark); color: #fff; font-size: 18px; padding: 10px 22px; }
button.go:not(:disabled):hover { background: var(--go-dark); }
button.go.big { font-size: 22px; padding: 12px 40px; border-radius: 999px; box-shadow: 0 4px 0 var(--go-dark); }
button.secondary { background: #fff; }
button.danger { color: var(--wrong); border-color: #f0c4be; }
button.icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 20px; }
button.plain { border: none; background: none; }
.small { color: var(--muted); font-size: 13px; }
b.hh { color: var(--hour); }
b.mh { color: var(--minute); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0;
  padding: 8px 14px; background: linear-gradient(90deg, #2f8fe0, #45b0f0); color: #fff;
  border-bottom: 5px solid var(--sun);
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark { font-size: 22px; background: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.top-right { display: flex; gap: 8px; align-items: center; }
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.apps-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 6px 14px;
  border-radius: 999px; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .6);
  color: #fff; text-decoration: none; font-weight: 700; font-size: 16px;
}
.apps-link:hover { background: rgba(255, 255, 255, .3); }
.apps-link svg { fill: currentColor; flex: none; }
.player-chip { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .6); padding: 6px 14px; }
.topbar button.icon { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .6); }
.update-note {
  display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; background: #fff4d6;
  border-bottom: 1px solid #f0d58a; font-weight: 600; flex-shrink: 0;
}

/* ---------- home ---------- */
.home { max-width: 1180px; width: 100%; margin: 0 auto; padding: 12px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }
.home h2 { margin: 0 0 10px; font-size: 18px; color: var(--blue-dark); }
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
.players { display: flex; flex-wrap: wrap; gap: 10px; }
.player { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 30px; border: 3px solid var(--line); }
.player-emoji { font-size: 28px; line-height: 1; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #f6f1e4; }
.player.on { border-color: var(--pc, var(--blue)); background: color-mix(in srgb, var(--pc, var(--blue)) 10%, #fff); }
.player.add { color: var(--muted); border-style: dashed; }
.player-badges { font-size: 18px; letter-spacing: 1px; margin-left: 2px; }
.climb-panel { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: linear-gradient(#e3f4ff, #fff); }
.mountain { flex: 1; min-width: 0; }
.mountain svg { width: 100%; height: auto; display: block; max-height: 130px; }
.home-total { font-size: 15px; color: var(--muted); font-weight: 700; text-align: center; white-space: nowrap; }
.home-total b { font-size: 26px; color: #c48a00; display: block; }
.tracks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.track { border: 3px solid color-mix(in srgb, var(--tc) 35%, #fff); border-radius: 14px; padding: 8px; background: color-mix(in srgb, var(--tc) 6%, #fff); display: flex; flex-direction: column; gap: 6px; }
.track-head { display: flex; align-items: center; gap: 6px; font-weight: 900; color: var(--tc); font-size: 17px; }
.track-icon { font-size: 22px; }
.track-badge { font-size: 11.5px; font-weight: 800; color: #a59a88; border: 2px dashed #ddd3bf; border-radius: 999px; padding: 1px 8px; width: fit-content; white-space: nowrap; }
.track-badge.won { color: #7a5200; background: linear-gradient(#fff3c4, #f7d36a); border: 2px solid #d9a521; }
.track-levels { display: flex; flex-direction: column; gap: 6px; }
.lvl { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 10px; border-width: 3px; text-align: left; }
.lvl-name { font-size: 15px; min-width: 0; }
.lvl-stars { color: #f2b705; letter-spacing: 1px; font-size: 15px; white-space: nowrap; }
.lvl.on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 12%, #fff); }
.lvl.locked { background: #f4f1ea; color: var(--muted); border-style: dashed; }
.lvl.locked .lvl-stars { opacity: .4; }
.level-about { margin: 10px 2px 0; color: var(--muted); font-weight: 600; }
.home-go {
  display: flex; align-items: center; gap: 10px; position: sticky; bottom: 0; z-index: 2;
  padding: 10px 0 12px; background: linear-gradient(rgba(253, 246, 227, 0), var(--bg) 30%);
}
.spacer { flex: 1; }

/* ---------- a round ---------- */
.play { flex: 1; display: grid; grid-template-rows: auto 1fr; gap: 6px; padding: 6px 10px 10px; min-height: 0; }
.play-bar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.bar-title { font-weight: 800; font-size: 18px; color: var(--tc); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.pip { width: 14px; height: 14px; border-radius: 50%; background: #e6dfcc; border: 2px solid #d8cfb8; }
.pip.done { background: var(--right); border-color: #23824a; }
.pip.now { background: #fff; border-color: var(--tc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 25%, #fff); }
.streak { font-weight: 900; font-size: 16px; color: #c2410c; background: #fff1e0; border: 2px solid #f6b98a; border-radius: 999px; padding: 2px 12px; white-space: nowrap; }
.streak.bump { animation: pop .35s ease-out; }
.board { position: relative; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 10px; min-height: 0; }

/* the scene */
.scene {
  --sky-top: #45aef5; --sky-bottom: #d2efff;
  position: relative; min-height: 0; border-radius: 18px; overflow: hidden; border: 3px solid #fff;
  box-shadow: 0 3px 12px rgba(30, 80, 140, .18);
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  transition: background .4s;
}
.sun {
  position: absolute; width: 9%; aspect-ratio: 1; max-width: 72px; min-width: 40px; z-index: 1; translate: -50% -50%; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff6b0, var(--sun) 55%, #ffb627);
  box-shadow: 0 0 30px 12px rgba(255, 214, 80, .55); transition: left .4s, top .4s;
}
.sun.moon { background: radial-gradient(circle at 60% 40%, #fffdf2, #f1ecd2 60%, #d9d2b0); box-shadow: 0 0 24px 8px rgba(255, 255, 230, .4); }
.clouds i {
  position: absolute; width: 120px; height: 34px; background: #fff; border-radius: 40px; opacity: .85;
  animation: drift 60s linear infinite;
}
.clouds i::before, .clouds i::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.clouds i::before { width: 54px; height: 54px; left: 18px; top: -26px; }
.clouds i::after { width: 40px; height: 40px; left: 60px; top: -16px; }
.clouds i:nth-child(1) { top: 12%; left: -10%; }
.clouds i:nth-child(2) { top: 26%; left: 40%; animation-duration: 80s; animation-delay: -30s; scale: .7; }
.clouds i:nth-child(3) { top: 8%; left: 70%; animation-duration: 95s; animation-delay: -60s; scale: .85; }
@keyframes drift { from { translate: -20vw 0; } to { translate: 80vw 0; } }
.scene.night .clouds i { opacity: .25; }
.stars-sky {
  position: absolute; inset: 0 0 40% 0; opacity: 0; transition: opacity .4s;
  background-image: radial-gradient(2px 2px at 10% 20%, #fff, transparent), radial-gradient(2px 2px at 30% 10%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 25%, #fff, transparent), radial-gradient(2px 2px at 75% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 88% 30%, #fff, transparent), radial-gradient(2px 2px at 42% 35%, #fff, transparent);
}
.scene.night .stars-sky { opacity: .9; }
.scene.night .window { fill: #ffe27a; }
.land-box { position: absolute; left: 0; right: 0; bottom: 0; height: 42%; }
.land { width: 100%; height: 100%; display: block; }
.clock-box, .clock-box2 { position: absolute; inset: 17% 4% 3%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.clock-box > svg, .clock-box2 > svg { width: 100%; height: 100%; min-height: 0; filter: drop-shadow(0 6px 10px rgba(20, 50, 90, .3)); }
.scene.two .clock-box { right: 50%; left: 2%; }
.scene.two .clock-box2 { left: 50%; right: 2%; }
.clock-tag { font-weight: 900; font-size: 18px; color: var(--blue-dark); background: #fff; border-radius: 999px; padding: 2px 14px; margin-bottom: 4px; flex: none; }
.clock-box.setting svg { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.clock-box.setting svg.dragging { cursor: grabbing; }
.clock-box.setting .hand { transition: filter .15s; }
.clock-box.setting svg.drag-h .hand-h, .clock-box.setting svg.drag-m .hand-m { filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 3px #ffd23f); }
.big-digital {
  background: #2a2440; border-radius: 22px; padding: 18px 34px; border: 8px solid #fff; box-shadow: 0 8px 20px rgba(20, 50, 90, .3);
}
.big-digital span { font-size: clamp(56px, 11vw, 120px); font-weight: 900; color: #7dffb0; font-variant-numeric: tabular-nums; letter-spacing: 2px; text-shadow: 0 0 14px rgba(125, 255, 176, .5); }
.big-words {
  background: #fff; border-radius: 22px; padding: 18px 28px; border: 6px solid var(--sun); box-shadow: 0 8px 20px rgba(20, 50, 90, .25);
  font-size: clamp(30px, 5vw, 52px); font-weight: 900; color: var(--blue-dark); text-align: center; max-width: 90%;
}
.scene.cheer .clock-box > * { animation: hop .5s ease-out; }
.scene.shake .clock-box > * { animation: shake .4s; }
@keyframes hop { 0% { translate: 0 0; } 40% { translate: 0 -14px; } 100% { translate: 0 0; } }
@keyframes shake { 0%, 100% { translate: 0; } 20% { translate: -10px; } 40% { translate: 9px; } 60% { translate: -6px; } 80% { translate: 4px; } }

.day-tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 2; background: rgba(255, 255, 255, .92); border-radius: 999px;
  padding: 5px 14px; font-size: 17px; font-weight: 700; color: var(--blue-dark); box-shadow: 0 2px 8px rgba(20, 50, 90, .2);
}
.day-tag b { font-size: 19px; }
.scene.night .day-tag { background: rgba(255, 255, 255, .85); }

/* the side: question, answers, help */
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding: 2px; }
.race { height: 12px; border-radius: 999px; background: #efe6d2; overflow: hidden; flex: none; }
.race-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--sun), #ffb627); border-radius: 999px; }
.race.late .race-fill { background: #e6dfcc; }
.prompt { font-size: 22px; font-weight: 800; line-height: 1.3; color: var(--blue-dark); }
.prompt b { color: var(--tc); font-size: 1.1em; white-space: nowrap; }
.target-digital { font-size: 58px; font-weight: 900; color: var(--blue-dark); background: #fff; border: 4px solid var(--tc); border-radius: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.target-words { font-size: 30px; font-weight: 900; color: var(--blue-dark); background: #fff; border: 4px solid var(--tc); border-radius: 18px; text-align: center; padding: 8px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  position: relative; border-width: 3px; border-radius: 16px; padding: 12px 8px; min-height: 76px; display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--line); transition: transform .1s;
}
.choice:not(:disabled):hover { border-color: var(--tc); }
.choice:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.choice .key { position: absolute; left: 7px; top: 4px; font-size: 11px; color: #c5bba8; font-weight: 800; }
.dig { font-size: 38px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--blue-dark); }
.wds { font-size: 20px; font-weight: 800; color: var(--blue-dark); line-height: 1.2; }
.txt { font-size: 22px; font-weight: 800; color: var(--blue-dark); line-height: 1.2; }
.choices.two .txt { font-size: 32px; }
.choices.as-clock .choice { padding: 6px; }
.choices.as-clock .choice svg { width: 100%; max-width: 150px; height: auto; }
.choice.yes { border-color: var(--right); background: #e3f7e9; box-shadow: 0 0 0 4px #bfe9cc; }
.choice.no { border-color: #e7b9ae; background: #f6e2de; opacity: .55; }
.choice.no::after { content: '✕'; position: absolute; right: 8px; top: 2px; color: var(--wrong); font-size: 22px; }
.setpad { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.turns { display: flex; gap: 8px; flex: 1; }
.turn { width: 62px; height: 62px; border-radius: 50%; font-size: 30px; line-height: 1; padding: 0; color: var(--minute); border: 3px solid #f6c8ae; display: grid; place-items: center; }
.turn small { font-size: 13px; color: var(--muted); margin-top: -6px; }
.turn.fine { width: 52px; height: 52px; font-size: 24px; }
.check {
  margin-left: auto; width: 84px; height: 84px; border-radius: 50%; padding: 0; background: var(--go); border: 4px solid var(--go-dark);
  box-shadow: 0 4px 0 var(--go-dark); display: grid; place-items: center;
}
.check svg { width: 48px; height: 48px; }
.check:active { transform: translateY(3px); box-shadow: none; }
.setpad button:disabled { opacity: .45; }
.say { font-size: 22px; font-weight: 900; min-height: 1.3em; }
.say.good { color: var(--right); animation: pop .35s ease-out; }
.say.bad { color: var(--wrong); }
.say.late { color: var(--muted); }
.say.shown { color: var(--blue-dark); font-size: 19px; }
.helpbox { background: #fff8dc; border: 2px solid #f2d27a; border-radius: 14px; padding: 8px 12px; font-size: 16px; line-height: 1.45; }
.helpbox .tip { margin: 0; }
.watch-count { margin: 6px 0 0; font-size: 26px; font-weight: 900; color: var(--blue-dark); font-variant-numeric: tabular-nums; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.help-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.htab { font-size: 15px; padding: 7px 12px; border-radius: 999px; }
.htab.on { background: #fff1c2; border-color: #e6b422; }
.help-tabs.nudge .htab { animation: nudge 1.4s ease-in-out 2; }
@keyframes nudge { 0%, 100% { scale: 1; } 50% { scale: 1.08; border-color: #e6b422; } }
#btn-next { font-size: 22px; padding: 12px; border-radius: 999px; }

.result {
  position: absolute; inset: 0; margin: auto; width: min(440px, 92%); height: fit-content; background: #fff; border-radius: 22px;
  border: 4px solid var(--sun); box-shadow: 0 10px 40px rgba(20, 50, 110, .25); padding: 18px 20px; text-align: center; z-index: 3;
}
.result-title { font-size: 28px; font-weight: 900; color: var(--blue-dark); }
.result-stars { font-size: 50px; color: #f2b705; letter-spacing: 4px; }
.result-detail { color: var(--muted); font-weight: 700; margin: 4px 0 12px; }
.result-rewards { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 4px; font-weight: 800; color: #7a4a00; }
.result-rewards li { background: #fff6dc; border-radius: 10px; padding: 4px 10px; }
.result-rewards:empty { display: none; }
.result-buttons { display: flex; gap: 10px; justify-content: center; }

/* ---------- dialogs ---------- */
.dialog { max-width: 460px; width: calc(100% - 28px); border: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.dialog.wide { max-width: 760px; }
.dialog::backdrop { background: rgba(20, 30, 50, .45); }
.dialog h2 { margin: 0 0 12px; color: var(--blue-dark); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field input[type=text], .field select { font: inherit; font-weight: 500; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; }
.field input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.field-label { font-weight: 700; margin-bottom: 6px; }
.emoji-pick { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; margin-bottom: 14px; }
.emoji-pick button { font-size: 26px; padding: 4px 0; border-radius: 10px; }
.emoji-pick button.on { border-color: var(--blue); background: #e6f2fc; }
.dialog-buttons { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.help li { margin-bottom: 8px; line-height: 1.45; }

/* ---------- rewards: celebrations ---------- */
.toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 20; pointer-events: none;
  background: #c2410c; color: #fff; font-weight: 900; font-size: 20px; padding: 8px 20px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(194, 65, 12, .35);
}
.toast.show { animation: toastIn 2.2s ease-out forwards; }
@keyframes toastIn {
  0% { opacity: 0; translate: 0 -12px; scale: .8; } 12% { opacity: 1; translate: 0 0; scale: 1.08; } 20% { scale: 1; }
  80% { opacity: 1; } 100% { opacity: 0; translate: 0 -8px; }
}
.celebrate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(20, 35, 70, .45); overflow: hidden; }
.cel-card {
  position: relative; z-index: 2; background: #fff; border-radius: 22px; border: 4px solid var(--sun); padding: 22px 28px 20px;
  width: min(420px, 90%); text-align: center; box-shadow: 0 16px 50px rgba(20, 35, 70, .4); animation: celIn .5s cubic-bezier(.2, 1.6, .4, 1);
}
.cel-icon { font-size: 72px; line-height: 1.1; animation: wiggle 1.2s ease-in-out .4s 2; }
.celebrate.badge .cel-icon {
  width: 120px; height: 120px; margin: 0 auto 6px; display: grid; place-items: center; font-size: 62px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8d6, #f7d36a 60%, #d9a521); border: 5px solid #c08f12;
  box-shadow: 0 0 0 6px #fff3c4, 0 0 30px 10px rgba(247, 211, 106, .7);
}
.cel-title { font-size: 30px; font-weight: 900; color: var(--blue-dark); margin-top: 4px; }
.cel-text { color: var(--muted); font-weight: 600; margin: 8px 0 16px; line-height: 1.4; }
@keyframes celIn { from { scale: .4; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -12deg; } 75% { rotate: 12deg; } }
@keyframes pop { 0% { scale: .9; } 70% { scale: 1.05; } 100% { scale: 1; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; opacity: 0;
  animation-name: fall; animation-timing-function: cubic-bezier(.3, .6, .6, 1); animation-fill-mode: forwards;
}
.confetti i.round { width: 12px; height: 12px; border-radius: 50%; }
@keyframes fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: .9; transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}

/* ---------- smaller and portrait screens ---------- */
@media (max-width: 980px) {
  .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  .board { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 1fr) auto; }
  .side { overflow: visible; }
  .choices.as-clock { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 700px) {
  .apps-link span { display: none; }
  .brand { font-size: 18px; }
  .home-top { grid-template-columns: 1fr; }
  .tracks { grid-template-columns: minmax(0, 1fr); }
  .choices.as-clock { grid-template-columns: 1fr 1fr; }
  .dig { font-size: 32px; }
}
@media (max-width: 420px) {
  .brand { display: none; }
}
@media (max-height: 700px) and (min-aspect-ratio: 1/1) {
  .prompt { font-size: 19px; }
  .choice { min-height: 64px; padding: 8px; }
  .target-digital { font-size: 46px; }
}
