/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0b0f1a;
  --surface:   #141929;
  --panel:     #1a2035;
  --border:    #2a3450;
  --accent:    #818cf8;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── Select Screen ──────────────────────────────────────── */
#select-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem;
  max-width: 900px;
  width: 100%;
}

.game-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.25em;
  background: linear-gradient(135deg, #10b981 0%, #60a5fa 30%, #818cf8 60%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  line-height: 1.1;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
}

.choose-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

/* ── Personality Cards ──────────────────────────────────── */
#personality-cards {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.personality-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  width: 180px;
  border: 2px solid var(--p-color, var(--border));
  border-radius: 1rem;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.personality-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 24px color-mix(in srgb, var(--p-color) 60%, transparent);
}

.personality-card.selected {
  background: color-mix(in srgb, var(--p-color) 10%, var(--surface));
  box-shadow: 0 0 36px color-mix(in srgb, var(--p-color) 70%, transparent);
}

.p-card-avatar {
  font-size: 2.5rem;
  line-height: 1;
}

.p-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--p-color, var(--text));
}

.p-card-quote {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  min-height: 2em;
}

.p-diff {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}
.diff-easy   { background: #14532d; color: #4ade80; }
.diff-medium { background: #92400e; color: #fbbf24; }
.diff-hard   { background: #7f1d1d; color: #f87171; }

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  border: none;
  border-radius: 0.6rem;
  padding: 0.65rem 2.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:hover  { opacity: 0.9; transform: scale(1.02); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.55rem 2rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

.controls-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Game Screen ────────────────────────────────────────── */
#game-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.game-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

#board-canvas {
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 160px;
  flex-shrink: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
}

.label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.score-panel {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.score-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fbbf24;
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.level-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

#next-canvas {
  display: block;
  border-radius: 4px;
  margin-top: 0.25rem;
}

/* ── Commentary ─────────────────────────────────────────── */
.commentary-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.p-avatar {
  font-size: 1.75rem;
  line-height: 1;
}

.p-name-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.commentary-bubble {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--muted);
  min-height: 4em;
  line-height: 1.4;
}

/* ── Controls mini ──────────────────────────────────────── */
.controls-mini {
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* ── Overlays ───────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  min-width: 280px;
}

.overlay-card h2 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #f87171, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.final-section {
  text-align: center;
}

.final-score-value {
  font-size: 3rem;
  font-weight: 900;
  color: #fbbf24;
  line-height: 1;
}

.name-entry {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.name-entry input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.name-entry input:focus { border-color: var(--accent); }

.submit-msg {
  font-size: 0.85rem;
  color: #4ade80;
  min-height: 1.2em;
  text-align: center;
}

/* ── Touch hint (select screen) ─────────────────────────────────────────────── */
.touch-hint {
  font-size: 0.78rem;
  color: var(--muted);
  display: none;
}

/* ── Prevent browser scroll/zoom on the game canvas ─────────────────────────── */
#board-canvas { touch-action: none; }

/* ── Mobile layout (portrait phones, or landscape phones with short viewport) ── */
@media (max-width: 599px), (max-height: 599px) and (orientation: landscape) {
  /* Select screen */
  #select-screen { padding: 1rem; gap: 0.75rem; }
  .personality-card { width: clamp(130px, 42vw, 180px); }
  .controls-hint { display: none; }
  .touch-hint    { display: block; }

  /* Game screen fills the viewport */
  #game-screen {
    position: fixed;
    inset: 0;
  }

  /* Board + sidebar stack vertically; sidebar goes on top */
  .game-layout {
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 0;
  }

  #sidebar {
    order: -1;
    flex-direction: row;
    width: 100%;
    height: 76px;
    flex-shrink: 0;
    gap: 0;
    border-bottom: 1px solid var(--border);
  }

  /* Remove individual panel borders / radii inside the top bar */
  #sidebar .panel {
    border-radius: 0;
    border: none;
  }

  /* Score panel: items flow in a row */
  .score-panel {
    flex: none;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.2rem 0.45rem;
    padding: 0.3rem 0.55rem;
    border-right: 1px solid var(--border);
  }
  .score-panel .label { margin-bottom: 0; font-size: 0.52rem; }
  .score-value  { font-size: 0.95rem; line-height: 1; margin-bottom: 0; }
  .level-value  { font-size: 0.9rem;  margin-bottom: 0; }
  #next-canvas  { margin-top: 0; }

  /* Commentary panel: compact horizontal strip */
  .commentary-panel {
    flex: 1;
    flex-direction: row;
    align-items: center;
    padding: 0.3rem 0.55rem;
    gap: 0.35rem;
    overflow: hidden;
  }
  .p-avatar { font-size: 1.2rem; flex-shrink: 0; }
  .p-name-label { display: none; }
  .commentary-bubble {
    font-size: 0.65rem;
    min-height: auto;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  /* Hide keyboard controls */
  .controls-mini { display: none; }

  /* Board canvas: center in the remaining space */
  #board-canvas {
    margin: auto;
    border: none;
    border-radius: 0;
  }
}
