/* Four in a Row — single-screen, board-first. Brand-aligned. */

: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);

  --disc-red: #de6739;
  --disc-red-edge: #b04d27;
  --disc-black: #2f2c28;
  --disc-black-edge: #0f0d0b;
  --board-bg: #157623;
  --board-edge: #0f5a1b;
  --hole-bg: #f4f7f2;
  --cell-size: min(13.5vw, 60px);
  --cell-gap: 6px;
}

* { 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: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
}

/* ===== 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-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.mode-row .mode-btn {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 3px 10px;
  min-height: 26px;
  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-row .mode-btn:hover {
  border-color: var(--gof-primary);
  background: var(--gof-bg-mint);
}

.mode-row .mode-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 9px;
}

/* Legacy mode-indicator (no longer used; kept for safety) */
.mode-indicator {
  font-weight: 600;
}

/* ===== Legacy game header (no longer used; kept for safety) ===== */
.game-header {
  text-align: center;
}

.game-title {
  font-family: 'League Spartan', sans-serif;
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--gof-primary-dark);
  line-height: 1;
}

.game-tagline {
  font-family: 'Trocchi', Georgia, serif;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ===== Scoreboard ===== */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
  max-width: 460px;
}

.score-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 0.5rem 0.625rem;
  box-shadow: var(--card-shadow);
  border: 2px solid transparent;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.score-card.is-current {
  border-color: var(--gof-primary-dark);
  background: var(--gof-bg-mint);
  transform: translateY(-2px);
}

.score-card-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
}

.score-card-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.score-card-color.is-red {
  background: radial-gradient(circle at 35% 30%, #f4885c, var(--disc-red) 60%, var(--disc-red-edge));
}
.score-card-color.is-black {
  background: radial-gradient(circle at 35% 30%, #5d5852, var(--disc-black) 60%, var(--disc-black-edge));
}

.score-card-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.score-card-name.is-editable { cursor: pointer; }
.score-card-name.is-editable:hover { color: var(--gof-primary-dark); }

.score-card-name .edit-icon {
  margin-left: 4px;
  font-size: 0.85em;
  opacity: 0.7;
}

.score-card-name.is-editable:hover .edit-icon { opacity: 1; }

.score-card-name-input {
  width: 100%;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  border: none;
  border-bottom: 2px solid var(--gof-primary-dark);
  background: white;
  color: var(--text-primary);
  padding: 2px 0;
  outline: none;
}

.score-card-wins {
  font-family: 'League Spartan', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gof-primary-dark);
  line-height: 1;
}

.score-card-wins-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ===== Turn indicator + round pill ===== */
.turn-indicator {
  font-size: 1rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.turn-name {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--gof-primary-dark);
}

.round-pill {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: white;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(0,0,0,0.08);
}

/* ===== Board ===== */
.board-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  gap: var(--cell-gap);
  background: var(--board-bg);
  padding: var(--cell-gap);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  border: 3px solid var(--board-edge);
}

.board.is-frozen { pointer-events: none; }

.col {
  display: flex;
  flex-direction: column;
  gap: var(--cell-gap);
  cursor: pointer;
  position: relative;
  border-radius: 8px;
  transition: background 0.15s;
}

.col[aria-disabled="true"] { cursor: not-allowed; }

.col:not([aria-disabled="true"]):hover {
  background: rgba(255, 255, 255, 0.06);
}

.ghost-cell {
  /* Sits half-tucked into the column — "loaded into the chute" look.
     Top half shows above the board rim; bottom half shows through the top
     hole (z-index keeps it above the cell so it reads like a real disc
     loaded halfway into the slot). */
  position: absolute;
  top: calc(-1 * var(--cell-size) / 2);
  left: 0;
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 2;
}

.ghost-cell.is-visible { opacity: 0.7; }
.ghost-cell.is-red {
  background: radial-gradient(circle at 35% 30%, #f4885c, var(--disc-red) 60%, var(--disc-red-edge));
}
.ghost-cell.is-black {
  background: radial-gradient(circle at 35% 30%, #5d5852, var(--disc-black) 60%, var(--disc-black-edge));
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--hole-bg);
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
  overflow: hidden;
}

.disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.3), inset 0 2px 0 rgba(255,255,255,0.18);
}

.disc.is-red {
  background: radial-gradient(circle at 35% 30%, #f4885c, var(--disc-red) 60%, var(--disc-red-edge));
}

.disc.is-black {
  background: radial-gradient(circle at 35% 30%, #5d5852, var(--disc-black) 60%, var(--disc-black-edge));
}

@keyframes drop {
  from { transform: translateY(var(--drop-from)); }
  to   { transform: translateY(0); }
}

.disc.is-dropping {
  animation-name: drop;
  animation-timing-function: cubic-bezier(0.55, 0.05, 0.85, 0.05);
  animation-fill-mode: forwards;
}

@keyframes win-pulse {
  0%, 100% {
    box-shadow:
      inset 0 -3px 0 rgba(0,0,0,0.3),
      inset 0 2px 0 rgba(255,255,255,0.18),
      0 0 0 0 rgba(255, 185, 32, 0.0);
  }
  50% {
    box-shadow:
      inset 0 -3px 0 rgba(0,0,0,0.3),
      inset 0 2px 0 rgba(255,255,255,0.18),
      0 0 14px 4px rgba(255, 185, 32, 0.85);
  }
}

.disc.is-winning { animation: win-pulse 1.1s ease-in-out infinite; }

.cell.is-dimmed { opacity: 0.55; transition: opacity 0.4s; }

/* ===== Status line ===== */
.status-line {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.4em;
}

.status-line.is-win {
  font-family: 'League Spartan', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gof-primary-dark);
}

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

.play-actions .primary-btn,
.play-actions .secondary-btn {
  flex: 1;
}

/* ===== Buttons ===== */
.primary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  background: var(--gof-primary-dark);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.primary-btn:hover:not(:disabled) { background: #0f5a1b; }
.primary-btn:active:not(:disabled) { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  background: white;
  color: var(--gof-primary-dark);
  border: 2px solid var(--gof-primary-dark);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.secondary-btn:hover:not(:disabled) { background: var(--gof-bg-mint); }
.secondary-btn:active:not(:disabled) { transform: scale(0.97); }
.secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Settings panel (always visible, below the board) ===== */
.settings-panel {
  width: 100%;
  max-width: 520px;
  margin-top: 0.25rem;
  padding: 0.875rem 1rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.setup-section[hidden] { display: none; }

.setup-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

/* "More settings" — collapsed by default; expands the rest of the options */
.more-settings {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 0.875rem;
  margin-top: 0.125rem;
}

.more-settings-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Arimo', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0.1rem;
}

.more-settings-toggle::-webkit-details-marker { display: none; }

.more-settings-toggle:hover { color: var(--gof-primary-dark); }

.more-settings-toggle::after {
  content: "▸";
  display: inline-block;
  font-size: 0.75rem;
  transition: transform 0.15s;
  margin-left: 0.1rem;
}

.more-settings[open] .more-settings-toggle::after {
  transform: rotate(90deg);
}

.more-settings-body {
  margin-top: 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Mode buttons */
.mode-buttons { display: flex; gap: 0.5rem; }

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
  min-height: 40px;
  font-family: 'Arimo', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  background: white;
  color: var(--text-primary);
  border: 1.5px solid var(--gof-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.mode-btn .mode-icon { font-size: 1.05rem; line-height: 1; }
.mode-btn:hover { background: var(--gof-bg-mint); }
.mode-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
  border-width: 2px;
}
.mode-btn:active { transform: scale(0.97); }

/* Difficulty + rule buttons */
.diff-buttons,
.rule-buttons {
  display: flex;
  gap: 0.5rem;
}

.diff-btn,
.rule-btn {
  flex: 1;
  min-height: 36px;
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  background: white;
  color: var(--text-primary);
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.rule-btn { font-size: 0.82rem; }

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

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

.diff-btn:active,
.rule-btn:active { transform: scale(0.97); }

/* ===== 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 tweaks ===== */
@media (max-width: 480px) {
  .game-title { font-size: 1.85rem; }
  :root {
    --cell-size: min(12.5vw, 50px);
    --cell-gap: 5px;
  }
  .turn-name { font-size: 1.15rem; }
  .score-card-wins { font-size: 1.3rem; }
}

@media (max-width: 360px) {
  :root { --cell-size: 36px; --cell-gap: 4px; }
}
