/* Werewolf Moderator: one phone, held by the moderator, passed around once
 * for the deal. Brand system per docs/design-guidelines.md (Canva kit
 * palette, League Spartan / Trocchi / Arimo). Standalone game, so nothing is
 * imported from another game's stylesheet. Shell (header, settings sheet,
 * article, footer) matches apps/words-or-less/style.css.
 *
 * The "night" look is the dark brand text color (#2f2c28) with yellow
 * accents; filled green stays reserved for the next action. */

:root {
  --gof-green-dark: #157623;
  --gof-green: #9bca3e;
  --gof-green-hover: #88b733;
  --gof-bg: #dde5ed;
  --gof-mint: #defff0;
  --gof-yellow: #ffb920;
  --gof-rust: #de6739;
  --text-primary: #2f2c28;
  --text-secondary: #5e5c5e;
  --night: #2f2c28;
  --night-soft: #48443e;
  --night-text: #f4efe6;
  --night-muted: #c9c4bc;
  --panel-bg: #ffffff;
  --panel-border: #e3e8ee;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Arimo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--gof-bg) 0%, var(--gof-mint) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

[hidden] { display: none !important; }

/* ===== Header bar (per HEADER_SPECS) ================================== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  padding: 4px 0;
  gap: 12px;
  position: relative;
  z-index: 1100;
}
.header-left { flex: 1; min-width: 0; }
.header-right { flex-shrink: 0; min-width: 52px; }
.game-title-wrap { position: relative; display: inline-block; }
.game-title-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
.game-title-heading {
  margin: 0;
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}
.game-title-chevron { font-size: 0.7rem; color: var(--text-secondary); }
.game-title-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 180px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
}
.game-title-dropdown[aria-hidden="false"] { display: block; }
.game-nav-link {
  display: block;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--panel-border);
}
.game-nav-link:last-child { border-bottom: none; }
.game-nav-link:hover { background: var(--gof-mint); }

.mode-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.mode-static {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  min-height: 28px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--gof-mint);
  color: var(--gof-green-dark);
  border: 2px solid var(--gof-green-dark);
  border-radius: 999px;
}

/* Beta badge: yellow brand accent (green stays for the next action). */
.ww-beta {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border: 1.5px solid var(--gof-yellow);
  border-radius: 999px;
  background: #fff3d1;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.ww-beta:hover { background: var(--gof-yellow); }

/* ===== The board ======================================================= */
/* One fixed scaffold on every screen (Step 4.5 #2): the card keeps a
   minimum height so the controls and pills below never jump. Sized for a
   night screen at up to 10 players; bigger tables grow the grid. */
.ww-card {
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 640px;
}

/* Small line at the top of a screen: "Night 2 · Werewolves". */
.ww-step {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Dark hero: the opening card, the hand-off cover, dawn. */
.ww-hero {
  padding: 22px 16px 20px;
  border-radius: var(--radius);
  background: var(--night);
  color: var(--night-text);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ww-hero-icon { font-size: 2.6rem; line-height: 1; }
.ww-hero-head {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 8vw, 2.3rem);
  line-height: 1.05;
  padding-top: 0.08em;
  overflow-wrap: anywhere;
}
.ww-hero-head .accent { color: var(--gof-yellow); }
.ww-hero-sub { font-size: 0.95rem; color: var(--night-muted); line-height: 1.4; max-width: 34em; }

/* Player count on the opening card. */
.ww-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px;
}
.ww-count-label { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.ww-count-label small { display: block; font-weight: 400; font-size: 0.8rem; color: var(--text-secondary); }

/* The role mix: one chip per role with a count. */
.ww-mix { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ww-mix-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--gof-bg);
  font-size: 0.88rem;
  font-weight: 700;
}
.ww-mix-chip.is-wolf { background: #fff3d1; border: 1.5px solid var(--gof-yellow); }
.ww-note { text-align: center; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.4; }
.ww-note strong { color: var(--text-primary); }

/* Name entry on the hand-off cover. */
.ww-name-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 18px;
  text-align: center;
  color: var(--text-primary);
  background: var(--panel-bg);
}
.ww-name-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(255, 185, 32, 0.5); }
.ww-field-label { text-align: center; font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }

/* The secret role card. */
.ww-role {
  border-radius: var(--radius);
  background: var(--night);
  color: var(--night-text);
  padding: 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 3px solid var(--night);
}
.ww-role.is-wolf { border-color: var(--gof-rust); }
.ww-role-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--night-muted); }
.ww-role-icon { font-size: 3.4rem; line-height: 1; }
.ww-role-name {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: clamp(2rem, 10vw, 2.6rem);
  line-height: 1;
  padding-top: 0.08em;
  color: var(--gof-yellow);
}
.ww-role-team { font-size: 0.85rem; font-weight: 700; color: var(--night-muted); }
.ww-role-goal { font-weight: 700; font-size: 1rem; }
.ww-role-how { font-size: 0.92rem; color: var(--night-muted); line-height: 1.45; max-width: 30em; }
/* What only the app can remind you of: your team, your checks so far. */
.ww-role-extra {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--gof-yellow);
  max-width: 30em;
}
.ww-forgot { margin-top: -6px; }
.ww-explain-seg { justify-content: center; }

/* Read-aloud box: what the moderator says. */
.ww-read {
  position: relative;
  border-radius: var(--radius);
  background: var(--night);
  color: var(--night-text);
  padding: 12px 48px 12px 14px;
}
.ww-read-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gof-yellow);
  margin-bottom: 4px;
}
.ww-read p {
  font-family: 'Trocchi', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.35;
  margin: 0 0 5px;
}
.ww-read p:last-child { margin-bottom: 0; }
.ww-read.is-after { background: var(--night-soft); }
/* The explain-the-game script is long: clear gaps so the moderator can find
   their place mid-read. */
.ww-read.is-script { padding-top: 14px; padding-bottom: 16px; }
.ww-read.is-script p { margin-bottom: 18px; line-height: 1.45; }
.ww-read.is-script p:last-of-type { margin-bottom: 0; }
.ww-speak {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: var(--night-text);
  font-size: 1.05rem;
  cursor: pointer;
}
.ww-speak:hover { border-color: var(--gof-yellow); }
.ww-speak.is-on { background: var(--gof-yellow); border-color: var(--gof-yellow); }

/* Moderator-only guidance under the read box. */
.ww-hint {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-secondary);
  text-align: center;
}
.ww-hint strong { color: var(--text-primary); }
.ww-hint.is-dead { padding: 10px; border-radius: var(--radius-sm); background: var(--gof-bg); }

/* Player grid: who they point at. */
.ww-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ww-pick {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1.5px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--gof-bg);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.ww-pick:hover { border-color: var(--gof-green); }
.ww-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ww-pick-role { font-size: 1rem; opacity: 0.85; }
.ww-pick.is-selected {
  background: var(--panel-bg);
  border: 2.5px solid var(--text-primary);
  box-shadow: 0 2px 8px rgba(47, 44, 40, 0.18);
  padding: 5px 9px;
}
.ww-pick:disabled { cursor: default; opacity: 0.45; background: transparent; border-style: dashed; }

/* Seer's answer. */
.ww-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  padding-top: 12px;
}
.ww-answer.is-wolf { background: #fde4da; border: 2px solid var(--gof-rust); }
.ww-answer.is-safe { background: var(--gof-bg); border: 2px solid #b8c3cf; }
.ww-answer-signal { text-decoration: underline; text-underline-offset: 4px; }

/* Day timer. */
.ww-timer-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ww-timer {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  min-width: 4ch;
  text-align: center;
  padding: 4px 14px 2px;
  border-radius: 999px;
  background: var(--gof-bg);
}
.ww-timer.is-low { background: var(--gof-yellow); }
.ww-timer.is-up { background: var(--gof-rust); color: #fff; }

/* Result: who was what, and what happened each night. */
.ww-result-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ww-result-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--gof-bg);
  font-size: 0.95rem;
}
.ww-result-list li.is-winner { background: #fff3d1; }
.ww-result-list .r-name { flex: 1; font-weight: 700; }
.ww-result-list .r-fate { font-size: 0.82rem; color: var(--text-secondary); }
.ww-recap { font-size: 0.88rem; line-height: 1.5; color: var(--text-secondary); }
.ww-recap summary { cursor: pointer; font-weight: 700; color: var(--text-primary); }
.ww-recap ol { padding-left: 20px; margin-top: 6px; }

/* Pushes the action buttons to the bottom of the fixed-height card. */
.ww-spacer { flex: 1; }
.ww-actions { display: flex; flex-direction: column; gap: 8px; }

/* ===== Mid-play controls and status line =============================== */
.ww-controls {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: -4px;
}
.ww-status { flex: 1; text-align: center; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.3; }
.ww-status strong { color: var(--text-primary); }
.ww-link {
  border: none;
  background: transparent;
  color: var(--gof-green-dark);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 4px;
  white-space: nowrap;
}
.ww-link:disabled { color: #b9c3cf; cursor: default; text-decoration: none; }
.ww-link.is-armed { color: var(--gof-rust); }

/* ===== Settings panel, below the board ================================= */
.ww-panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ww-names-link {
  align-self: flex-start;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gof-green-dark);
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 0;
}
.panel-block { display: flex; flex-direction: column; gap: 8px; }
.name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.name-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;  /* 16px stops iOS zooming in on focus */
  color: var(--text-primary);
  background: var(--panel-bg);
}
.name-input:focus { outline: none; border-color: var(--text-primary); }

/* ===== Buttons ========================================================= */
.ww-btn {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gof-green);
  color: var(--text-primary);
  font-family: 'League Spartan', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.ww-btn:hover { background: var(--gof-green-hover); }
.ww-btn:active { transform: translateY(1px); }
.ww-btn:disabled { background: #e3e8ee; color: #8a95a1; cursor: default; transform: none; }

.ww-btn-outline {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 2px solid var(--text-primary);
  border-radius: var(--radius-sm);
  background: var(--panel-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.ww-btn-outline:hover { background: var(--gof-mint); }

.ww-btn-ghost {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1.5px dashed #c4ccd6;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ww-btn-ghost:hover { border-color: var(--gof-green); color: var(--text-primary); }

/* ===== Article ========================================================= */
.article { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.article-section {
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 12px;
}
.article-section h2 { font-family: 'League Spartan', sans-serif; font-size: 1.05rem; font-weight: 700; margin: 0; }
.article-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.article-section__head::-webkit-details-marker { display: none; }
.article-chevron { color: var(--text-secondary); font-size: 0.8rem; transition: transform 0.15s; }
.article-section[open] .article-chevron { transform: rotate(180deg); }
.article-body { padding: 0 16px 16px; line-height: 1.55; font-size: 0.95rem; }
.article-body h3 { font-size: 0.95rem; margin: 14px 0 6px; }
.article-body h4 { font-size: 0.95rem; margin: 12px 0 4px; }
.article-body p { margin: 0 0 10px; }
.article-body ol, .article-body ul { margin: 0 0 10px; padding-left: 20px; }
.article-body li { margin-bottom: 6px; }

/* ===== Settings sheet ================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(47, 44, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1200;
}
.modal {
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-title { font-family: 'League Spartan', sans-serif; font-size: 1.2rem; font-weight: 700; margin: 0; }
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  bottom: -16px;
  margin: 4px -16px -16px;
  padding: 12px 16px 16px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
}
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-label { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.sheet-hint { font-weight: 400; font-size: 0.78rem; color: var(--text-secondary); }
.sheet-hint.is-note { padding: 8px 10px; border-radius: var(--radius-sm); background: #fff3d1; color: var(--text-primary); font-size: 0.85rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  background: var(--panel-bg);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 6px 11px;
  cursor: pointer;
}
.chip:hover { border-color: var(--gof-green); }
.chip.selected { background: var(--gof-mint); border-color: var(--gof-green-dark); color: var(--gof-green-dark); }
.chip:disabled { opacity: 0.4; cursor: default; }

.seg { display: flex; gap: 4px; flex-shrink: 0; }
.seg button {
  min-width: 44px;
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1.5px solid #d1d5db;
  background: var(--panel-bg);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}
.seg button.selected { background: var(--gof-mint); border-color: var(--gof-green-dark); color: var(--gof-green-dark); }

.stepper { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.stepper button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid #d1d5db;
  background: var(--panel-bg);
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}
.stepper button:hover { border-color: var(--gof-green); background: var(--gof-mint); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper span {
  min-width: 44px;
  text-align: center;
  font-family: 'League Spartan', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

/* ===== Footer (Timer-style) ============================================ */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.footer-links { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: var(--gof-green-dark); text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }
