/* style.css – Mutuals */

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  /* Primary palette — blue / yellow / red */
  --blue:         #1A73E8;
  --blue-dark:    #1557B0;
  --blue-light:   #E8F0FE;
  --yellow:       #FBBC04;
  --yellow-dark:  #F29900;
  --yellow-light: #FFF8E1;
  --red:          #D93025;
  --red-light:    #FCE8E6;

  /* Surfaces */
  --bg:           #FFFFFF;
  --bg-board:     #F1F3F4;
  --bg-panel:     #FFFFFF;
  --border:       #DADCE0;
  --border-focus: var(--blue);

  /* Text */
  --text:         #202124;
  --text-muted:   #5F6368;
  --text-light:   #9AA0A6;

  /* Shadows */
  --shadow-card:  0 1px 3px rgba(60,64,67,0.20), 0 2px 8px rgba(60,64,67,0.10);
  --shadow-raise: 0 4px 14px rgba(26,115,232,0.22), 0 2px 6px rgba(60,64,67,0.12);
  --shadow-btn:   0 2px 8px rgba(26,115,232,0.30);

  /* Shape */
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app { height: 100vh; overflow: hidden; }

/* ── Base Screen ──────────────────────────────────────────────────────────── */
.screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: 'Nunito', inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.85rem 1.75rem;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 4px 14px rgba(26,115,232,0.40); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }

.btn-lg {
  font-size: 1.1rem;
  padding: 1.1rem 2.25rem;
  border-radius: var(--radius-xl);
}

.btn-sm {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
}

/* Answer buttons */
.btn-yes {
  flex: 1;
  background: var(--blue);
  color: #fff;
  font-size: 1.15rem;
  box-shadow: var(--shadow-btn);
}
.btn-yes:hover { background: var(--blue-dark); }

.btn-no {
  flex: 1;
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
  font-size: 1.15rem;
}
.btn-no:hover { border-color: var(--text-muted); color: var(--text); }

/* ── Input ────────────────────────────────────────────────────────────────── */
.input {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: 'Nunito', inherit;
  font-size: 1rem;
  outline: none;
  padding: 0.95rem 1.2rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.input::placeholder { color: var(--text-light); }

/* ── Player Badges ────────────────────────────────────────────────────────── */
.player-badge {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.9rem;
  text-transform: uppercase;
}
.player-1-badge {
  background: var(--blue-light);
  border: 1.5px solid var(--blue);
  color: var(--blue-dark);
}
.player-2-badge {
  background: var(--yellow-light);
  border: 1.5px solid var(--yellow-dark);
  color: #6B4700;
}

/* ── Brand Mark — small Mutuals wordmark used on cover / gameover screens ─── */
.brand-mark {
  font-family: 'Fredoka One', cursive;
  color: var(--blue);
  font-size: 1.6rem;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 0.8rem 1rem 0;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── Setup Screen — App launch screen ────────────────────────────────────── */
.setup-screen {
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  background: var(--bg);
}

/* Hero / logo area */
.logo {
  background: linear-gradient(145deg, #1A73E8 0%, #1255B0 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 2rem 3rem;
  text-align: center;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 5rem;
  display: block;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.22));
}

.game-title {
  font-family: 'Fredoka One', cursive;
  color: #fff;
  font-size: 5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 2px 14px rgba(0,0,0,0.18);
}

.game-subtitle {
  color: rgba(255,255,255,0.82);
  font-size: 1.05rem;
  margin-top: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Form area */
.setup-card {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 2rem;
}

.setup-form { display: flex; flex-direction: column; gap: 1.2rem; }
.setup-form .btn { width: 100%; margin-top: 0.3rem; }

.input-group { display: flex; flex-direction: column; gap: 0.5rem; }

.input-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Shrink hero on short screens */
@media (max-height: 620px) {
  .logo { padding: 2rem 2rem 1.75rem; }
  .logo-icon { font-size: 3.25rem; }
  .game-title { font-size: 3.5rem; }
  .game-subtitle { font-size: 0.95rem; }
}

/* ── Cover Screen ─────────────────────────────────────────────────────────── */
.cover-screen {
  background: var(--bg);
  border-top: 4px solid var(--yellow);
}

.cover-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  max-width: 340px;
  padding: 1rem 2rem 2.5rem;
  text-align: center;
  width: 100%;
  align-self: center;
}

.cover-emoji { font-size: 4rem; display: block; }
.cover-eyebrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cover-content h2 {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.3;
}
.cover-hint {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

/* ── Pick Screen ──────────────────────────────────────────────────────────── */
.pick-screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.section-header {
  flex-shrink: 0;
  text-align: center;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.section-header h2 {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0.5rem 0 0.25rem;
}
.pick-hint { color: var(--text-muted); font-size: 0.88rem; }

/* ── Character Grid — Game board (exactly 2 rows, horizontal scroll) ─────── */
.board-area {
  flex: 1;
  overflow: hidden;
  background: var(--bg-board);
  min-height: 0;
}

.character-grid-board {
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  /*
   * Card size = min(width-limit, height-limit) so all 20 cards fit on
   * screen with no scrolling, using whichever axis is the constraint.
   *
   * Width limit  — fit 10 cols in the viewport:
   *   (100vw − 40px h-padding − 9×12px gaps) / 10  =  (100vw − 148px) / 10
   *
   * Height limit — fit 2 rows in the remaining board area:
   *   Fixed chrome (phase bar 54px + play-header 59px + question panel
   *   with log 198px) + grid padding (36px) + 2×name (30px) + row gap (12px)
   *   ≈ 389px consumed; add ~20px safety margin = 409px.
   *   Each row: (100vh − 409px) / 2
   */
  grid-auto-columns: min(
    calc((100vw - 148px) / 10),
    calc((100vh - 409px) / 2)
  );
  gap: 12px;
  align-content: center;
  height: 100%;
  overflow-x: auto;   /* fallback if viewport is unusually small */
  overflow-y: hidden;
  padding: 16px 20px 20px;
}

/* ── Character Cards ──────────────────────────────────────────────────────── */

/* Outer wrapper — the clickable grid item */
.char-wrap {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  scroll-snap-align: start;
}
.char-wrap:active .char-card { transform: scale(0.94); }

.char-wrap:hover:not(.eliminated):not(.no-click) .char-card {
  border-color: var(--blue);
  box-shadow: var(--shadow-raise);
  transform: translateY(-3px);
}

.char-wrap.guess-mode:hover:not(.eliminated) .char-card {
  border-color: var(--yellow-dark);
  box-shadow: 0 4px 14px rgba(251,188,4,0.45);
  transform: translateY(-3px);
}

/* Eliminated: greyscale card + faded name */
.char-wrap.eliminated .char-card { filter: grayscale(100%); opacity: 0.38; }
.char-wrap.eliminated .char-name { opacity: 0.38; }

/* Read-only in ask phase */
.char-wrap.no-click { cursor: default; pointer-events: none; }

/* Square bordered box — contains only the photo */
.char-card {
  aspect-ratio: 1;       /* forces square regardless of content */
  width: 100%;           /* fills grid column width */
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;      /* clips image to rounded corners */
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Photo fills the entire square card — no padding, no gaps */
.char-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Name sits below the card border, not inside it */
.char-name {
  font-family: 'Nunito', sans-serif;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* Red X overlay — inside the square card */
.elim-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(217,48,37,0.12);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--red);
  pointer-events: none;
}

/* ── Play Screen Layout ───────────────────────────────────────────────────── */
.play-screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

/* ── Phase Indicator Bar ──────────────────────────────────────────────────── */
.phase-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 50px;
  text-align: center;
}

.step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
}

.step-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Active: solid blue */
.phase-step.active .step-dot   { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(26,115,232,0.4); }
.phase-step.active .step-label { color: var(--blue); font-weight: 800; }

/* Done: yellow */
.phase-step.done .step-dot     { background: var(--yellow); color: #5C3D00; }
.phase-step.done .step-label   { color: var(--yellow-dark); }

/* Pending: grey */
.phase-step.pending .step-dot  { background: var(--border); color: var(--text-light); }
.phase-step.pending .step-label{ color: var(--text-light); }

.phase-arrow {
  color: var(--border);
  font-size: 1rem;
  flex-shrink: 0;
  margin-bottom: 14px; /* align with dots, not labels */
}

/* ── Play Header ──────────────────────────────────────────────────────────── */
.play-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 10px 14px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.turn-meta { display: flex; flex-direction: column; gap: 4px; }
.turn-hint { color: var(--text-muted); font-size: 0.82rem; }

/* ── Question Panel ───────────────────────────────────────────────────────── */
.question-panel {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 0.7rem;
  padding: 12px 14px 16px;
}

.question-row { display: flex; gap: 8px; align-items: stretch; }
.question-input { flex: 1; }

/* ── Question Log ─────────────────────────────────────────────────────────── */
.question-log {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 100px;
  overflow-y: auto;
  padding-top: 8px;
}

.log-entry {
  align-items: baseline;
  display: flex;
  font-size: 0.78rem;
  gap: 5px;
  color: var(--text-muted);
}
.log-name   { color: var(--text); flex-shrink: 0; font-weight: 700; }
.log-q      { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-a      { flex-shrink: 0; font-weight: 700; }
.log-a.yes  { color: var(--blue); }
.log-a.no   { color: var(--red); }

/* ── Answer Chips ─────────────────────────────────────────────────────────── */
.answer-chip {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.18rem 0.65rem;
}
.answer-chip.yes        { background: var(--blue-light); color: var(--blue-dark); }
.answer-chip.no         { background: var(--red-light);  color: var(--red); }
.answer-chip.inline     { font-size: 0.82rem; }

/* ── Eliminate Footer ─────────────────────────────────────────────────────── */
.eliminate-footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  padding: 12px 14px 16px;
}

/* ── Answer Screen ────────────────────────────────────────────────────────── */
.answer-screen {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
  border-top: 4px solid var(--blue);
  overflow-y: auto;
}

.answer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 400px;
  text-align: center;
  width: 100%;
}

.answer-content h2 {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 800;
}

.question-bubble {
  background: var(--bg-board);
  border: 2px solid var(--border);
  border-left: 5px solid var(--blue);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 600;
  line-height: 1.5;
  padding: 1.25rem 1.5rem;
  text-align: left;
  width: 100%;
}

.answer-buttons { display: flex; gap: 12px; width: 100%; }

/* ── Decide Screen ────────────────────────────────────────────────────────── */
.decide-screen {
  background: var(--bg);
  border-top: 4px solid var(--yellow);
}

.decide-content {
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1.1rem;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.decide-content h2 {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
}

.decide-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  max-width: 360px;
  margin-top: 0.5rem;
}

.decide-btn { width: 100%; }

/* ── Guess Screen ─────────────────────────────────────────────────────────── */
.guess-prompt {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 16px 4px;
  text-align: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ── Suspense Screen ──────────────────────────────────────────────────────── */
.suspense-screen {
  align-items: center;
  justify-content: center;
  background: #0D1117;
}

.suspense-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
  animation: suspense-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes suspense-in {
  from { opacity: 0; transform: scale(0.82); }
  to   { opacity: 1; transform: scale(1); }
}

.suspense-eyebrow {
  color: rgba(255,255,255,0.45);
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.suspense-photo {
  width: 156px;
  height: 156px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  animation: suspense-glow 1.1s ease-in-out infinite alternate;
}

@keyframes suspense-glow {
  from { box-shadow: 0 0 0 3px rgba(255,255,255,0.10), 0 20px 60px rgba(0,0,0,0.60); }
  to   { box-shadow: 0 0 0 6px rgba(255,255,255,0.28), 0 0 55px rgba(26,115,232,0.40), 0 20px 60px rgba(0,0,0,0.60); }
}

.suspense-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.suspense-name {
  color: rgba(255,255,255,0.95);
  font-family: 'Nunito', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  margin-top: -0.4rem;
}

.suspense-text {
  color: rgba(255,255,255,0.55);
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.02em;
}

.suspense-dots {
  display: inline-block;
  animation: suspense-blink 0.85s ease-in-out infinite;
}

@keyframes suspense-blink {
  0%, 100% { opacity: 0.2; }
  50%       { opacity: 1; }
}

/* ── Game Over Screen ─────────────────────────────────────────────────────── */
.gameover-screen {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg);
}

.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 380px;
  text-align: center;
  width: 100%;
}

.win-logo {
  font-family: 'Fredoka One', cursive;
  color: var(--blue);
  font-size: 1.75rem;
  letter-spacing: 0.05em;
  opacity: 0.75;
  margin-bottom: -0.1rem;
}

.win-title {
  font-family: 'Fredoka One', cursive;
  color: var(--text);
  font-size: 3.2rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.win-sub { color: var(--text-muted); font-size: 1rem; font-weight: 700; }

.reveal-card {
  align-items: center;
  background: var(--bg);
  border: 3px solid var(--yellow);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 20px rgba(251,188,4,0.30);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.5rem 0;
  padding: 1.5rem 2.5rem;
}

.reveal-avatar {
  border-radius: var(--radius);
  height: 96px;
  object-fit: cover;
  width: 96px;
}

.reveal-name { color: var(--text); font-size: 1.25rem; font-weight: 800; }

.win-stats {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Responsive card grid — tablet (600–959px) and mobile (< 600px) ──────── */

/*
 * Both breakpoints: switch from the desktop 10-col horizontal layout to a
 * standard row-flow grid. The board-area becomes vertically scrollable so
 * cards can be a comfortable tap size without being crammed to fit the height.
 */
@media (max-width: 959px) {
  .board-area {
    overflow-y: auto;             /* board scrolls vertically if grid is taller */
  }

  .character-grid-board {
    grid-template-rows: none;     /* remove the desktop 2-row constraint        */
    grid-auto-flow: row;          /* natural left-to-right, top-to-bottom order  */
    grid-auto-columns: auto;      /* neutralise the desktop min() column formula */
    height: auto;                 /* shrink-wrap to content, not 100% of area   */
    overflow-x: hidden;           /* no horizontal scroll                        */
    overflow-y: hidden;           /* board-area handles vertical scroll          */
  }
}

/* Tablet: 5 columns × 4 rows */
@media (min-width: 600px) and (max-width: 959px) {
  .character-grid-board {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Mobile: 4 columns × 5 rows */
@media (max-width: 599px) {
  .character-grid-board {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px 10px 12px;
  }

  /* Guarantee a comfortable finger tap target */
  .char-card {
    min-height: 60px;
  }

  /* Slightly larger name label for legibility at smaller card widths */
  .char-name {
    font-size: 13px;
  }
}
