/* Mobile-first, portrait, one-handed. No web fonts, no external resources of any kind
   (docs/13-MOBILE.md, 02-RESEARCH.md Pitfall 7). Base font-size is 16px so mobile Safari
   does not zoom on select focus. */

:root {
  color-scheme: dark light;
  --bg: #12141a;
  --fg: #eef0f4;
  --muted: #9aa3b2;
  --accent: #6fb1ff;
  --surface: #1c1f28;
  --border: #2c3140;
  --danger: #ff8080;
  font-size: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fa;
    --fg: #171a20;
    --muted: #5b6270;
    --accent: #1a5fb4;
    --surface: #ffffff;
    --border: #dadfe8;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

section {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1rem;
  gap: 0.75rem;
}

section[hidden] {
  display: none;
}

/* Shared tap-target rule -- applied to every button, select, and reorder control so the
   44px minimum (docs/13-MOBILE.md line 149) cannot be forgotten on a new control. Padding
   alone is not relied on here; min-height/min-width are explicit. */
.tap-target {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
}

.tap-target:disabled {
  opacity: 0.5;
}

.primary-button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-weight: 600;
}

/* --- screen-intro ------------------------------------------------------------------ */

#screen-intro {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

#screen-intro p {
  max-width: 32ch;
  margin: 0;
}

#btn-start {
  width: 100%;
  max-width: 20rem;
  min-height: 56px;
  font-size: 1.1rem;
}

/* --- screen-play -------------------------------------------------------------------- */

#screen-play {
  padding: 0;
}

.status-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.status-item {
  white-space: nowrap;
}

.log {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0.5rem 1rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  min-height: 3rem;
}

/* The action menu sits in the lower two-thirds of the viewport so it stays thumb-reachable
   in a one-handed hold. */
.action-menu {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1rem;
  overflow-y: auto;
}

.action-menu button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
}

.divination-row {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem;
}

.divination-row button {
  flex: 1;
}

.fine-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
}

.fine-picker[hidden] {
  display: none;
}

.divination-result {
  padding: 0 1rem;
  font-size: 0.9rem;
  min-height: 1.2rem;
}

.guess-button {
  margin: 0 1rem 1rem;
  width: calc(100% - 2rem);
  min-height: 52px;
}

.hint {
  margin: 0 1rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- screen-guess -------------------------------------------------------------------- */

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}

.rank-row .rank-name {
  flex: 1;
}

.rank-row button {
  min-height: 44px;
  min-width: 44px;
}

.guess-selects {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.guess-selects select {
  width: 100%;
}

/* --- screen-reveal ------------------------------------------------------------------- */

.reveal-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.reveal-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.reveal-group-title {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reveal-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.reveal-row-name {
  width: 6rem;
  flex-shrink: 0;
}

.reveal-bar-track {
  flex: 1;
  height: 0.9rem;
  background: var(--border);
  border-radius: 0.3rem;
  overflow: hidden;
  position: relative;
}

/* The inner fill's width is set inline by main.js, from the wasm-computed `bar_pct`
   percentage. No bar width is computed here in CSS or in JS -- Rust owns that number. */
.reveal-bar-fill {
  height: 100%;
  background: var(--accent);
}

.reveal-row-marker {
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.receipts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.receipt {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  font-size: 0.9rem;
}

.score-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- screen-error -------------------------------------------------------------------- */

#screen-error {
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* --- Reduced motion / accessibility --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
