/* ============================================================
   THE HOLLOW VILLAGE — Werewolf Prototype
   Aesthetic: Luxury / Refined · Noir-Parlor
   Fonts: Cormorant Garamond (display) · Spectral (body)
   Palette: Ink #0E0B0A · Amber #E8A33D · Gold #C9A227
            Garnet #8B2E2E · Parchment #F2E9D8
   ============================================================ */

:root {
  --ink:        #0E0B0A;
  --ink-2:      #171210;
  --ink-3:      #221a16;
  --amber:      #E8A33D;
  --gold:       #C9A227;
  --garnet:     #8B2E2E;
  --parchment:  #F2E9D8;
  --text:       #EADFCB;
  --text-dim:   #9A8C77;
  --hair:       rgba(201,162,39,0.28);
  --hair-soft:  rgba(201,162,39,0.14);

  --display: "Cormorant Garamond", Georgia, serif;
  --body:    "Spectral", Georgia, serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* Day theme override */
body.theme-day {
  --ink:        #EFE4CE;
  --ink-2:      #E4D6BB;
  --ink-3:      #D8C7A6;
  --text:       #2A1F16;
  --text-dim:   #6B5A43;
  --hair:       rgba(138,46,46,0.30);
  --hair-soft:  rgba(138,46,46,0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }
body {
  font-family: var(--body);
  color: var(--text);
  /* Mobile-safe: centered radial (no off-center bleed), covers full viewport incl. notches */
  background:
    radial-gradient(120% 120% at 50% 30%, #1a1411 0%, var(--ink) 55%, #060403 100%) fixed;
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  transition: background 1.1s ease, color 0.9s ease;
  -webkit-font-smoothing: antialiased;
}
body.theme-day {
  background:
    radial-gradient(120% 120% at 50% 25%, #FBF4E2 0%, var(--ink) 60%, #D9C7A2 100%) fixed;
}

/* ---- Atmospheric layers ---- */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(120% 100% at 50% 45%, transparent 42%, rgba(0,0,0,0.55) 100%);
  transition: opacity 1s ease;
}
body.theme-day .vignette { opacity: 0.22; }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.candle-glow {
  position: fixed; left: 50%; bottom: -22vh; transform: translateX(-50%);
  width: 80vw; max-width: 720px; height: 55vh; pointer-events: none; z-index: 1;
  background: radial-gradient(closest-side, rgba(232,163,61,0.22), transparent 70%);
  filter: blur(20px);
  animation: flicker 5.5s ease-in-out infinite;
}
body.theme-day .candle-glow { background: radial-gradient(closest-side, rgba(232,163,61,0.10), transparent 70%); }
@keyframes flicker {
  0%,100% { opacity: 0.85; transform: translateX(-50%) scale(1); }
  45%     { opacity: 1;    transform: translateX(-50%) scale(1.04); }
  70%     { opacity: 0.7;  transform: translateX(-49%) scale(0.98); }
}

/* Diagonal phase sweep */
.phase-sweep {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  transform: translateY(-100%) skewY(-8deg);
  background: linear-gradient(120deg, var(--garnet) 0%, var(--ink-3) 60%, var(--ink) 100%);
  opacity: 0;
}
.phase-sweep.run { animation: sweep 1.05s cubic-bezier(.7,0,.3,1) forwards; }
@keyframes sweep {
  0%   { opacity: 0; transform: translateY(-100%) skewY(-8deg); }
  35%  { opacity: 0.96; }
  100% { opacity: 0; transform: translateY(100%) skewY(-8deg); }
}

.hidden { display: none !important; }

/* ================= SETUP SCREEN ================= */
.screen { position: relative; z-index: 5; min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: calc(2rem + var(--safe-t)) 1.2rem calc(2rem + var(--safe-b)); }
.setup-card { width: min(560px, 100%); background: linear-gradient(160deg, rgba(23,18,16,0.92), rgba(14,11,10,0.92));
  border: 1px solid var(--hair); border-radius: 4px; padding: 2.4rem 2.2rem;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.setup-kicker { font-family: var(--display); font-style: italic; color: var(--gold); letter-spacing: 0.08em; font-size: 1rem; text-align: center; }
.setup-title { font-family: var(--display); font-weight: 700; font-size: 3.2rem; line-height: 1; text-align: center; color: var(--text); margin: 0.4rem 0 0.7rem; }
.setup-sub { text-align: center; color: var(--text-dim); font-size: 1.02rem; line-height: 1.6; margin-bottom: 1.8rem; }
.setup-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.setup-label { font-family: var(--display); font-size: 1.2rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text); }
.count-control { display: flex; align-items: center; gap: 0.6rem; }
.step-btn { width: 42px; height: 42px; border-radius: 3px; border: 1px solid var(--hair);
  background: transparent; color: var(--amber); cursor: pointer; font-size: 1rem; transition: all 0.25s ease; }
.step-btn:hover { border-color: var(--gold); background: rgba(201,162,39,0.08); }
#playerCount { width: 64px; height: 42px; text-align: center; font-family: var(--display); font-weight: 700;
  font-size: 1.5rem; color: var(--amber); background: var(--ink); border: 1px solid var(--hair); border-radius: 3px; }
#playerCount::-webkit-outer-spin-button, #playerCount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dist-preview { text-align: center; color: var(--text-dim); font-size: 0.92rem; margin: 0.3rem 0 1.4rem; font-style: italic; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 1.6rem; }
.name-grid input { width: 100%; padding: 0.6rem 0.7rem; font-family: var(--body); font-size: 0.95rem;
  color: var(--text); background: var(--ink); border: 1px solid var(--hair); border-radius: 3px; }
.name-grid input::placeholder { color: var(--text-dim); }
.name-grid input:focus { outline: none; border-color: var(--gold); }
.setup-cta { text-align: center; }

/* ================= GAME GRID ================= */
.stage-grid {
  position: relative; z-index: 5;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh; min-height: 100dvh;
  padding: calc(2.4rem + var(--safe-t)) 3rem calc(3rem + var(--safe-b));
}

.hud {
  grid-column: 1 / 8; grid-row: 1;
  display: flex; align-items: center; gap: 2rem;
  padding-bottom: 1.4rem; border-bottom: 1px solid var(--hair); margin-bottom: 2.2rem;
}
.hud-mark { display: flex; align-items: center; gap: 0.7rem; }
.hud-mark .icon { width: 30px; height: 30px; fill: none; stroke: var(--gold); stroke-width: 1.4; filter: drop-shadow(0 0 6px rgba(201,162,39,0.4)); }
.hud-title { font-family: var(--display); font-weight: 700; font-size: 1.55rem; letter-spacing: 0.04em; color: var(--text); }
.hud-meta { display: flex; flex-direction: column; gap: 0.15rem; }
.hud-phase { display: flex; align-items: center; gap: 0.55rem; font-family: var(--display); font-size: 1.15rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
.phase-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
body.theme-day .phase-dot { background: var(--garnet); box-shadow: 0 0 10px var(--garnet); }
.hud-round { font-size: 0.85rem; color: var(--text-dim); letter-spacing: 0.05em; }
.hud-actions { margin-left: auto; display: flex; gap: 0.6rem; }

.ghost-btn { font-family: var(--body); font-size: 0.82rem; letter-spacing: 0.06em; color: var(--text-dim);
  background: transparent; border: 1px solid var(--hair); padding: 0.5rem 0.9rem; border-radius: 2px;
  cursor: pointer; transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 0.45rem; }
.ghost-btn:hover { color: var(--amber); border-color: var(--gold); }
.ghost-btn i { font-size: 0.85rem; }

.scene { grid-column: 2 / 9; grid-row: 2; display: flex; align-items: center; padding-right: 2rem; }
.scene-inner { max-width: 540px; }
.scene-kicker { font-family: var(--display); font-style: italic; font-size: 1.05rem; color: var(--gold); letter-spacing: 0.06em; margin-bottom: 0.8rem; border-left: 2px solid var(--gold); padding-left: 0.8rem; }
.narrator-line { font-family: var(--display); font-style: italic; font-size: 1.2rem; line-height: 1.5; color: var(--amber);
  margin-bottom: 1.1rem; padding: 0.5rem 0 0.5rem 0.9rem; border-left: 2px solid var(--garnet); }
.scene-title { font-family: var(--display); font-weight: 700; font-size: 4.1rem; line-height: 0.98; letter-spacing: -0.01em; color: var(--text); margin-bottom: 1.1rem; text-shadow: 0 2px 30px rgba(0,0,0,0.5); }
.scene-body { font-size: 1.12rem; line-height: 1.75; color: var(--text-dim); max-width: 460px; margin-bottom: 2.2rem; }
.scene-cta { display: flex; gap: 1rem; flex-wrap: wrap; }

.cta { font-family: var(--display); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.06em; color: var(--ink);
  background: linear-gradient(135deg, var(--amber), var(--gold)); border: none; padding: 0.85rem 1.6rem; border-radius: 2px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.7rem; box-shadow: 0 8px 30px rgba(232,163,61,0.28); transition: transform 0.25s ease, box-shadow 0.25s ease; }
.cta:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(232,163,61,0.42); }
.cta i { font-size: 0.9rem; transition: transform 0.25s ease; }
.cta:hover i { transform: translateX(4px); }
.cta-ghost { background: transparent; color: var(--amber); border: 1px solid var(--gold); box-shadow: none; }
.cta-ghost:hover { background: rgba(201,162,39,0.10); box-shadow: none; }

/* Roster */
.roster { grid-column: 10 / 13; grid-row: 1 / 3; border-left: 1px solid var(--hair); padding: 0 0 0 1.6rem; margin-top: -0.4rem; display: flex; flex-direction: column; }
.roster-head { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 0.9rem; margin-bottom: 0.6rem; border-bottom: 1px solid var(--hair-soft); }
.roster-title { font-family: var(--display); font-size: 1.25rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.roster-count { font-family: var(--display); font-size: 1.5rem; color: var(--garnet); font-weight: 700; }
.roster-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; }
.player { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.7rem; border: 1px solid transparent; border-radius: 2px; cursor: pointer; position: relative; transition: all 0.3s ease; }
.player:hover { border-color: var(--hair); background: rgba(201,162,39,0.06); }
.player .avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; background: radial-gradient(circle at 35% 30%, var(--ink-3), var(--ink)); border: 1px solid var(--hair); display: grid; place-items: center; color: var(--gold); font-family: var(--display); font-weight: 700; font-size: 1rem; }
.player .pname { font-size: 0.98rem; color: var(--text); letter-spacing: 0.02em; }
.player .ptag { margin-left: auto; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.player.dead { opacity: 0.42; cursor: default; }
.player.dead .avatar { border-color: var(--garnet); color: var(--garnet); }
.player.dead .pname { text-decoration: line-through; }
.player.dead::after { content: "\2020"; position: absolute; right: 0.7rem; color: var(--garnet); font-family: var(--display); }
.player.selected { border-color: var(--gold); background: rgba(232,163,61,0.10); }
.player.selected .avatar { box-shadow: 0 0 0 2px var(--amber); }

/* ================= ROLE GATE (privacy) ================= */
.gate-veil { position: fixed; inset: 0; z-index: 45; display: none; align-items: center; justify-content: center;
  background: rgba(6,4,3,0.86); backdrop-filter: blur(8px); padding: 1.2rem; }
.gate-veil.show { display: flex; }
.gate { width: min(440px, 100%); max-height: 90vh; overflow-y: auto; background: linear-gradient(160deg, var(--ink-2), var(--ink)); border: 1px solid var(--gold); border-radius: 4px; padding: 2rem 1.8rem; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,0.7); }
.gate h2 { font-family: var(--display); font-weight: 700; font-size: 2.1rem; color: var(--amber); margin-bottom: 0.7rem; }
.gate > p { color: var(--text-dim); font-size: 0.98rem; line-height: 1.6; margin-bottom: 1.3rem; }
.gate-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.4rem; }
.gate-list li { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; border: 1px solid var(--hair); border-radius: 3px; cursor: pointer; transition: all 0.25s ease; }
.gate-list li:hover { border-color: var(--gold); background: rgba(201,162,39,0.07); }
.gate-list li.seen { opacity: 0.5; }
.gate-list li.seen .g-name { text-decoration: line-through; }
.gate-list .g-avatar { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--ink-3), var(--ink)); border: 1px solid var(--hair); display: grid; place-items: center; color: var(--gold); font-family: var(--display); font-weight: 700; }
.gate-list .g-name { font-family: var(--body); color: var(--text); flex: 1; text-align: left; }
.gate-list .g-status { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.gate-list li.seen .g-status { color: var(--gold); }
.gate-actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: center; }

/* ================= SINGLE ROLE REVEAL ================= */
.modal-veil, .drawer-veil, .banner-veil { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; background: rgba(6,4,3,0.8); backdrop-filter: blur(6px); }
.modal-veil.show, .banner-veil.show { display: flex; }
.drawer-veil.show { display: block; }
#revealCard .role-card { width: min(420px, 90vw); padding: 2.6rem 2.2rem; background: linear-gradient(160deg, var(--ink-2), var(--ink)); border: 1px solid var(--gold); border-radius: 4px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,0.7); animation: rise 0.5s cubic-bezier(.2,.8,.2,1); }
.reveal-prompt { color: var(--text-dim); font-size: 1rem; line-height: 1.55; margin-bottom: 1.4rem; }
.reveal-prompt b { color: var(--amber); }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; } }
.role-flourish { width: 70px; height: 2px; margin: 0 auto 1.4rem; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.role-eyebrow { font-family: var(--display); font-style: italic; color: var(--gold); letter-spacing: 0.1em; font-size: 1.05rem; margin-bottom: 0.4rem; }
.role-name { font-family: var(--display); font-weight: 700; font-size: 3rem; color: var(--amber); margin-bottom: 0.9rem; letter-spacing: 0.02em; }
.role-blurb { font-size: 1.05rem; line-height: 1.7; color: var(--text-dim); margin-bottom: 1.8rem; }
.role-card.wolf .role-name { color: var(--garnet); }
.role-card.seer .role-name { color: #6fb89c; }

/* ================= NARRATOR PEEK / CHRONICLE DRAWER ================= */
.drawer { position: absolute; right: 0; top: 0; height: 100%; width: min(420px, 92vw); background: linear-gradient(180deg, var(--ink-2), var(--ink)); border-left: 1px solid var(--gold); padding: 2rem 1.8rem; transform: translateX(100%); transition: transform 0.5s cubic-bezier(.3,.8,.3,1); display: flex; flex-direction: column; }
.drawer-veil.show .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--hair); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.drawer-head h3 { font-family: var(--display); font-weight: 600; font-size: 1.5rem; color: var(--text); letter-spacing: 0.04em; }
.narr-list { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.narr-list li { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem; border: 1px solid var(--hair-soft); border-radius: 3px; }
.narr-list .n-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; background: radial-gradient(circle at 35% 30%, var(--ink-3), var(--ink)); }
.narr-list .n-name { font-family: var(--body); color: var(--text); flex: 1; }
.narr-list .n-role { font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; }
.narr-list li.wolf .n-avatar, .narr-list li.wolf .n-role { color: var(--garnet); border-color: var(--garnet); }
.narr-list li.seer .n-avatar, .narr-list li.seer .n-role { color: #6fb89c; }
.narr-list li.dead { opacity: 0.5; }
.narr-list li.dead .n-name { text-decoration: line-through; }

.log-list { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 0.7rem; }
.log-list li { font-size: 0.95rem; line-height: 1.55; color: var(--text-dim); padding-left: 1rem; border-left: 2px solid var(--hair-soft); }
.log-list li .lg-phase { font-family: var(--display); color: var(--amber); letter-spacing: 0.05em; font-size: 0.8rem; text-transform: uppercase; }
.log-list li.death { border-left-color: var(--garnet); }
.log-list li.death .lg-phase { color: var(--garnet); }
.log-list li.banish { border-left-color: var(--gold); }

/* ================= END BANNER ================= */
.banner { text-align: center; width: min(520px, 90vw); padding: 3rem 2.5rem; background: linear-gradient(160deg, var(--ink-2), var(--ink)); border: 1px solid var(--gold); border-radius: 4px; box-shadow: 0 30px 80px rgba(0,0,0,0.7); animation: rise 0.6s; }
.banner-eyebrow { font-family: var(--display); font-style: italic; color: var(--gold); font-size: 1.1rem; margin-bottom: 0.6rem; }
.banner-title { font-family: var(--display); font-weight: 700; font-size: 3.4rem; color: var(--amber); margin-bottom: 1rem; }
.banner.win-village .banner-title { color: var(--amber); }
.banner.win-wolf .banner-title { color: var(--garnet); }
.banner-body { font-size: 1.1rem; line-height: 1.7; color: var(--text-dim); margin-bottom: 2rem; }

/* ================= RESPONSIVE ================= */
@media (max-width: 920px) {
  .stage-grid { grid-template-columns: 1fr; padding: calc(1.4rem + var(--safe-t)) 1.2rem calc(1.4rem + var(--safe-b)); gap: 1.4rem; min-height: 100dvh; }
  .hud { grid-column: 1; grid-row: auto; flex-wrap: wrap; gap: 0.9rem; margin-bottom: 1rem; }
  .hud-title { font-size: 1.3rem; }
  .hud-actions { margin-left: 0; width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .ghost-btn { flex: 1; justify-content: center; min-width: 96px; }
  .scene { grid-column: 1; grid-row: auto; padding-right: 0; align-items: flex-start; }
  .scene-title { font-size: 2.6rem; }
  .scene-body { font-size: 1.02rem; }
  .narrator-line { font-size: 1.05rem; }
  .roster { grid-column: 1; grid-row: auto; border-left: none; border-top: 1px solid var(--hair); padding: 1.2rem 0 0; }
  .roster-list { max-height: 42vh; }
  .player .pname { font-size: 1.05rem; }
}
@media (max-width: 560px) {
  .setup-card { padding: 1.8rem 1.3rem; }
  .setup-title { font-size: 2.4rem; }
  .scene-title { font-size: 2.1rem; }
  .banner-title { font-size: 2.4rem; }
  .role-name { font-size: 2.4rem; }
  .name-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-height: 720px) and (max-width: 920px) {
  .roster-list { max-height: 34vh; }
  .scene-title { font-size: 2rem; margin-bottom: 0.8rem; }
}

/* scrollbars */
.roster-list::-webkit-scrollbar, .log-list::-webkit-scrollbar, .narr-list::-webkit-scrollbar, .gate-veil .gate::-webkit-scrollbar { width: 5px; }
.roster-list::-webkit-scrollbar-thumb, .log-list::-webkit-scrollbar-thumb, .narr-list::-webkit-scrollbar-thumb { background: var(--hair); border-radius: 4px; }
