#app { position: relative; max-width: 1000px; margin: 0 auto; padding: 16px 20px; }

/* ---------- Set up ---------- */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
#card-tables { --main: #7b61ff; --on-main: #fff; }
#setup > .btn { display: block; margin: 26px auto 0; }

.tables { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.tables label, .heights label { cursor: pointer; }
.tables input, .heights input { position: absolute; opacity: 0; pointer-events: none; }
.tables span, .heights span {
  display: grid; place-items: center;
  height: 50px;
  font-size: 22px; font-weight: 900;
  border: 3px solid #d9d5ee;
  border-radius: 14px;
  background: #f6f4ff;
  color: #9a95bb;
  transition: transform .12s;
}
@media (hover: hover) { .tables label:hover span, .heights label:hover span { transform: scale(1.06); } }
.tables input:checked + span, .heights input:checked + span {
  color: var(--ink); border-color: var(--ink); background: var(--sun);
  box-shadow: 0 4px 0 var(--ink);
}
.tables input:focus-visible + span, .heights input:focus-visible + span { outline: 4px solid var(--ink); outline-offset: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tables-msg { margin: 8px 0 0; min-height: 20px; font-size: 14px; font-weight: 800; color: #c92a2a; }

.heights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.heights span { height: auto; padding: 8px 4px; font-size: 17px; gap: 2px; }
.heights small { display: block; font-size: 12px; font-weight: 800; opacity: .7; }

.best-box { margin-top: 16px; padding: 10px 14px; background: #fff7d6; border: 3px dashed #e0b400; border-radius: 16px; font-weight: 800; font-size: 15px; }
.best-box h3 { margin: 0 0 4px; font-size: 15px; }
.best-box ol { margin: 0; padding-left: 22px; }
.best-box li { padding: 1px 0; }
.best-box li.you { color: #c2337a; }
.best-box .none { color: #6b6690; }

/* ---------- Play: one window tall, the 3D board takes the spare room ---------- */
#screen-play { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 32px); min-height: 460px; }
.hud { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stat {
  padding: 6px 14px;
  font-size: 18px; font-weight: 900;
  background: rgba(255, 255, 255, .88);
  border: 3px solid var(--ink); border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat.timer { margin-left: auto; font-size: 24px; min-width: 132px; text-align: center; background: var(--sun); }

.field { position: relative; flex: 1 1 0; min-height: 200px; margin: 0 -20px; }
#stage {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; touch-action: manipulation;
  -webkit-mask-image: linear-gradient(transparent, #000 10%, #000 96%, transparent);
  mask-image: linear-gradient(transparent, #000 10%, #000 96%, transparent);
}
/* Shown only when the browser cannot draw the 3D board. */
.chips { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.chips .btn { font-size: 30px; min-width: 96px; padding: 18px; }

.ask-card {
  flex: 0 0 auto;
  background: linear-gradient(#fff, #f3f0ff);
  border: 4px solid var(--ink);
  border-top: 12px solid var(--main);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--ink), 0 20px 26px rgba(43, 35, 80, .22);
  padding: 12px 20px 12px;
  margin-bottom: 10px;
}
.ask { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.ask-hero { width: 52px; height: 56px; }
.question { font-size: clamp(34px, 6vw, 54px); font-weight: 900; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.answer { width: 150px; font-size: 40px; text-align: center; padding: 6px 10px; font-variant-numeric: tabular-nums; }
.ask .btn { font-size: 24px; padding: 12px 26px; }
.ask-card.busy .answer { background: #f1eefc; }
.feedback { margin: 8px 0 0; min-height: 24px; text-align: center; font-size: 17px; font-weight: 800; color: #6b6690; }
.feedback.good { color: #2b9a3f; }
.feedback.bad { color: #c92a2a; }
.ask-card.shake { animation: wobble .4s; }

/* ---------- Finished ---------- */
.done-card { --main: #7b61ff; max-width: 600px; margin: 30px auto 0; padding: 26px 30px 32px; text-align: center; }
.done-hero { width: 150px; height: 163px; margin: 0 auto; animation: bob 1s ease-in-out infinite; }
.done-card h1 { margin: 6px 0 4px; font-size: 38px; font-weight: 900; }
.done-time { margin: 0; font-size: 64px; font-weight: 900; line-height: 1.1; color: #c2337a; font-variant-numeric: tabular-nums; }
.done-sub { margin: 4px 0 0; font-size: 18px; font-weight: 800; }
.done-card .best-box { text-align: left; margin-bottom: 22px; }
.row { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
#confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 900px) { .logo { margin-top: 50px; } }
@media (max-width: 640px) {
  .setup-grid { grid-template-columns: 1fr; }
  .hud { gap: 8px; }
  .stat { font-size: 15px; padding: 4px 10px; }
  .stat.timer { font-size: 19px; min-width: 96px; }
  .ask-card { padding: 10px 14px; }
  .ask { gap: 10px; }
  .ask-hero { width: 42px; height: 46px; }
  .ask .btn { font-size: 20px; padding: 10px 18px; }
  .answer { width: 110px; font-size: 32px; }
  .feedback { font-size: 15px; }
  .done-card { margin-top: 12px; padding: 20px 18px 26px; }
  .done-hero { width: 110px; height: 120px; }
  .done-card h1 { font-size: 30px; }
  .done-time { font-size: 52px; }
}

/* A phone held sideways: the HUD runs along the top, the board fills the left
   and the question sits beside it, so nothing has to squeeze into a short window. */
@media (orientation: landscape) and (max-height: 500px) {
  #app { padding: 8px 16px; }
  #screen-play {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 42%);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px 14px;
    height: calc(100dvh - 16px); min-height: 0;
  }
  .hud { grid-column: 1 / -1; gap: 8px; }
  .stat { font-size: 15px; padding: 3px 10px; }
  .stat.timer { font-size: 18px; min-width: 96px; }
  .btn.small { padding: 4px 12px; }
  .field { grid-column: 1; grid-row: 2; min-height: 0; margin: 0 0 0 -16px; }
  .ask-card { grid-column: 2; grid-row: 2; align-self: center; margin-bottom: 8px; padding: 10px 14px; }
  .ask { gap: 10px; }
  .ask-hero { width: 40px; height: 44px; }
  .question { font-size: 36px; }
  .answer { width: 100px; font-size: 30px; }
  .ask .btn { font-size: 20px; padding: 8px 16px; }
  .feedback { font-size: 14px; }
  .done-card { margin-top: 0; padding: 14px 20px 22px; }
  .done-hero { width: 90px; height: 98px; }
  .done-card h1 { font-size: 28px; }
  .done-time { font-size: 44px; }
}
