@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&display=swap');

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

/* Variables */
:root {
  --bg:            #0F172A;
  --surface:       #1E293B;
  --border:        #334155;
  --accent:        #B91C1C;
  --accent-hover:  #DC2626;
  --accent-bg:     rgba(185, 28, 28, 0.12);
  --accent-border: rgba(185, 28, 28, 0.35);
  --text:          #E5E7EB;
  --text-muted:    #94A3B8;
  --success:       #4ADE80;
  --error:         #F87171;
  --radius:        10px;
  --max-width:     480px;
  --serif:         'Playfair Display', Georgia, serif;
  --sans:          'Playfair Display', Georgia, serif;
}

/* Base */
html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body.has-bg {
  --hero-bg: none;
  background:
    linear-gradient(to bottom, rgba(15,23,42,0.6) 0%, rgba(15,23,42,0.88) 55%, rgba(15,23,42,1) 100%),
    var(--hero-bg) center top / cover no-repeat fixed;
  background-color: var(--bg);
}

/* ─── Shared page layout ─── */

main.landing,
main.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.75rem 1.5rem max(4.5rem, calc(2rem + env(safe-area-inset-bottom, 0px)));
  gap: 2rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

main.landing {
  gap: 3rem;
  padding-top: 2rem;
}

/* Page header (back link + small logo) */
.page-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-family: var(--sans);
}

.logo-small {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.25px;
  color: var(--text);
}

/* ─── Landing hero ─── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  padding-top: 1rem;
}

/* Logo image (landing page) */
.logo-img {
  width: min(300px, 90vw);
  border-radius: 14px;
  filter: drop-shadow(0 0 24px rgba(185,28,28,0.35)) drop-shadow(0 6px 20px rgba(0,0,0,0.7));
}

/* Text logo fallback (not currently used) */
.logo {
  font-family: var(--serif);
  font-size: clamp(3.5rem, 16vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1;
}

.tagline {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  line-height: 1.35;
}

.description {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 300px;
}

.subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ─── How it works ─── */

.how-it-works { width: 100%; }

.how-it-works h2 {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  text-align: center;
}

.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.step-number {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-text {
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
}

/* ─── Buttons ─── */

.btn-primary {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.85rem 2.5rem;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 400;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary.btn-full {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 0;
  padding: 0.85rem 1rem;
}

.btn-primary:active {
  background: var(--accent-hover);
  transform: scale(0.98);
}

@media (hover: hover) {
  .btn-primary:hover { background: var(--accent-hover); }
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.7rem 1rem;
  background: transparent;
  color: var(--text);
  border: 1px solid #475569;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary.btn-full {
  display: block;
  width: 100%;
  text-align: center;
  white-space: normal;
}

.btn-secondary:active {
  background: rgba(255,255,255,0.06);
  border-color: #64748B;
}

@media (hover: hover) {
  .btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    border-color: #64748B;
  }
}

/* ─── Card ─── */

.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  margin-bottom: 1.5rem;
}

.form-title {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

/* ─── Form fields ─── */

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

.field label {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="email"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--sans);
  padding: 0.8rem 1rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.field--error input { border-color: var(--accent); }

.field-error {
  font-size: 0.85rem;
  color: var(--error);
}

.field-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.optional {
  font-weight: 400;
  color: var(--text-muted);
}

/* Checkbox field */
.field--checkbox { gap: 0.5rem; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── Lobby ─── */

.lobby-label {
  font-size: 0.82rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.copy-row { display: flex; gap: 0.5rem; }

.copy-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--sans);
  padding: 0.6rem 0.85rem;
  outline: none;
  min-width: 0;
}

/* Card header row */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Player roster */
.player-roster {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.65rem 0.75rem 0.65rem 1rem;
}

.roster-name {
  font-size: 1rem;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-remove:active {
  color: var(--error);
  background: var(--accent-bg);
}

@media (hover: hover) {
  .btn-remove:hover {
    color: var(--error);
    background: var(--accent-bg);
  }
}

/* Add player inline form */
.add-player-form {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.input-row { display: flex; gap: 0.5rem; }

.input-row input { flex: 1; min-width: 0; }

.btn-add {
  padding: 0.8rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-add:active { background: var(--accent-hover); }

@media (hover: hover) {
  .btn-add:hover { background: var(--accent-hover); }
}

/* Start card */
.start-card { gap: 1rem; }

.start-hint {
  font-size: 0.95rem;
  text-align: center;
}

.start-hint.muted { color: var(--text-muted); }

/* Settings summary */
.settings-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dot { opacity: 0.4; }

.lobby-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Game page ─── */

.game-page {
  gap: 0;
  padding-top: 1.25rem;
}

#scenario-content,
#defense-content,
#witness-content,
#twist-content,
#score-content {
  width: 100%;
}

/* Phase header */
.phase-header {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
}

.phase-label {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.25px;
  color: var(--text-muted);
}

.phase-title {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 6.5vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

/* Scenario / Case file */
.case-file {
  border-left: 3px solid var(--accent);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.case-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
}

.case-row {
  display: contents;
}

.case-label {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 0.1rem;
}

.case-value {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.case-section-heading {
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: -0.25rem;
}

.case-forlopp {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
}

.case-background {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.case-suspects-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.case-suspect {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.suspects-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.suspect-chip {
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  font-size: 1rem;
}

.suspect-chip--a {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
}

.suspect-chip--b {
  background: var(--accent-bg);
  color: #F87171;
  border: 1px solid var(--accent-border);
}

.vs {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.round-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

/* Transcript box */
.transcript-box {
  width: 100%;
  min-height: 4.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
  gap: 0.5rem;
}

.transcript-label {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.transcript-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  min-height: 1.5rem;
}

/* Speech loading spinner */
.speech-loading {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 0;
}

.speech-spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Verdict loading (score phase) */
.verdict-loading {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 3rem 0;
}

.verdict-gavel-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.verdict-gavel-svg {
  width: 100px;
  height: 100px;
  position: relative;
  z-index: 1;
}

.gavel-arm {
  transform-origin: 51px 82px;
  animation: gavel-strike 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
  fill: var(--accent);
}

.gavel-handle { fill: var(--text-muted); }
.gavel-block  { fill: var(--border); }

@keyframes gavel-strike {
  0%   { transform: rotate(-40deg); }
  35%  { transform: rotate(8deg); }
  55%  { transform: rotate(8deg); }
  90%  { transform: rotate(-40deg); }
  100% { transform: rotate(-40deg); }
}

.verdict-ripple {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%) scaleX(0.3);
  width: 70px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: verdict-ripple 2s ease-out infinite;
  animation-delay: 0.7s;
}

@keyframes verdict-ripple {
  0%   { transform: translateX(-50%) scaleX(0.3); opacity: 0; }
  8%   { transform: translateX(-50%) scaleX(1);   opacity: 0.55; }
  50%  { transform: translateX(-50%) scaleX(2.8); opacity: 0; }
  100% { transform: translateX(-50%) scaleX(2.8); opacity: 0; }
}

.verdict-loading-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-muted);
  animation: verdict-text-pulse 2s ease-in-out infinite;
}

@keyframes verdict-text-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* Button loading dots */
.btn-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
  animation: btn-pulse 1s ease-in-out infinite;
}

.btn-dots span:nth-child(2) { animation-delay: 0.18s; }
.btn-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes btn-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

.speech-loading-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-muted);
}

/* Scenario reminder */
.scenario-reminder {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.scenario-reminder-label {
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.scenario-reminder-text {
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
}

/* Timer */
.timer-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.timer-ring {
  position: relative;
  width: 148px;
  height: 148px;
}

.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 5;
}

.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s;
}

.timer-number {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  transition: color 0.3s;
}

.timer-number.timer--urgent { color: var(--error); }

.ring-fg.timer--urgent { stroke: var(--error); }

.timer-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.instruction-card p {
  font-size: 1rem;
  line-height: 1.6;
}

.instruction-card .text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Twist */
.twist-card {
  text-align: center;
  border-left: 3px solid var(--accent);
}

.twist-icon {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.twist-text {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.7;
  font-style: italic;
  color: var(--text);
}

/* Verdict */
.verdict-instruction {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

.verdict-choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.verdict-choices form { width: 100%; }

.verdict-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.verdict-btn:active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

@media (hover: hover) {
  .verdict-btn:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
  }
}

.verdict-name {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.verdict-tag {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--accent-border);
  border-radius: 4px;
}

/* Score screen */
.scoreboard-title {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.scoreboard {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: var(--bg);
}

.score-row--suspect {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.score-row--winner {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}

.score-name {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.medal {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--accent);
}

.score-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.score-change {
  font-size: 0.9rem;
  font-weight: 400;
  min-width: 2rem;
  text-align: right;
}

.score-up   { color: var(--success); }
.score-down { color: var(--error); }

.score-value {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: right;
}

.score-target {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}

/* Verdict reasoning */
.verdict-reasoning {
  border-left: 3px solid var(--accent);
}

.verdict-reasoning-text {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.75;
  color: var(--text);
}

/* Judge commentary */
.commentary {
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  padding: 0 0.5rem;
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

/* ─── Result screen ─── */

.result-winner {
  text-align: center;
  gap: 0.75rem;
  padding: 2.25rem 1.75rem;
}

.winner-label {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
}

.winner-name {
  font-family: var(--serif);
  font-size: clamp(2.25rem, 10vw, 3.5rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.winner-summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
