/* LCR (Left Center Right) — diamond layout, active player at bottom.
 * Visual language matches the Game On Family brand. */

: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);
  --chip-color: #ffb920;
}

* { 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: 1.5rem 1rem 2rem;
}

/* ===== Shared header bar (per HEADER_SPECS) ===== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0.75rem;
  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 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.mode-indicator {
  font-weight: 600;
}

/* ===== Screens ===== */
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.screen[hidden] {
  display: none;
}

/* ===== Inline settings on the play screen =====
 * Sits below the gameplay area. Pre-selected to 4 players on load so
 * users can ignore this entirely and just roll. Click a different
 * count to restart the game; edit a name to live-update the running
 * game on blur. */
.play-settings {
  width: 100%;
  max-width: 480px;
  margin: 1rem auto 0;
  padding: 1rem 1.25rem 0.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Muted styling so settings don't compete visually with active gameplay. */
.play-settings .setup-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

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

.setup-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.setup-hint {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.player-count-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.count-btn {
  min-width: 0;
  min-height: 38px;
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  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, transform 0.1s;
}

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

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

.count-btn:active {
  transform: scale(0.96);
}

.player-name-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-name-input {
  font-family: 'Arimo', sans-serif;
  font-size: 0.95rem;
  padding: 0.625rem 0.875rem;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  background: white;
  color: var(--text-primary);
  min-height: 40px;
}

.player-name-input:focus {
  outline: none;
  border-color: var(--gof-primary);
  box-shadow: 0 0 0 3px rgba(155, 202, 62, 0.25);
}

/* ===== Buttons ===== */
.primary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.875rem 1.5rem;
  min-height: 48px;
  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;
}

.start-btn {
  font-size: 1.15rem;
  padding: 1rem 1.5rem;
}

/* ===== Game blurb ===== */
.game-blurb {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-primary);
  text-align: center;
}

.game-blurb p { margin: 0; }
.game-blurb p + p { margin-top: 0.625rem; }

.goal-line {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  color: var(--gof-primary-dark);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

/* ===== Settings section ===== */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.settings-heading {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 0.125rem;
}

.settings-section .setup-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Setup screen die preview */
.setup-die-preview {
  --gof-dice-size: 100px;
  --gof-dice-tumble-ms: 900ms;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===== Diamond board (play screen) =====
 * Player cards + center-pot card positioned absolutely around a single
 * point. Each card has a `--angle` CSS variable (clockwise from top:
 * 0deg = top, 90deg = right, 180deg = bottom, 270deg = left), updated
 * by JS every turn. The translate() uses CSS sin()/cos() to convert
 * angle + radius into x/y. The transition handles the smooth slide. */
.diamond-board {
  position: relative;
  width: 100%;
  max-width: 380px;
  height: 320px;
  margin: 0 auto;
  --board-radius-x: 130px;
  --board-radius-y: 110px;
  --arc-card-scale: 1;
}

.player-card,
.pot-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 96px;
  margin-left: -48px;
  margin-top: -36px;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 0.45rem 0.5rem 0.55rem;
  box-shadow: var(--card-shadow);
  border: 2px solid transparent;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.2s ease,
              opacity 0.25s ease,
              background 0.2s ease;
}

/* Default angle = 180deg (bottom). JS overrides per card. */
.player-card {
  --angle: 180deg;
  transform: translate(
    calc(sin(var(--angle)) * var(--board-radius-x)),
    calc(-1 * cos(var(--angle)) * var(--board-radius-y))
  );
}

/* Cards on the upper arc (offsets 2..N-2) shrink for higher player
 * counts so they fit without too much overlap. --arc-card-scale is
 * computed by JS based on player count and set on the diamond board. */
.player-card.is-arc {
  transform: translate(
    calc(sin(var(--angle)) * var(--board-radius-x)),
    calc(-1 * cos(var(--angle)) * var(--board-radius-y))
  ) scale(var(--arc-card-scale));
  z-index: 1;
}

.player-card.is-arc.is-out {
  z-index: 0;
}

/* Anchor positions (bottom, left, right) sit above arc cards if they
 * happen to overlap, since they're the "active triplet" the user
 * needs to read at a glance. */
.player-card[data-slot="bottom"],
.player-card[data-slot="left"],
.player-card[data-slot="right"] {
  z-index: 2;
}

.player-card.is-current {
  border-color: var(--gof-primary-dark);
  background: var(--gof-bg-mint);
}

.player-card.is-out {
  opacity: 0.5;
}

.player-card-name {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.player-card-name.is-editable {
  cursor: pointer;
}

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

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

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

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

/* Visual chip representation — a row of "poker chip" dots, one per chip.
 * Wraps to a second row above ~5 chips. Min-height keeps card layout
 * stable as chips come and go. */
.player-card-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 4px;
  width: 100%;
  min-height: 36px;
  padding: 2px 0;
}

.chip-pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd674, var(--chip-color) 60%, #c89015);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.22),
              0 1px 2px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.chip-pip-overflow {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  align-self: center;
  margin-left: 2px;
}

.player-card.is-out .chip-pip {
  background: #d8d8d8;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.12);
}

/* L/R neighbor cues — render small arrows on the screen-left and
 * screen-right cards, positioned just below the card. */
.player-card-cue {
  position: absolute;
  bottom: -14px;
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gof-primary-dark);
  background: white;
  border-radius: 12px;
  padding: 1px 8px;
  box-shadow: var(--card-shadow);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}

.player-card[data-cue="L"] .player-card-cue,
.player-card[data-cue="R"] .player-card-cue {
  opacity: 1;
}

/* Center pot card — fixed in the middle. Uses transform-based centering
 * so the card stays centered on the diamond's center point as its height
 * grows when chips accumulate inside it. */
.pot-card {
  margin-left: 0;
  margin-top: 0;
  transform: translate(-50%, -50%);
  background: var(--gof-bg-mint);
  border-color: var(--gof-warm);
  /* Override the player-card transform transition rule for slot moves
   * (pot doesn't move); keep border-color/opacity transitions only. */
  transition: border-color 0.2s ease, opacity 0.25s ease, background 0.2s ease;
}

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

.pot-card-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 4px;
  width: 100%;
  min-height: 18px;
  padding: 2px 0;
}

.pot-card-chips .chip-pip {
  background: radial-gradient(circle at 35% 30%, #ffc4a0, var(--gof-warm) 60%, #9a3a16);
}

.pot-card-sub {
  font-size: 0.65rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-align: center;
  margin-top: 2px;
}

/* Chip-delta badge that pops in on each card after a roll, then fades. */
.player-card-delta,
.pot-card-delta {
  position: absolute;
  top: -6px;
  right: -6px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.player-card-delta.is-showing,
.pot-card-delta.is-showing {
  opacity: 1;
  transform: scale(1);
}

.player-card-delta.is-positive,
.pot-card-delta.is-positive {
  color: var(--gof-primary-dark);
  background: #eaf6dc;
}

.player-card-delta.is-negative,
.pot-card-delta.is-negative {
  color: var(--gof-warm);
  background: #fde9df;
}

/* ===== Dice area ===== */
.dice-area {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 110px;
  padding: 0.25rem 0;
  width: 100%;
}

.dice-tray-wrap {
  --gof-dice-size: 90px;
  --gof-dice-tumble-ms: 900ms;
}

.dice-area.is-empty {
  min-height: 60px;
}

/* ===== Commentary bubble ===== */
.lcr-commentary {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  max-width: 480px;
  min-height: 80px;
  margin: 0 auto;
  padding: 0 0.25rem;
}

.lcr-character {
  font-size: 3rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  transition: transform 0.25s ease;
}

.lcr-character.is-talking {
  transform: scale(1.12) rotate(-4deg);
}

.lcr-bubble {
  flex: 1;
  position: relative;
  background: white;
  border-radius: 14px;
  padding: 0.75rem 1rem;
  box-shadow: var(--card-shadow);
  border: 2px solid var(--text-primary);
  min-height: 50px;
  display: flex;
  align-items: center;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.lcr-bubble.is-fading {
  opacity: 0;
  transform: translateX(-4px);
}

.lcr-bubble::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-right: 13px solid var(--text-primary);
}

.lcr-bubble::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-right: 10px solid white;
}

.lcr-bubble p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

@keyframes pop-in {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== Action buttons ===== */
.action-buttons {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 360px;
}

.action-buttons .primary-btn {
  flex: 1;
}

/* ===== Pass-over button ===== */
.passover {
  width: 100%;
  max-width: 360px;
}

.passover-btn {
  width: 100%;
  background: var(--gof-warm);
}

.passover-btn:hover:not(:disabled) {
  background: #c75529;
}

/* ===== Win screen ===== */
.win-screen {
  padding-top: 2rem;
  text-align: center;
}

.trophy {
  font-size: 4rem;
  animation: pop-in 0.5s ease-out;
}

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

.winner-title #winnerName {
  color: var(--gof-warm);
}

.winner-score {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ===== 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: 420px) {
  .game-title {
    font-size: 2.25rem;
  }
  .diamond-board {
    --board-radius-x: 108px;
    --board-radius-y: 100px;
    height: 290px;
  }
  .player-card,
  .pot-card {
    width: 88px;
    margin-left: -44px;
    margin-top: -34px;
  }
  .player-card-num,
  .pot-card-num {
    font-size: 1.25rem;
  }
  .dice-tray-wrap {
    --gof-dice-size: 76px;
  }
}

@media (max-width: 360px) {
  .diamond-board {
    --board-radius-x: 96px;
    --board-radius-y: 92px;
    height: 272px;
  }
  .player-card,
  .pot-card {
    width: 80px;
    margin-left: -40px;
    margin-top: -32px;
  }
  .dice-tray-wrap {
    --gof-dice-size: 68px;
  }
}
