/* =========================================================
   PhoneDuel — Dark Minimalist Theme (Catppuccin Mocha / Dracula)
   ========================================================= */

:root {
  --bg-crust: #11111b;
  --bg-mantle: #181825;
  --bg-base: #1e1e2e;
  --bg-surface0: #262738;
  --bg-surface1: #313244;
  --bg-surface2: #45475a;

  --border: rgba(166, 173, 200, 0.14);
  --border-strong: rgba(203, 166, 247, 0.35);

  --text-primary: #cdd6f4;
  --text-secondary: #a6adc8;
  --text-muted: #7f849c;

  --mauve: #cba6f7;
  --mauve-strong: #b48ef2;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --peach: #fab387;
  --red: #f38ba8;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.45);

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #202036 0%, var(--bg-crust) 68%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* --- Views --- */

.view {
  display: none;
  width: 100%;
  height: 100dvh;
}

.view.active {
  display: flex;
}

/* --- Toast Notifications --- */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  background: rgba(30, 30, 46, 0.96);
  border: 1px solid var(--border);
  border-left: 3px solid var(--mauve);
  color: var(--text-primary);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  animation: toastIn 0.22s ease-out;
}

.toast.toast-success { border-left-color: var(--green); }
.toast.toast-warning { border-left-color: var(--yellow); }
.toast.toast-error { border-left-color: var(--red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Shared Cards, Inputs, Buttons --- */

.card {
  background: rgba(30, 30, 46, 0.86);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

.field-label,
.meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.text-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-mantle);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.text-input:focus {
  border-color: var(--mauve);
  box-shadow: 0 0 0 3px rgba(203, 166, 247, 0.16);
}

.text-input::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-full {
  width: 100%;
}

.btn-sm {
  height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: linear-gradient(135deg, var(--mauve) 0%, var(--blue) 100%);
  color: #11111b;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--bg-surface1);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface2);
  border-color: rgba(205, 214, 244, 0.25);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.icon-sm {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(49, 50, 68, 0.7);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* =========================================================
   1. LANDING VIEW
   ========================================================= */

#view-landing {
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.landing-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.brand-header {
  text-align: center;
}

.brand-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(203, 166, 247, 0.15), rgba(137, 180, 250, 0.08));
  border: 1px solid rgba(203, 166, 247, 0.28);
  color: var(--text-primary);
}

.brand-logo svg {
  width: 32px;
  height: 32px;
}

.brand-title {
  margin: 0;
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-title span,
.brand-mini span {
  background: linear-gradient(135deg, var(--mauve), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-subtitle {
  margin: 6px 0 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.landing-card {
  width: 100%;
  padding: 24px;
}

.invite-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: rgba(137, 180, 250, 0.12);
  border: 1px solid rgba(137, 180, 250, 0.3);
  font-size: 0.84rem;
  color: var(--blue);
}

.invite-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row {
  display: flex;
  gap: 10px;
}

.code-input {
  flex: 1;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
}

.form-error {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(243, 139, 168, 0.12);
  border: 1px solid rgba(243, 139, 168, 0.35);
  color: var(--red);
  font-size: 0.84rem;
}

.landing-footer {
  display: flex;
  justify-content: center;
}

/* =========================================================
   2. LOBBY VIEW
   ========================================================= */

#view-lobby {
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}

.lobby-shell {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-mini {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.lobby-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.room-code-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.room-code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.room-code-display {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--mauve);
  line-height: 1;
}

.players-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-mantle);
  border: 1px solid var(--border);
  min-width: 0;
}

.player-slot.empty {
  border-style: dashed;
  opacity: 0.72;
}

.player-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(203, 166, 247, 0.25), rgba(137, 180, 250, 0.2));
  border: 1px solid rgba(203, 166, 247, 0.3);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--mauve);
  flex-shrink: 0;
}

.player-slot.empty .player-avatar {
  background: var(--bg-surface0);
  border-color: var(--border);
  color: var(--text-muted);
}

.player-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.player-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.badge {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.badge-host {
  background: rgba(249, 226, 175, 0.16);
  color: var(--yellow);
}

.badge-you {
  background: rgba(137, 180, 250, 0.16);
  color: var(--blue);
}

.vs-divider {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 4px 6px;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-mantle);
  border: 1px solid var(--border);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.setting-desc {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface0);
  border: 1px solid var(--border);
}

.seg-btn {
  min-width: 44px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn.active {
  background: var(--mauve);
  color: #11111b;
}

.seg-btn:disabled {
  cursor: default;
  opacity: 0.75;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--bg-surface1);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.18s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  transition: transform 0.18s ease, background 0.18s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: rgba(203, 166, 247, 0.35);
  border-color: var(--mauve);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: var(--mauve);
}

.toggle-switch input:disabled + .toggle-track {
  cursor: default;
  opacity: 0.65;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guest-note {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* =========================================================
   3. GAME VIEW (FULL-VIEWPORT, ZERO SCROLL)
   ========================================================= */

.game-view {
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.game-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(24, 24, 37, 0.92);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-shrink: 0;
}

.hud-player {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hud-me {
  align-items: flex-start;
}

.hud-opp {
  align-items: flex-end;
  text-align: right;
}

.hud-player-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
}

.hud-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(137, 180, 250, 0.16);
  color: var(--blue);
}

.opp-ping {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(243, 139, 168, 0.18);
  color: var(--red);
  animation: fadePop 0.2s ease-out;
}

.hud-score {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 240px;
}

.hud-round-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-round-pill,
.hud-points-pill,
.hud-hardcore-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.hud-round-pill {
  background: var(--bg-surface1);
  color: var(--text-primary);
}

.hud-points-pill {
  background: rgba(166, 227, 161, 0.14);
  color: var(--green);
}

.hud-hardcore-pill {
  background: rgba(243, 139, 168, 0.18);
  color: var(--red);
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.hud-timer {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  min-width: 54px;
  text-align: right;
  color: var(--text-primary);
}

.hud-timer.warn { color: var(--yellow); }
.hud-timer.danger { color: var(--red); }

.timer-bar-bg {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-surface1);
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--mauve));
  transition: background-color 0.25s ease;
}

.timer-bar-fill.warn { background: var(--yellow); }
.timer-bar-fill.danger { background: var(--red); }

/* --- 360 Stage --- */

.stage-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-canvas {
  display: block;
  cursor: grab;
  user-select: none;
}

.viewer-canvas.is-dragging {
  cursor: grabbing;
}

.viewer-canvas[data-mode="pan"] {
  cursor: move;
}

.viewer-canvas.hardcore-fallback {
  filter: grayscale(1) contrast(1.85) brightness(0.28);
}

.stage-top-overlays {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  width: min(620px, calc(100% - 28px));
  pointer-events: none;
}

.brand-match-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(249, 226, 175, 0.16);
  border: 1px solid rgba(249, 226, 175, 0.55);
  color: var(--yellow);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  animation: fadePop 0.2s ease-out;
}

.brand-match-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 10px var(--yellow);
}

.hint-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(30, 30, 46, 0.9);
  border: 1px solid rgba(137, 180, 250, 0.36);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  font-size: 0.85rem;
  text-align: center;
  animation: slideDown 0.24s ease-out;
}

.hint-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(137, 180, 250, 0.18);
  color: var(--blue);
}

.hint-text {
  color: var(--text-primary);
  font-weight: 500;
}

.preload-overlay,
.reveal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

.preload-overlay {
  background: rgba(17, 17, 27, 0.72);
  backdrop-filter: blur(6px);
}

.preload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 30px;
  border-radius: var(--radius-md);
  background: rgba(30, 30, 46, 0.95);
  border: 1px solid var(--border);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--bg-surface2);
  border-top-color: var(--mauve);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.preload-text {
  font-weight: 700;
  font-size: 0.98rem;
}

.preload-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.reveal-overlay {
  pointer-events: none;
  align-items: flex-end;
  padding-bottom: 18px;
}

.reveal-card {
  pointer-events: auto;
  width: min(480px, calc(100% - 28px));
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: rgba(24, 24, 37, 0.94);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  text-align: center;
  animation: slideUp 0.25s ease-out;
}

.reveal-status {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 4px;
}

.reveal-status.win { color: var(--green); }
.reveal-status.loss { color: var(--red); }
.reveal-status.timeout { color: var(--yellow); }

.reveal-phone-name {
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.reveal-phone-specs {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.reveal-meta {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--mauve);
}

.viewer-help {
  position: absolute;
  left: 16px;
  bottom: 12px;
  font-size: 0.73rem;
  color: var(--text-muted);
  pointer-events: none;
  background: rgba(17, 17, 27, 0.55);
  padding: 4px 9px;
  border-radius: 6px;
}

.viewer-controls {
  position: absolute;
  right: 16px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(24, 24, 37, 0.82);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.ctrl-btn {
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: var(--bg-surface1);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.ctrl-btn:hover {
  background: var(--bg-surface2);
}

.ctrl-btn.active {
  background: var(--mauve);
  color: #11111b;
}

.ctrl-readout {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
}

/* --- Bottom Guess Dock & Autocomplete --- */

.guess-dock {
  padding: 12px 18px 16px;
  background: rgba(24, 24, 37, 0.94);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 25;
}

.guess-inner {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

.autocomplete-list {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: rgba(30, 30, 46, 0.98);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
  padding: 6px;
  z-index: 40;
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-primary);
  transition: background 0.1s ease;
}

.ac-item:hover,
.ac-item.active {
  background: rgba(203, 166, 247, 0.16);
}

.ac-item.guessed {
  opacity: 0.45;
  text-decoration: line-through;
}

.ac-brand {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
}

.ac-highlight {
  color: var(--mauve);
  font-weight: 700;
}

.guess-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-mantle);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.guess-box:focus-within {
  border-color: var(--mauve);
  box-shadow: 0 0 0 3px rgba(203, 166, 247, 0.14);
}

.guess-box.cooldown {
  border-color: rgba(243, 139, 168, 0.6);
}

.guess-box.shake {
  animation: shakeX 0.36s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeX {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.cooldown-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0%;
  background: var(--red);
  pointer-events: none;
}

.guess-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.96rem;
  outline: none;
}

.guess-input::placeholder {
  color: var(--text-muted);
}

.guess-input:disabled {
  color: var(--text-muted);
}

.btn-guess {
  height: 38px;
  padding: 0 18px;
  border-radius: 9px;
}

.guess-status-line {
  min-height: 18px;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.guess-status-line.error { color: var(--red); }
.guess-status-line.warn { color: var(--yellow); }

/* =========================================================
   4. MATCH SUMMARY VIEW
   ========================================================= */

#view-summary {
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}

.summary-shell {
  width: 100%;
  max-width: 700px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.summary-card {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100dvh - 40px);
}

.summary-header {
  text-align: center;
}

.summary-headline {
  margin: 6px 0 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.summary-headline.win { color: var(--green); }
.summary-headline.loss { color: var(--red); }
.summary-headline.draw { color: var(--yellow); }

.summary-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-player-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-mantle);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-player-card.winner {
  border-color: rgba(166, 227, 161, 0.45);
  background: linear-gradient(180deg, rgba(166, 227, 161, 0.08), rgba(24, 24, 37, 0.95));
}

.sp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sp-name {
  font-weight: 700;
  font-size: 1rem;
}

.sp-score {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--mauve);
}

.sp-stats {
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.summary-table-wrap {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-mantle);
  max-height: 290px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.summary-table th,
.summary-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(166, 173, 200, 0.08);
}

.summary-table th {
  position: sticky;
  top: 0;
  background: var(--bg-surface0);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.summary-table .num {
  text-align: right;
  font-family: var(--font-mono);
}

.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.summary-actions .btn {
  min-width: 150px;
}

/* --- Animations --- */

@keyframes fadePop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive Mobile Layout --- */

@media (max-width: 680px) {
  .players-grid {
    grid-template-columns: 1fr;
  }

  .vs-divider {
    text-align: center;
  }

  .game-hud {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    padding: 8px 12px;
    gap: 6px;
  }

  .hud-center {
    grid-column: 1 / -1;
    order: -1;
    min-width: 0;
    width: 100%;
  }

  .viewer-help {
    display: none;
  }

  .viewer-controls {
    right: 10px;
    bottom: 8px;
  }

  .guess-dock {
    padding: 10px 12px 12px;
  }

  .summary-players {
    grid-template-columns: 1fr;
  }
}
