/* ===== Closing Time — styles ===== */
:root {
  --ink: #0c1018;
  --panel: rgba(14, 20, 30, 0.92);
  --panel-solid: #121826;
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8edf4;
  --muted: #9aa6b2;
  --amber: #f0b35b;
  --amber-deep: #d8932f;
  --blue: #5fb0ff;
  --green: #6ddf8e;
  --danger: #ff6b6b;
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#game { position: fixed; inset: 0; background: #000; }

/* Fixed-resolution stage, scaled to fit by JS */
#stage {
  position: absolute;
  left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform-origin: center center;
  background: var(--ink);
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.6);
}

#bg-layer, #sprite-layer, #scene-layer {
  position: absolute; inset: 0;
}
#bg-layer {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* swaps are instant; scene changes are smoothed by the black #fade overlay
     (a background-image crossfade ghosts badly with the photographic storefront) */
}

/* Sprite: waist-up portrait, lower-right, facing the (unseen) detective */
#sprite-layer { pointer-events: none; }
.sprite {
  position: absolute;
  right: 3%; bottom: 0;
  height: 100%;                 /* full-figure art, anchored to the floor */
  max-width: 44%;               /* keep clear of the centre on very wide sprites */
  object-fit: contain; object-position: bottom;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.55));
  animation: sprite-in 0.35s ease both;
}
@keyframes sprite-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== VN dialogue box ===== */
#vn-box {
  position: absolute;
  left: 4%; right: 4%; bottom: 3.5%;
  min-height: 168px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 28px 22px;
  backdrop-filter: blur(4px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
#vn-name {
  font-size: 22px; font-weight: 700; letter-spacing: 0.3px;
  margin-bottom: 8px;
}
#vn-text {
  font-size: 25px; line-height: 1.5; color: var(--text);
  min-height: 78px; white-space: pre-wrap;
}
#vn-box.narration #vn-text { font-style: italic; color: #c8d2dd; }
#vn-badge {
  position: absolute; right: 22px; top: -16px;
  background: var(--danger); color: #1a0606;
  font-size: 13px; font-weight: 800; letter-spacing: 1.5px;
  padding: 6px 12px; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(255, 107, 107, 0.4);
  animation: badge-in 0.28s ease both;
}
@keyframes badge-in { from { opacity: 0; transform: translateY(8px) scale(0.9); } to { opacity: 1; transform: none; } }
#vn-box.evidence { border-color: rgba(255, 107, 107, 0.65); box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,107,107,0.35); }
#vn-indicator {
  position: absolute; right: 22px; bottom: 14px;
  color: var(--amber); font-size: 18px; opacity: 0;
}
#vn-indicator.ready { opacity: 1; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(4px);} }

/* ===== Pause button ===== */
#pause-btn {
  position: absolute; top: 16px; right: 18px;
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 22, 0.7);
  color: var(--text);
  font-size: 14px; cursor: pointer;
  z-index: 30;
  transition: background 0.15s ease;
}
#pause-btn:hover { background: rgba(30, 40, 56, 0.9); }

#notes-btn {
  position: absolute; top: 16px; left: 18px;
  height: 44px; padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 22, 0.7);
  color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer;
  z-index: 30;
  transition: background 0.15s ease;
}
#notes-btn:hover { background: rgba(30, 40, 56, 0.9); }

/* ===== Overlays (Menu / Options / Pause) ===== */
#overlay-layer {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 12, 0.72);
  backdrop-filter: blur(3px);
  z-index: 40;
}
.overlay-panel {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 40px 44px;
  width: min(560px, 80%);
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  animation: pop 0.22s ease both;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.title-block { margin-bottom: 28px; }
.game-title {
  font-size: 58px; font-weight: 800; letter-spacing: 1px;
  color: var(--amber);
  text-shadow: 0 2px 18px rgba(216, 147, 47, 0.4);
}
.game-subtitle { color: var(--muted); font-size: 18px; margin-top: 6px; letter-spacing: 3px; text-transform: uppercase; }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 22px; }

/* ===== Buttons ===== */
.btn {
  font-family: var(--font);
  font-size: 18px; font-weight: 600;
  color: var(--text);
  background: rgba(40, 52, 72, 0.85);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: rgba(58, 74, 102, 0.95); border-color: rgba(255,255,255,0.22); }
.btn:active { transform: translateY(1px); }
.btn.wide { width: 100%; }
.btn.primary { background: linear-gradient(180deg, var(--amber), var(--amber-deep)); color: #1a1206; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ===== Options ===== */
.options-panel h2, .pause-panel h2, .quit-panel h2 { margin-bottom: 22px; font-size: 30px; }
.opt-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.opt-row label { font-size: 17px; color: var(--text); }
.segmented { display: flex; gap: 6px; }
.btn.seg { padding: 8px 16px; font-size: 15px; background: rgba(30,40,56,0.8); }
.btn.seg.active { background: var(--blue); color: #06121f; border-color: transparent; }
.slider-wrap { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.slider { flex: 1; accent-color: var(--amber); height: 6px; cursor: pointer; }
.slider-val { width: 48px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn.toggle { min-width: 90px; }
.btn.toggle.active { background: var(--danger); color: #1a0606; border-color: transparent; }
.options-panel .btn.wide { margin-top: 24px; }

/* ===== Investigation Map ===== */
.map-header {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  text-align: center; z-index: 5; pointer-events: none;
  background: rgba(8, 12, 20, 0.6); padding: 10px 22px; border-radius: 12px;
  border: 1px solid var(--line);
}
.map-header h3 { font-size: 22px; color: var(--amber); }
.map-header p { font-size: 14px; color: var(--muted); margin-top: 3px; }

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: transparent; border: none; cursor: pointer;
  z-index: 6;
}
.pin-dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--danger);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.3), 0 4px 12px rgba(0,0,0,0.5);
  animation: pin-pulse 1.8s ease-in-out infinite;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
@keyframes pin-pulse {
  0%,100% { box-shadow: 0 0 0 6px rgba(255,107,107,0.30), 0 4px 12px rgba(0,0,0,0.5); }
  50%     { box-shadow: 0 0 0 12px rgba(255,107,107,0.10), 0 4px 12px rgba(0,0,0,0.5); }
}
.pin.done .pin-dot {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(109, 223, 142, 0.28), 0 4px 12px rgba(0,0,0,0.5);
  animation: none;
}
.pin-label {
  font-size: 15px; font-weight: 700; color: #fff;
  background: rgba(8, 12, 20, 0.82); padding: 4px 10px; border-radius: 8px;
  border: 1px solid var(--line); white-space: nowrap;
}
.pin-sub { font-size: 12px; color: var(--muted); background: rgba(8,12,20,0.7); padding: 2px 8px; border-radius: 6px; }
.pin:hover .pin-dot { transform: scale(1.12); }

.accuse-btn {
  position: absolute; left: 24px; bottom: 24px; z-index: 8;
  font-size: 19px; padding: 14px 26px;
  animation: pop 0.3s ease both;
}

/* ===== Clue popup ===== */
.clue-popup {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 12, 0.6);
}
.clue-card {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 14px; padding: 26px 30px; width: min(560px, 78%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: pop 0.22s ease both;
}
.clue-tag { font-size: 13px; letter-spacing: 2px; color: var(--amber); font-weight: 700; margin-bottom: 12px; }
.clue-text { font-size: 20px; line-height: 1.55; color: var(--text); margin-bottom: 22px; }
.clue-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.clue-actions .btn { flex: 1; }

/* ===== Final Accusation ===== */
.accuse-wrap {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px;
}
.accuse-title { font-size: 40px; color: var(--amber); margin-bottom: 8px; text-shadow: 0 2px 16px rgba(0,0,0,0.6); }
.accuse-sub { color: var(--muted); font-size: 17px; margin-bottom: 34px; }
.choice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; width: 92%; max-width: 1040px; }
.choice-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(30, 40, 56, 0.9); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px 14px; cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}
.choice-card:hover { transform: translateY(-4px); border-color: var(--amber); background: rgba(48, 62, 86, 0.95); }
.choice-name { font-size: 22px; font-weight: 700; color: #fff; }
.choice-role { font-size: 14px; color: var(--amber); }
.choice-poi { font-size: 13px; color: var(--muted); }

/* ===== Summary / endings ===== */
.center-wrap {
  position: absolute; inset: 0; z-index: 12;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.summary-card {
  width: min(640px, 84%);
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 18px; padding: 34px 40px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.65); animation: pop 0.28s ease both;
  text-align: center;
}
.summary-verdict {
  font-size: 16px; letter-spacing: 4px; font-weight: 800;
  color: var(--green); margin-bottom: 6px;
}
.summary-verdict.bad { color: var(--danger); }
.summary-card h2 { font-size: 34px; margin-bottom: 22px; color: var(--text); }
.summary-row { display: flex; gap: 14px; text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line); }
.summary-row label { width: 90px; color: var(--muted); flex-shrink: 0; font-size: 15px; }
.summary-row span { font-size: 16px; }
.summary-evidence { text-align: left; margin-top: 16px; }
.summary-evidence label { color: var(--muted); font-size: 15px; }
.summary-evidence ul { margin: 8px 0 24px 18px; }
.summary-evidence li { font-size: 15px; line-height: 1.5; margin-bottom: 6px; }
.bad-text { font-size: 18px; line-height: 1.55; color: #d8d2c4; margin: 14px 0 26px; }

/* ===== Pin tooltip (hover) ===== */
.pin-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -8px);
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  background: rgba(8, 12, 20, 0.96); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 8px 22px rgba(0,0,0,0.5); z-index: 9;
}
.pin:hover .pin-tip { opacity: 1; transform: translate(-50%, -12px); }
.pin-tip-name { font-size: 15px; font-weight: 700; color: #fff; }
.pin-tip-role { font-size: 12px; color: var(--amber); }
.pin-tip-status { font-size: 12px; color: var(--muted); }
.pin-tip-status.done { color: var(--green); }

/* pin "just completed" pop + ring */
.pin.just-done .pin-dot { animation: pin-complete 0.65s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes pin-complete {
  0% { transform: scale(0.5); box-shadow: 0 0 0 0 rgba(109,223,142,0.6); }
  55% { transform: scale(1.35); }
  100% { transform: scale(1); box-shadow: 0 0 0 18px rgba(109,223,142,0); }
}

/* ===== Accusation juice: shake + flash ===== */
#game.shake { animation: shake 0.45s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate(-1px, 1px); }
  20%, 80% { transform: translate(3px, -2px); }
  30%, 50%, 70% { transform: translate(-6px, 3px); }
  40%, 60% { transform: translate(6px, -3px); }
}
#flash {
  position: absolute; inset: 0; background: #fff;
  opacity: 0; pointer-events: none; z-index: 55;
}
#flash.flash-anim { animation: flash-out 0.42s ease-out both; }
@keyframes flash-out { 0% { opacity: 0.85; } 100% { opacity: 0; } }

/* ===== Case Notes journal ===== */
#journal {
  position: absolute; inset: 0; z-index: 46;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 12, 0.74); backdrop-filter: blur(3px);
}
.journal-panel {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 16px; width: min(680px, 86%); max-height: 82%;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6); animation: pop 0.22s ease both;
}
.journal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 26px 12px; border-bottom: 1px solid var(--line);
}
.journal-head h2 { font-size: 28px; color: var(--amber); }
.btn.journal-close { padding: 6px 14px; font-size: 16px; background: rgba(40,52,72,0.85); }
.journal-sub { color: var(--muted); font-size: 14px; padding: 10px 26px 0; }
.journal-body { padding: 8px 26px 18px; overflow-y: auto; }
.journal-section {
  font-size: 14px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--blue); margin: 18px 0 10px;
}
.note-item {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
}
.note-item.contra { border-left-color: var(--danger); }
.note-loc { font-size: 15px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.note-who { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.note-text { font-size: 15px; line-height: 1.5; color: #d7dee7; }
.journal-empty { color: var(--muted); font-size: 15px; font-style: italic; padding: 6px 2px; }
.journal-hint { color: var(--muted); font-size: 13px; text-align: center; padding: 4px 0 16px; }

/* ===== Endings gallery ===== */
.gallery-panel { width: min(560px, 84%); text-align: left; }
.gallery-panel h2 { font-size: 30px; text-align: center; margin-bottom: 4px; }
.gallery-count { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 15px; }
.gallery-count.complete { color: var(--green); font-weight: 700; }
.gallery-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.gallery-row {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px;
}
.gallery-row.locked { opacity: 0.55; }
.gallery-row.seen { border-color: rgba(240,179,91,0.4); }
.gallery-mark { font-size: 22px; width: 28px; text-align: center; }
.gallery-info { display: flex; flex-direction: column; }
.gallery-title { font-size: 17px; font-weight: 700; color: #fff; }
.gallery-row.locked .gallery-title { color: var(--muted); }
.gallery-desc { font-size: 13px; color: var(--muted); }

/* ===== Fade ===== */
#fade {
  position: absolute; inset: 0; background: #000;
  opacity: 0; pointer-events: none; z-index: 50;
}

.hidden { display: none !important; }
