/* Farkle - single-screen, dice-first. Brand-aligned with Game On Family. */

:root {
  --gof-primary-dark: #157623;
  --gof-primary: #9bca3e;
  --gof-bg-light: #dde5ed;
  --gof-bg-mint: #defff0;
  --gof-accent: #ffb920;
  --gof-warm: #de6739;
  --text-primary: #2f2c28;
  --text-secondary: #5e5c5e;
  --card-bg: #ffffff;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

  /* Dice. The roll dice are the shared GofDice 3D cubes (../shared/dice.*);
     fed in as --gof-dice-size. The roll size is capped so all six fit one
     row inside the 460px dice area on desktop (6 x 58 + gaps + padding). */
  --roll-die: clamp(40px, 11.5vw, 58px);
  --kept-die: clamp(26px, 7vw, 34px);
}

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

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

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

/* ===== Shared header bar (per HEADER_SPECS) ===== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0.25rem;
  padding: 4px 0;
  gap: 12px;
  position: relative;
  z-index: 1100;
}

.header-left { flex: 1; min-width: 0; max-width: 85%; }
.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;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

.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: 160px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  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 #e2e8f0;
}

.game-nav-link:last-child { border-bottom: none; }
.game-nav-link:hover { background: var(--gof-bg-mint); }

/* ===== Mode + difficulty pills ===== */
.mode-row,
.difficulty-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

/* `display: flex` above would otherwise override the [hidden] attribute. */
.difficulty-row[hidden] { display: none; }

.difficulty-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.mode-btn,
.diff-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  min-height: 28px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-btn:hover,
.diff-btn:hover {
  border-color: var(--gof-primary);
  background: var(--gof-bg-mint);
}

.mode-btn[aria-pressed="true"],
.diff-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
  border-width: 2px;
  padding: 2px 10px;
}

/* ===== Tagline ===== */
.tagline {
  font-family: 'Trocchi', Georgia, serif;
  color: var(--text-secondary);
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.35;
}

/* ===== Scoreboard ===== */
.scoreboard {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  max-width: 460px;
}

.player-card {
  flex: 1;
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  text-align: center;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s, transform 0.15s;
}

/* The player whose turn it is. */
.player-card.is-current {
  border-color: var(--gof-primary-dark);
  transform: translateY(-2px);
}

/* The winner (or a tied player) at game end. */
.player-card.is-winner {
  border-color: var(--gof-accent);
  background: #fffdf3;
}

.player-name {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-card.is-current .player-name { color: var(--gof-primary-dark); }

.player-score {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.7rem;
  line-height: 1.1;
  color: var(--text-primary);
}

.player-turn-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gof-primary-dark);
}

/* ===== Final-round banner ===== */
.final-round-banner {
  width: 100%;
  max-width: 460px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #8a5a00;
  background: #fff3d4;
  border: 1px solid var(--gof-accent);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
}

/* ===== Status area: turn / win ===== */
.status-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-height: 3.6rem;
  justify-content: center;
}

.turn-banner {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--gof-primary-dark);
  text-align: center;
}

.turn-points {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.turn-points strong {
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  color: var(--gof-warm);
}

.turn-points.is-farkled strong { color: var(--gof-warm); }

.win-banner {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--gof-primary-dark);
  text-align: center;
  line-height: 1.2;
}

.win-banner.is-tie { color: var(--text-secondary); }

.win-banner .win-score {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

/* ===== Announce line (Farkle / Hot Dice / banking / selection) ===== */
/* Fixed-height slot. The styled message box sits inside it and sizes to its
   content; reserving the slot height means a message appearing or clearing
   never shifts the dice and buttons below it. */
.announce {
  width: 100%;
  max-width: 460px;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.announce-msg {
  width: 100%;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  line-height: 1.3;
}

.announce-msg.is-farkle {
  color: #b3261e;
  background: #ffe5e2;
  border: 1px solid #f3a9a2;
  font-size: 1.05rem;
}

.announce-msg.is-hot {
  color: #b3500e;
  background: #ffe9d0;
  border: 1px solid #f3c089;
}

.announce-msg.is-bank {
  color: var(--gof-primary-dark);
  background: var(--gof-bg-mint);
  border: 1px solid var(--gof-primary);
}

.announce-msg.is-hint {
  color: var(--text-secondary);
  background: #eef2f6;
  border: 1px solid #d9e0e7;
  font-weight: 600;
}

/* ===== Dice (shared GofDice 3D cubes) ===== */
/* The board is a fixed height: enough for the roll area plus one row of the
   kept tray. The kept tray is empty (hidden) at the start of a turn, so
   reserving its row here means setting dice aside never shifts the buttons
   below - the tray fills space that was already held. */
.dice-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: calc(var(--roll-die) + var(--kept-die) + 3.4rem);
}

/* The roll area also serves as the GofDice tray container (ui.js gives it the
   .gof-dice-tray class). Loading dice.css before style.css lets this gap win
   over the module's default 1rem so all six dice fit one row. */
.dice-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  min-height: calc(var(--roll-die) + 1.7rem);
  padding: 0.7rem 0.55rem;
  width: 100%;
  max-width: 460px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
}

/* `display: flex` on the dice area / kept tray would otherwise override the
   [hidden] attribute's display:none, so restore it explicitly. */
.dice-area[hidden],
.kept-tray[hidden] { display: none; }

/* Each die is a GofDice cube wrapped in a .gof-dice-stage; ui.js adds the
   state classes below. The cube faces and pips keep the shared dice.css look. */
.dice-area .gof-dice-stage {
  border-radius: calc(var(--gof-dice-size, 58px) * 0.16);
  transition: transform 0.13s ease, opacity 0.15s ease;
}

/* A die that can contribute to a score - tappable. */
.dice-area .gof-dice-stage.is-scoring { cursor: pointer; }
.dice-area .gof-dice-stage.is-scoring:hover { transform: translateY(-3px); }
.dice-area .gof-dice-stage.is-scoring:focus-visible {
  outline: 2px solid var(--gof-primary-dark);
  outline-offset: 3px;
}

/* A die the player has picked to set aside. */
.dice-area .gof-dice-stage.is-selected {
  transform: translateY(-7px);
  outline: 3px solid var(--gof-accent);
  outline-offset: 3px;
}

/* Non-scoring dice in the roll, and every die of a Farkled roll - dimmed. */
.dice-area .gof-dice-stage.is-dud,
.dice-area .gof-dice-stage.is-farkle {
  opacity: 0.38;
  filter: grayscale(0.6);
}

/* ROLL-phase placeholders: empty dashed slots shown before a roll. A die
   only ever shows a value once it has actually been rolled. */
.die-ghost {
  width: var(--roll-die);
  height: var(--roll-die);
  border-radius: calc(var(--roll-die) * 0.16);
  border: 2px dashed rgba(47, 44, 40, 0.2);
  box-sizing: border-box;
}

/* ===== Kept-this-turn tray ===== */
.kept-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 460px;
  padding: 0.5rem 0.65rem;
  background: var(--gof-bg-mint);
  border: 1px dashed var(--gof-primary);
  border-radius: 12px;
}

.kept-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gof-primary-dark);
}

/* The kept dice are a second GofDice tray - static cubes, no roll. */
#keptDice { gap: 0.4rem; }

/* ===== Play actions ===== */
.play-actions {
  display: flex;
  gap: 0.625rem;
  width: 100%;
  max-width: 380px;
  justify-content: center;
}

.primary-btn,
.secondary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7rem 1.25rem;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  flex: 1;
}

.primary-btn {
  background: var(--gof-primary-dark);
  color: white;
  border: 2px solid var(--gof-primary-dark);
}

.primary-btn:hover { background: #11631d; }

.secondary-btn {
  background: white;
  color: var(--gof-primary-dark);
  border: 2px solid var(--gof-primary-dark);
}

.secondary-btn:hover { background: var(--gof-bg-mint); }

.primary-btn:active,
.secondary-btn:active { transform: scale(0.97); }

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ===== How to play ===== */
.how-to {
  width: 100%;
  max-width: 520px;
}

.how-to details {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.how-to-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.how-to-toggle::-webkit-details-marker { display: none; }

.how-to-chevron { font-size: 0.7rem; color: var(--text-secondary); transition: transform 0.15s; }
.how-to details[open] .how-to-chevron { transform: rotate(180deg); }

.how-to-body {
  padding: 0 1rem 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.how-to-body p { margin-bottom: 0.5rem; }
.how-to-body ul { padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.how-to-body strong { color: var(--text-primary); }

/* ===== Footer ===== */
.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-primary-dark);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover { text-decoration: underline; }

/* ===== Mobile ===== */
@media (max-width: 360px) {
  .turn-banner { font-size: 1.2rem; }
  .win-banner { font-size: 1.35rem; }
  .player-score { font-size: 1.45rem; }
}
