:root {
  --ink: #2a2118;
  --panel: rgba(40, 30, 22, 0.72);
  --brown: #5b4a3a;
  --red: #e0453a;
  --blue: #3a7be0;
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #a9d8f0; color: #fff; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }
kbd, code {
  font: 700 0.85em/1 ui-monospace, monospace;
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
  background: #f1e8dc;
  border: 1px solid #d3c2ab;
  color: var(--ink);
}
.t0 { color: #ffb3a8; }
.t1 { color: #a9cbff; }

/* ---------- Scene ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; }
#scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* ---------- Top: toolbar and the two walls' blocks ---------- */
#hud-top {
  position: fixed; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; gap: 2vw;
  padding: 2vh 2vw;
  z-index: 10;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
#toolbar, #toolbar-space { display: flex; gap: 0.5vw; flex: 0 0 auto; width: 19vh; }
#toolbar button {
  width: 5.4vh; height: 5.4vh;
  border-radius: 1.4vh;
  border: none;
  background: var(--panel);
  font-size: 2.8vh;
  cursor: pointer;
  color: #fff;
  display: grid; place-items: center;
}
#toolbar button:hover { background: rgba(40, 30, 22, 0.9); }

#scores { flex: 1; display: flex; justify-content: space-between; gap: 4vw; }
.score {
  width: min(34vw, 46vh);
  background: var(--panel);
  border-radius: 2vh;
  padding: 0.8vh 1.6vh 1.2vh;
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 1vh;
  border: 0.4vh solid transparent;
  transition: border-color 0.3s, transform 0.3s;
}
.score .name { font-size: 3.6vh; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .left { font-size: 2.6vh; font-weight: 700; opacity: 0.9; }
.score .bar { grid-column: 1 / -1; height: 1.6vh; border-radius: 1vh; background: rgba(255, 255, 255, 0.18); overflow: hidden; margin-top: 0.4vh; }
.score .bar i { display: block; height: 100%; border-radius: 1vh; transition: width 0.8s; }
.team0 .bar i { background: var(--red); }
.team1 .bar i { background: var(--blue); }
.score.team1 { text-align: right; }
.score.team1 { grid-template-columns: auto 1fr; }
.score.team1 .left { order: 1; }
.score.team1 .name { order: 2; }
.score.team1 .bar { order: 3; }
.score.active { transform: scale(1.04); }
.score.team0.active { border-color: var(--red); }
.score.team1.active { border-color: var(--blue); }

/* ---------- The question, over the sky between the castles ---------- */
#card {
  position: fixed; left: 50%; top: 16.5vh;
  translate: -50% 0;
  width: min(62vw, 120vh);
  z-index: 9;
  text-align: center;
  background: rgba(255, 252, 246, 0.95);
  color: var(--ink);
  border-radius: 3vh;
  padding: 1.4vh 3vh 1.8vh;
  box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.25);
  border-top: 1.2vh solid var(--brown);
}
#card.turn0 { border-top-color: var(--red); }
#card.turn1 { border-top-color: var(--blue); }
#card.pop { animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: scale(0.9); opacity: 0.3; } to { transform: scale(1); opacity: 1; } }
#card p { margin: 0; }
#prompt { font-size: clamp(18px, 3.4vh, 48px); font-weight: 700; line-height: 1.25; color: #6e5d4a; }
#prompt .t0 { color: #c23328; font-weight: 800; }
#prompt .t1 { color: #2a62c0; font-weight: 800; }
#question { font-size: clamp(26px, 7vh, 110px); font-weight: 800; line-height: 1.12; margin-top: 0.6vh !important; overflow-wrap: anywhere; }
#question.long { font-size: clamp(22px, 4.8vh, 72px); }
#answer {
  display: inline-block;
  margin-top: 1vh !important;
  font-size: clamp(20px, 4.6vh, 64px); font-weight: 800; line-height: 1.15;
  background: #e5f6e3; color: #1f6b2a;
  border-radius: 1.6vh; padding: 0.2vh 2.4vh;
}

/* ---------- Bottom: pick a shot, then mark the answer ---------- */
#controls {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 0 2vw 2.4vh;
  z-index: 10;
  pointer-events: none;
}
.row {
  pointer-events: auto;
  display: flex; gap: 1.6vh; align-items: stretch; flex-wrap: wrap; justify-content: center;
  background: var(--panel);
  border-radius: 2.6vh;
  padding: 1.4vh;
}
.row button {
  border: none;
  border-radius: 1.8vh;
  font-weight: 800; line-height: 1;
  cursor: pointer;
  min-height: 8vh;
  padding: 0 3.4vh;
  font-size: 3.8vh;
  box-shadow: 0 0.6vh 0 rgba(0, 0, 0, 0.3);
}
.row button:active { transform: translateY(0.5vh); box-shadow: none; }
.row button:disabled { opacity: 0.45; cursor: default; transform: none; }
.pick {
  --team: var(--red);
  background: #fff; color: var(--ink);
  border: 0.6vh solid var(--team) !important;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.6vh;
  padding: 1.2vh 3.4vh !important;
  min-width: 34vh;
  text-align: left;
}
.pick b { font-size: 4.4vh; display: flex; align-items: center; gap: 1.2vh; }
.pick b::before {
  content: '';
  width: 3vh; height: 2.6vh;
  border-radius: 45% 55% 50% 40%;
  background: radial-gradient(circle at 35% 30%, #c9c5bd, #7f7b74);
}
.pick.big b::before { width: 5.4vh; height: 4.6vh; }
.pick span { font-size: 2.4vh; font-weight: 700; color: #6e5d4a; }
#reveal { background: rgba(255, 255, 255, 0.2); color: #fff; }
#right { background: #5fd068; color: #0e3a1a; min-width: 24vh; box-shadow: 0 0.6vh 0 #2f8f3a; }
#wrong { background: #ff8a7a; color: #5a1009; min-width: 24vh; box-shadow: 0 0.6vh 0 #c4493a; }
#skip { background: transparent; color: #fff; font-size: 2.4vh; box-shadow: none; text-decoration: underline; padding: 0 1.4vh; }
.go { background: #ffd23f; color: #4a3300; box-shadow: 0 0.6vh 0 #c99a12 !important; min-width: 30vh; }

/* ---------- Setup menu ---------- */
#setup {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 20;
  background: radial-gradient(ellipse at center, rgba(30, 24, 18, 0.5), rgba(14, 10, 6, 0.85));
  overflow: auto;
  padding: 3vh 2vw;
}
.panel {
  width: min(960px, 94vw);
  background: rgba(255, 252, 246, 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(--brown); letter-spacing: -0.5px; }
.tagline { margin: 8px 0 18px; font-size: 19px; line-height: 1.35; color: #5a4a38; }
.panel h2 { margin: 0 0 8px; font-size: 20px; }
.panel h3 { margin: 0 0 6px; font-size: 17px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.cards button {
  border: 3px solid #e6d8c4;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.cards button:hover { transform: translateY(-2px); }
.cards button[aria-pressed='true'] { border-color: var(--brown); background: #f6efe6; }
.cards b { display: block; font-size: 21px; line-height: 1.1; }
.cards span { display: block; font-size: 15px; color: #6e5d4a; line-height: 1.3; }
.src { margin: -4px 0 16px; padding: 12px 14px; background: #f6efe6; border-radius: 16px; }
.src .cards { margin-bottom: 0; }
.help-line { margin: 0 0 8px; font-size: 15px; color: #5a4a38; line-height: 1.4; }
.help-line:empty { display: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 16px; }
textarea, .panel input, select {
  border: 2px solid #d9c9b2; border-radius: 10px;
  padding: 6px 10px; font-size: 16px; color: var(--ink); background: #fff;
}
textarea { resize: vertical; font-size: 15px; line-height: 1.4; }
.teams { margin-bottom: 16px; }
.teams .team0 input { border-color: var(--red); }
.teams .team1 input { border-color: var(--blue); }
.make { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.make label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
.make .grow { flex: 1; min-width: 240px; }
.primary-small, .add, .set button {
  border: 2px solid var(--brown); background: var(--brown); color: #fff;
  border-radius: 999px; padding: 6px 18px; font-weight: 800; cursor: pointer;
}
.primary-small:disabled { opacity: 0.5; cursor: wait; }
#sets { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.set { display: flex; gap: 8px; align-items: stretch; }
.set .use {
  flex: 1; text-align: left; background: #fff; color: var(--ink);
  border: 3px solid #e6d8c4; border-radius: 12px; padding: 4px 12px;
}
.set[aria-current='true'] .use { border-color: var(--brown); }
.set .use b { font-size: 18px; margin-right: 10px; }
.set .use span { font-size: 14px; color: #6e5d4a; }
.set .del { background: #fff; color: #9b2c22; border-color: #e6c3bd; border-radius: 12px; }
.qlist { margin: 0 0 6px; padding-left: 26px; display: flex; flex-direction: column; gap: 5px; max-height: 340px; overflow: auto; }
.qlist li { display: flex; gap: 5px; align-items: flex-start; }
.qlist textarea, .qlist input { flex: 1; min-width: 0; font-size: 14px !important; line-height: 1.3; padding: 4px 8px !important; }
/* The whole question shows, however long */
.qlist textarea { resize: none; field-sizing: content; min-height: 2em; }
.qlist input.a { flex: 0 0 30%; }
.qlist button { border: none; background: none; color: #9b2c22; font-size: 16px; cursor: pointer; padding: 2px 4px; }
.add { background: #fff; color: var(--brown); font-size: 14px; padding: 3px 12px; }
.buttons { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.buttons button {
  border: 2px solid var(--brown);
  background: #fff;
  color: var(--brown);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 19px; font-weight: 800;
  cursor: pointer;
}
.buttons button.primary { background: var(--brown); color: #fff; font-size: 22px; padding: 12px 34px; box-shadow: 0 6px 0 #3a2e24; }
.buttons button.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #3a2e24; }
.buttons button:disabled { opacity: 0.45; cursor: default; }
#play-note { font-weight: 700; color: #9b2c22; }
#offline-status { margin: 10px 0 0; font-size: 15px; font-weight: 700; color: #2e7d4a; }
.help { margin-top: 16px; font-size: 15px; color: #5a4a38; }
.help summary { cursor: pointer; font-weight: 700; }
.help ul { padding-left: 20px; line-height: 1.5; }

@media (max-width: 700px) {
  .cards.three, .two { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .logo { font-size: 38px; }
}

/* Phones held upright: size things by the width instead of the height */
@media (max-aspect-ratio: 1/1) {
  #hud-top { flex-wrap: wrap; gap: 2vw; padding: 3vw; }
  #toolbar { width: 100%; gap: 2vw; }
  #toolbar-space { display: none; }
  #toolbar button { width: 10vw; height: 10vw; font-size: 5vw; border-radius: 2.6vw; }
  #scores { gap: 3vw; }
  .score { width: auto; flex: 1; padding: 1.4vw 3vw 2vw; border-radius: 3vw; border-width: 0.8vw; }
  .score .name { font-size: 5vw; }
  .score .left { font-size: 3.6vw; }
  .score .bar { height: 2.4vw; }
  #card { width: 94vw; top: 34vw; padding: 2vw 4vw 3vw; border-radius: 4vw; border-top-width: 2vw; }
  #prompt { font-size: 4.4vw; }
  #question { font-size: 9vw; }
  #question.long { font-size: 6vw; }
  #answer { font-size: 6.5vw; }
  #controls { padding: 0 3vw 4vw; }
  .row { gap: 2.4vw; padding: 2.4vw; border-radius: 4vw; }
  .row button { min-height: 13vw; font-size: 5.4vw; padding: 0 4vw; border-radius: 3vw; }
  #right, #wrong { min-width: 34vw; }
  #skip { font-size: 4vw; }
  .pick { min-width: 0; flex: 1; padding: 2.4vw 3vw !important; border-width: 1vw !important; }
  .pick b { font-size: 5.6vw; }
  .pick span { font-size: 3.4vw; }
  .go { min-width: 50vw; }
}
