@import url("../theme.css");
@import url("../chrome.css");

:root {
  --topbar: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- Top bar (header chrome is shared in ../chrome.css) ---------- */
.score {
  font-weight: bold;
  color: var(--ink-soft);
  font-size: clamp(13px, 3vw, 18px);
  white-space: nowrap;
}
.btn:focus-visible,
.choice-tile:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Play area ---------- */
.stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}
.quiz {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 5vw, 44px);
  width: 100%;
  max-width: 760px;
}

/* ---------- Prompt strip (icon-only question) ---------- */
.prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 16px);
  min-height: clamp(60px, 16vw, 110px);
}
.prompt .pcell {
  width: clamp(50px, 13vw, 96px);
  height: clamp(50px, 13vw, 96px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.prompt .face-emoji { font-size: clamp(40px, 11vw, 84px); }
.prompt .op {
  font-size: clamp(30px, 8vw, 60px);
  font-weight: bold;
  color: var(--ink-soft);
  line-height: 1;
}
/* Counting prompt can be several icons — keep them tight. */
.prompt-counting { gap: clamp(2px, 1.2vw, 10px); }

/* ---------- Choice tiles ---------- */
/* Grid columns are set per question by render.js (4 choices -> 2x2, else one
   row) so a 4-choice question never wraps as 3 + 1 on a narrow phone. */
.choices {
  display: grid;
  justify-content: center;
  align-items: center;
  gap: clamp(10px, 3vw, 24px);
}
.choice-tile {
  position: relative;
  width: clamp(96px, 25vw, 168px);
  height: clamp(96px, 25vw, 168px);
  border: 4px solid transparent;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 6px 0 var(--shadow);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s, opacity .25s;
}
.choice-tile:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--shadow); }
.tile-face {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Faces ---------- */
.choices .face-emoji { font-size: clamp(46px, 12vw, 96px); }
.face-emoji { line-height: 1; display: inline-block; }
.face-color {
  width: 66%;
  height: 66%;
  border-radius: 50%;
  box-shadow: inset 0 -4px 8px #0002;
  border: 2px solid #00000016;
}
.face-shape { width: 76%; height: 76%; }
.face-dots { width: 78%; height: 78%; color: var(--primary); }

/* ---------- Answer feedback ---------- */
.choice-tile.faded { opacity: .35; }
.choice-tile.correct {
  border-color: #57c46b;
  background: #eafbef;
  box-shadow: 0 0 0 3px #57c46b inset, 0 6px 0 var(--shadow);
  animation: pop-correct .4s ease;
}
@keyframes pop-correct {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.choice-tile.wrong { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- Overlay screens (start / win) ---------- */
.screen {
  position: fixed;
  inset: 0;
  background: #0008;
  display: none;
  padding: 16px;
  z-index: 10;
  overflow: auto;
}
.screen.show { display: flex; }
.screen-card {
  position: relative;
  margin: auto;
  background: #fff;
  border-radius: 28px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 10px 0 #0004;
  max-width: 520px;
  width: 100%;
  animation: pop .3s ease;
}
.screen-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 50%;
}
.screen-close:active { background: rgba(0,0,0,.08); }
.screen-title { color: var(--primary); margin: 0 0 6px; font-size: clamp(28px, 7vw, 46px); }
.screen-card h2 { color: var(--primary); margin: 8px 0; font-size: clamp(24px, 6vw, 40px); }
.screen-hint { font-size: clamp(30px, 9vw, 52px); margin: 6px 0; letter-spacing: 4px; }
.screen-label { color: var(--ink-soft); margin: 10px 0 4px; font-weight: bold; }
.big-emoji { font-size: clamp(60px, 16vw, 120px); }
.play { margin-top: 18px; }
.actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
@keyframes pop {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
