:root {
  --bg: #fff7e6;
  --text: #2b2118;
  --muted: #7a6a5a;
  --card: #ffffff;
  --green: #1f9d55;
  --green-dark: #167a41;
  --red: #e0413a;
  --red-dark: #b5302a;
  --primary: #2f6fdf;
  --primary-dark: #2257b5;
  --track: #eadfcb;
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

h1, h2 { text-align: center; margin: 8px 0 24px; }
h1 { font-size: 2.4rem; }
h2 { font-size: 2.6rem; margin-top: 15dvh; }

/* Settings */
#settings { gap: 20px; }
.setting .label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--muted); }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice button {
  flex: 1 1 0;
  min-width: 64px;
  padding: 14px 8px;
  border-radius: 14px;
  background: var(--card);
  border: 2px solid var(--track);
  font-weight: 600;
}
.choice button.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

.big, .huge {
  border-radius: var(--radius);
  font-weight: 800;
  color: #fff;
}
.big { padding: 20px; font-size: 1.5rem; margin-top: auto; }
.primary { background: var(--primary); box-shadow: 0 6px 0 var(--primary-dark); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--primary-dark); }

/* Ready */
#ready { justify-content: center; align-items: center; gap: 32px; position: relative; }
.hint { text-align: center; font-size: 1.3rem; color: var(--muted); max-width: 20em; }
.huge { width: min(70vw, 300px); aspect-ratio: 1; border-radius: 50%; font-size: 2.6rem; }
.corner {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  font-size: 1.8rem;
  background: none;
  color: var(--muted);
  padding: 8px;
}

/* Play */
.scores { display: flex; align-items: center; gap: 12px; }
.count {
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 14px;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
}
.count.guessed { background: var(--green); }
.count.skipped { background: var(--red); }
.timer { flex: 1; display: flex; align-items: center; gap: 8px; }
.bar { flex: 1; height: 16px; border-radius: 8px; background: var(--track); overflow: hidden; }
/* Shrinks towards the right edge: with a quarter of the time left, the right quarter is coloured. */
.fill { height: 100%; width: 100%; background: var(--primary); border-radius: 8px; transform-origin: right; }
.fill.low { background: var(--red); }
#seconds { width: 2.2em; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.card {
  flex: 1;
  min-height: 0;
  margin: 16px 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(60, 40, 10, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 12px;
}
.card img { flex: 1; min-height: 0; max-width: 100%; object-fit: contain; border-radius: 12px; }
.card .word { font-size: 2rem; font-weight: 800; text-align: center; }
.card.no-images img { display: none; }
.card.no-images .word { font-size: 3rem; }

.actions { display: flex; gap: 12px; }
.actions button {
  padding: 28px 8px;
  border-radius: var(--radius);
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
}
.skip { flex: 1; background: var(--red); box-shadow: 0 6px 0 var(--red-dark); }
.guess { flex: 2; background: var(--green); box-shadow: 0 6px 0 var(--green-dark); }
.skip:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark); }
.guess:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--green-dark); }

/* Pause overlay: covers the card and buttons so a stray tap does nothing */
#play { position: relative; }
.paused {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  gap: 20px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(255, 247, 230, 0.97);
}
.paused.active { display: flex; }
.paused .big { margin-top: 0; }
.paused h2 { margin-bottom: auto; }
.stop { background: var(--red); box-shadow: 0 6px 0 var(--red-dark); }
.stop:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-dark); }

/* End */
.final { display: flex; gap: 16px; justify-content: center; margin-top: 24px; }
.final-score {
  flex: 1;
  max-width: 160px;
  padding: 20px 8px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
}
.final-score span { display: block; font-size: 3.6rem; font-weight: 800; }
.final-score.guessed { background: var(--green); }
.final-score.skipped { background: var(--red); }
.hidden { visibility: hidden; }
