/* ===== RESET & TOKENS ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c1: #F2F5F4;   /* lightest — page background */
  --c2: #D6DCDA;   /* light — cards, secondary bg */
  --c3: #AEB8B5;   /* mid — borders, dividers */
  --c4: #6A7774;   /* mid-dark — muted text */
  --c5: #2d3534;   /* darkest — primary text, buttons */

  --bg:          var(--c1);
  --card:        var(--c2);
  --card-border: var(--c3);
  --text:        var(--c5);
  --muted:       var(--c4);

  --green:       #2a7a4b;
  --green-bg:    #d4edda;
  --red:         #8b1a1a;
  --red-bg:      #f5d0d0;

  --r:   2px;   /* sharp global radius */
  --r2:  4px;   /* button radius */
  --shadow: 3px 3px 0 var(--c3);
}

html, body {
  height: 100%;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg);
  background-image: url('SVDG.png');
  background-size: cover;
  background-position: top center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== VIEWS ===== */
.view {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 28px 22px max(28px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
}
.view.active { display: flex; animation: fadeUp .2s ease both; }

/* Game views that need their own solid background */
#view-single,
#view-username-game { background: var(--bg); }

/* Face-safe spacer: pushes content below the face zone (~top 44% of screen) */
.face-spacer { flex: 1; min-height: 44vh; pointer-events: none; }

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

/* ===== BRAND / LANDING ===== */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4px 0 0;
  flex-shrink: 0;
}
.brand-name {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--c5);
  text-shadow: 0 1px 8px rgba(242,245,244,0.9), 0 0 20px rgba(242,245,244,0.7);
}
.brand-name span { color: var(--c4); }

.brand-subtitle {
  font-family: 'Fraunces', serif;
  font-size: 15px;
  font-style: italic;
  font-weight: 500;
  color: var(--c4);
  margin-top: 4px;
  text-shadow: 0 1px 6px rgba(242,245,244,0.9);
}

/* Memorial strip */
.memorial {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 2px;
  background: rgba(45,53,52,0.82);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--r);
  padding: 12px 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.memorial-candle {
  font-size: 18px;
  color: #d4a84b;
  flex-shrink: 0;
  opacity: 0.9;
}
.memorial-text {
  font-family: 'Fraunces', serif;
  font-size: 13px;
  font-style: italic;
  font-weight: 500;
  color: rgba(242,245,244,0.92);
  line-height: 1.55;
  text-align: center;
  flex: 1;
  letter-spacing: 0.01em;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 14px;
}

/* ===== FORM ELEMENTS ===== */
.field-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--c4);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.field-input,
.field-textarea {
  width: 100%;
  background: var(--c1);
  border: 1.5px solid var(--c3);
  border-radius: var(--r);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  padding: 13px 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.field-input:focus,
.field-textarea:focus {
  border-color: var(--c5);
  box-shadow: var(--shadow);
}
.field-input::placeholder,
.field-textarea::placeholder { color: var(--c3); }
.field-textarea { resize: none; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: var(--r2);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 14px 22px;
  transition: box-shadow .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  letter-spacing: 0.01em;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--c3) !important; }

.btn-primary {
  background: var(--c5);
  color: var(--c1);
  border-color: var(--c5);
  box-shadow: var(--shadow);
}
.btn-primary:hover { box-shadow: 5px 5px 0 var(--c4); }

.btn-outline {
  background: transparent;
  border-color: var(--c5);
  color: var(--c5);
  box-shadow: var(--shadow);
}
.btn-outline:hover { box-shadow: 5px 5px 0 var(--c4); background: var(--c2); }

.btn-green {
  background: var(--c5);
  color: var(--c1);
  border-color: var(--c5);
  box-shadow: var(--shadow);
}
.btn-green:hover { box-shadow: 5px 5px 0 var(--c4); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--c4);
  box-shadow: none;
}
.btn-ghost:hover { color: var(--c5); }
.btn-ghost:active { transform: none; box-shadow: none !important; }

.btn-glow {
  background: var(--c5);
  color: var(--c1);
  border-color: var(--c5);
  box-shadow: var(--shadow);
}
.btn-glow:hover { box-shadow: 5px 5px 0 var(--c4); }

.btn-dark {
  background: rgba(0,0,0,0.25);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}
.btn-dark:hover { background: rgba(0,0,0,0.35); }

.btn-full  { width: 100%; }
.btn-large { padding: 17px 24px; font-size: 18px; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.btn-row .btn { flex: 1; }

/* ===== LOBBY ===== */
.lobby-header { padding: 4px 0 4px; margin-bottom: 0; }

.room-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 12px;
  background: rgba(242,245,244,0.88);
  border: 1.5px solid var(--c3);
  border-radius: var(--r);
  padding: 6px 14px 6px 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.room-badge-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--c4);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.room-badge-code {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 900;
  color: var(--c5);
  letter-spacing: -0.01em;
  text-shadow: 0 1px 6px rgba(242,245,244,0.85);
}
.copy-hint {
  font-size: 10px;
  color: var(--c4);
  opacity: 0.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.room-badge:hover .copy-hint { opacity: 1; }

.stats-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1.5px solid var(--c3);
  border-radius: var(--r);
  overflow: hidden;
  width: fit-content;
  background: rgba(242,245,244,0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 20px;
  line-height: 1;
}
.stat:first-child { border-right: 1.5px solid var(--c3); }
.stat-val  { font-family: 'Fraunces', serif; font-size: 28px; font-weight: 800; }
.stat-key  { font-size: 10px; color: var(--c4); text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; }
.stat-divider { display: none; }

#host-start-section { margin-top: 8px; }

.pulse-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.pulse-dot {
  width: 7px; height: 7px;
  background: var(--c5);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.7); }
}

/* ===== MODE MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45,53,52,0.45);
  backdrop-filter: blur(4px);
}
.modal-sheet {
  position: relative;
  background: var(--c1);
  border-radius: 0;
  border-top: 2px solid var(--c5);
  padding: 28px 22px max(40px, env(safe-area-inset-bottom));
  width: 100%;
  animation: slideUp .25s cubic-bezier(.22,1,.36,1) both;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-title {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--c5);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--c2);
  border: 1.5px solid var(--c3);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  box-shadow: var(--shadow);
}
.mode-btn:hover { border-color: var(--c5); box-shadow: 5px 5px 0 var(--c4); }
.mode-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--c3); }

.mode-info  { flex: 1; }
.mode-name  { font-size: 17px; font-weight: 700; color: var(--c5); margin-bottom: 2px; }
.mode-desc  { font-size: 13px; color: var(--c4); line-height: 1.4; }
.mode-arrow { font-size: 20px; color: var(--c4); font-weight: 700; }

/* ===== USERNAME ENTRY ===== */
.page-content {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 0 0 auto;
}
.page-title {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 800;
  text-align: center;
}

.center-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0 8px;
  gap: 8px;
}
.checkmark {
  font-size: 40px;
  font-weight: 700;
  color: var(--c5);
  line-height: 1;
  animation: popIn .3s cubic-bezier(.18,.89,.32,1.28) both;
}
@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.section-divider { height: 1.5px; background: var(--c3); margin: 24px 0 20px; }
.section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--c4);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 14px;
}

.player-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.player-chip {
  background: var(--c1);
  border: 1.5px solid var(--c5);
  border-radius: var(--r);
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c5);
  box-shadow: 2px 2px 0 var(--c3);
  animation: fadeUp .2s ease both;
}

/* ===== GAME: SHARED FULL-SCREEN ===== */
.game-full {
  justify-content: space-between;
  padding-top: 52px;
  padding-bottom: max(52px, env(safe-area-inset-bottom));
  background: var(--bg);
}

.question-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.q-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--c4);
  text-transform: uppercase;
  margin-bottom: 20px;
  border-left: 3px solid var(--c5);
  padding-left: 10px;
}
.green-eyebrow { color: rgba(255,255,255,0.65); border-left-color: rgba(255,255,255,0.5); }

.q-text {
  font-family: 'Fraunces', serif;
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--c5);
}

.assigned-pill {
  display: inline-block;
  background: var(--c2);
  border: 1.5px solid var(--c5);
  border-radius: var(--r);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c5);
  margin-bottom: 20px;
  align-self: flex-start;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 2px 2px 0 var(--c3);
}

.game-footer { flex-shrink: 0; padding-top: 28px; }

.remaining-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c4);
  text-align: center;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.remaining-dark { color: rgba(0,0,0,0.35); }

/* ===== GREEN SCREEN ===== */
.green-screen { background: #1a4d32; }
.green-screen .q-text    { color: #e8f5ee; }
.green-screen .q-eyebrow { color: rgba(232,245,238,0.55); border-left-color: rgba(232,245,238,0.4); }
.green-screen .remaining-label { color: rgba(232,245,238,0.5); }

/* ===== BACK BUTTON ===== */
.btn-back {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  background: none;
  border: none;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  color: var(--c4);
  padding: 4px 6px;
  z-index: 5;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--r);
}
.btn-back:active { opacity: 0.5; }
.btn-back-light { color: rgba(255,255,255,0.55); }

/* ===== RED SCREEN ===== */
.red-screen { background: #4d1a1a; }
.red-eyebrow { color: rgba(245,232,232,0.45); border-left-color: rgba(245,232,232,0.3); }
.red-q-text  { color: rgba(245,232,232,0.9); }
.red-phrase  {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 800;
  font-style: italic;
  color: #f5e8e8;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.red-sub   { font-size: 15px; color: rgba(245,232,232,0.55); font-weight: 500; }

/* ===== CENTER FULL ===== */
.center-full {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}
.center-full h2 {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--c5);
}

/* ===== GAME OVER ===== */
.gameover-title {
  font-family: 'Fraunces', serif;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--c5);
  line-height: 1.0;
}

/* ===== MISC ===== */

.muted       { color: var(--c4); font-size: 15px; line-height: 1.5; }
.error-text  { color: #8b1a1a; font-size: 13px; min-height: 16px; margin-bottom: 4px; font-weight: 600; }
.success-text { color: var(--c5); font-size: 13px; min-height: 16px; font-weight: 600; }

.hidden { display: none !important; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--c5);
  color: var(--c1);
  font-size: 13px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--r2);
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
}
.toast.hidden { display: none; }
