:root {
  --ink: #1d2a33;
  --panel: rgba(12, 36, 54, 0.72);
  --brand: #1f5f7a;
  --orange: #ff7a2f;
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: #fff; }
body { background: radial-gradient(ellipse at 50% 40%, #16314a, #0a1724 75%); }
button, input { font: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
kbd {
  font: 700 0.85em/1 ui-monospace, monospace;
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
  background: #e9f1f5;
  border: 1px solid #bfd0da;
  color: var(--ink);
}

/* ---------- Globe ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; }
#globe { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#globe:active { cursor: grabbing; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* ---------- Top: toolbar and progress ---------- */
#hud-top {
  position: fixed; left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 2vh 2vw;
  z-index: 10;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
#toolbar { display: flex; gap: 0.6vh; }
#toolbar button {
  width: clamp(40px, min(6vh, 7.5vw), 64px); height: clamp(40px, min(6vh, 7.5vw), 64px);
  border-radius: 1.4vh;
  border: none;
  background: var(--panel);
  font-size: clamp(20px, min(3vh, 3.75vw), 32px);
  cursor: pointer;
  color: #fff;
  display: grid; place-items: center;
}
#toolbar button:hover { background: rgba(12, 36, 54, 0.92); }
#progress {
  display: flex; gap: 1.4vh; align-items: center;
  font-weight: 800; font-size: clamp(18px, min(3.4vh, 4.25vw), 40px); line-height: 1;
}
#progress div { background: var(--panel); border-radius: 2vh; padding: 1vh 1.8vh 0.7vh; }
#progress div:empty { display: none; }
#score { color: #8ef0a0; }

/* ---------- Bottom: the answer box ---------- */
#answer {
  position: fixed; left: 50%; bottom: 2vh;
  transform: translateX(-50%);
  width: min(880px, 96vw);
  background: var(--panel);
  border-radius: 2.6vh;
  padding: 1.2vh 1.6vh 1.6vh;
  z-index: 10;
  backdrop-filter: blur(4px);
}
#msg {
  margin: 0 0 1vh;
  min-height: 1.25em;
  text-align: center;
  font-weight: 800;
  font-size: clamp(20px, min(4.4vh, 5.5vw), 52px);
  line-height: 1.2;
  text-shadow: 0 0.25vh 0 rgba(0, 0, 0, 0.3);
}
#msg small { font-size: 0.7em; opacity: 0.85; }
#msg.right { color: #8ef0a0; }
#msg.wrong { color: #ffb4a8; }
#msg.reveal { color: #ffd166; }
#msg.note { color: #cfe6f5; font-size: clamp(18px, min(3.4vh, 4.25vw), 40px); }
#msg.pop { animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: scale(0.85); opacity: 0.3; } to { transform: scale(1); opacity: 1; } }

#guess-form { display: flex; gap: 1.2vh; }
#combo { position: relative; flex: 1; min-width: 0; }
#combo.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-1.2vh); } 40%, 80% { transform: translateX(1.2vh); } }
#guess {
  width: 100%;
  height: clamp(48px, min(8vh, 10vw), 92px);
  border: 0.4vh solid transparent;
  border-radius: 1.6vh;
  padding: 0 2vh;
  font-size: clamp(22px, min(4.4vh, 5.5vw), 52px); font-weight: 700;
  color: var(--ink);
  background: #fff;
  outline: none;
}
#guess:focus { border-color: var(--orange); }
#guess:disabled { background: rgba(255, 255, 255, 0.8); }
#suggestions {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 0.8vh);
  margin: 0; padding: 0.6vh;
  list-style: none;
  background: #fff;
  border-radius: 1.6vh;
  box-shadow: 0 1vh 4vh rgba(0, 0, 0, 0.45);
  max-height: 52vh; overflow-y: auto;
}
#suggestions li {
  padding: 0.6vh 1.6vh;
  border-radius: 1vh;
  color: var(--ink);
  font-size: clamp(19px, min(3.6vh, 4.5vw), 42px); font-weight: 700; line-height: 1.25;
  cursor: pointer;
}
#suggestions li small { font-size: 0.65em; font-weight: 600; color: #6b7f8c; margin-left: 0.4em; }
#suggestions li:hover { background: #eef5f9; }
#suggestions li[aria-selected='true'] { background: var(--orange); color: #fff; }
#suggestions li[aria-selected='true'] small { color: #ffe5d6; }

#answer button {
  border: none;
  border-radius: 1.6vh;
  font-weight: 800; line-height: 1;
  cursor: pointer;
}
#check {
  padding: 0 3vh;
  background: #5fd068; color: #0e3a1a;
  font-size: clamp(20px, min(4vh, 5vw), 46px);
  box-shadow: 0 0.5vh 0 #2f8f3a;
}
#actions { display: flex; gap: 1.2vh; justify-content: center; margin-top: 1.2vh; }
#hint, #give-up {
  height: clamp(38px, min(5.6vh, 7vw), 64px); padding: 0 3vh;
  background: rgba(255, 255, 255, 0.2); color: #fff;
  font-size: clamp(17px, min(2.8vh, 3.5vw), 32px);
}
#next {
  height: clamp(48px, min(8vh, 10vw), 92px); padding: 0 4vh;
  background: #ffd23f; color: #4a3300;
  font-size: clamp(22px, min(4.4vh, 5.5vw), 52px);
  box-shadow: 0 0.5vh 0 #c99a12;
}
#answer button:active { transform: translateY(0.4vh); box-shadow: none; }
#answer button:disabled { opacity: 0.45; cursor: default; transform: none; }
#guess-form:has(#guess:disabled) { display: none; }

/* ---------- Menu and end of round ---------- */
#setup, #end {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 20;
  background: radial-gradient(ellipse at center, rgba(6, 20, 32, 0.45), rgba(4, 12, 20, 0.85));
  overflow: auto;
  padding: 3vh 2vw;
}
.panel {
  width: min(900px, 94vw);
  background: rgba(250, 253, 255, 0.97);
  color: var(--ink);
  border-radius: 28px;
  padding: 26px 34px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.logo { margin: 0; font-size: 50px; line-height: 1; font-weight: 800; color: var(--brand); letter-spacing: -0.5px; }
.tagline { margin: 8px 0 18px; font-size: 19px; line-height: 1.35; color: #45596a; }
.panel h2 { margin: 0 0 8px; font-size: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cards.narrow { grid-template-columns: repeat(auto-fill, minmax(110px, 140px)); }
.cards button {
  border: 3px solid #d5e3ec;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.cards button:hover { transform: translateY(-2px); }
.cards button[aria-pressed='true'] { border-color: var(--brand); background: #e8f3f8; }
.cards b { display: block; font-size: 22px; line-height: 1.1; }
.cards span { display: block; font-size: 15px; color: #5d7282; line-height: 1.3; }
.buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.buttons button {
  border: 2px solid var(--brand);
  background: #fff;
  color: var(--brand);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 19px; font-weight: 800;
  cursor: pointer;
}
.buttons button.primary { background: var(--brand); color: #fff; font-size: 22px; padding: 12px 34px; box-shadow: 0 6px 0 #123b4d; }
.buttons button.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #123b4d; }
#offline-status { margin: 10px 0 0; font-size: 15px; font-weight: 700; color: #2e7d4a; }
.help { margin-top: 16px; font-size: 15px; color: #45596a; }
.help summary { cursor: pointer; font-weight: 700; }
.help ul { padding-left: 20px; line-height: 1.5; }

#end-score { margin: 0; font-size: 64px; line-height: 1; color: var(--brand); }
#end-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0; padding: 0; list-style: none;
}
#end-list li {
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 19px; font-weight: 700;
}
#end-list .first { background: #d8f5dd; color: #1d6b2c; }
#end-list .later { background: #fff0c2; color: #6b4d00; }
#end-list .missed { background: #fde0dc; color: #9b2a1f; }

@media (max-width: 600px) {
  #toolbar button { width: 38px; height: 38px; font-size: 19px; border-radius: 10px; }
  #progress { font-size: 17px; gap: 6px; }
  #progress div { padding: 6px 10px 4px; border-radius: 12px; }
  #check { padding: 0 16px; }
}
#progress div { white-space: nowrap; }

@media (max-height: 560px) {
  .panel { padding: 16px 22px; }
  .logo { font-size: 36px; }
}
