:root {
  --bg-void: #05070b;
  --panel-bg: #0d1017;
  --panel-border: #202634;
  --panel-hi: #151b26;
  --brass: #c9a255;
  --brass-bright: #e5c172;
  --brass-glow: rgba(201, 162, 85, 0.32);
  --cyan-uv: #4ff4d8;
  --blue-brand: #2563eb;
  --text-main: #eaedf4;
  --text-dim: #8892a6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-drag: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-main);
  font-family: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Fullscreen Adventure Frame */
.game-app {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 46px minmax(0, 1fr) 90px;
  max-width: 1380px;
  margin: 0 auto;
  background: #07090e;
  border-left: 1px solid #141923;
  border-right: 1px solid #141923;
  position: relative;
}

/* Minimal Dark Metallic HUD */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, #0d1119 0%, #090c12 100%);
  border-bottom: 1px solid #1b2230;
  z-index: 30;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mini {
  text-decoration: none;
  font-weight: 900;
  font-size: 0.94rem;
  letter-spacing: -0.03em;
  color: #f8fafc;
}

.brand-mini .dot {
  color: #3b82f6;
}

.room-compass {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--brass-bright);
  background: rgba(201, 162, 85, 0.09);
  border: 1px solid rgba(201, 162, 85, 0.28);
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.hud-pill {
  background: #0b0e15;
  border: 1px solid #1e2636;
  color: #cbd5e1;
  font-size: 0.77rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #121722;
  border: 1px solid #232c3f;
  color: #d8dee9;
  font-size: 0.76rem;
  font-weight: 700;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.hud-btn.icon-only {
  width: 30px;
  padding: 0;
}

.hud-btn:hover:not(:disabled) {
  border-color: var(--brass);
  color: var(--brass-bright);
  background: #192030;
}

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

/* Main 1376:768 Room Viewport */
.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #04060a;
  overflow: hidden;
  touch-action: none;
}

.room-stage {
  position: relative;
  width: 100%;
  height: auto;
  max-width: 1280px;
  max-height: 100%;
  aspect-ratio: 1376 / 768;
  overflow: hidden;
  background: #05070b;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.92);
}

.scene-svg-mount,
.closeup-svg-mount {
  width: 100%;
  height: 100%;
}

.scene-svg-mount svg,
.closeup-svg-mount svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Clean, Non-Slop Interactive Hitboxes (Zero Colored Boxes on Artwork!) */
.hit-zone {
  fill: rgba(255, 255, 255, 0.001);
  stroke: none;
  cursor: pointer;
}

.sprite-interactive {
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), filter 0.18s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.sprite-interactive:hover {
  filter: brightness(1.1) drop-shadow(0 0 10px rgba(235, 200, 125, 0.28));
}

.book-sprite {
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), filter 0.2s ease;
  transform-box: fill-box;
  transform-origin: center bottom;
}

.book-sprite:hover {
  transform: translateY(-7px);
  filter: brightness(1.08);
}

.book-sprite.picked {
  transform: translateY(-20px) scale(1.025);
  filter: brightness(1.15) drop-shadow(0 14px 16px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 12px rgba(229, 193, 114, 0.38));
}

/* Breaker Analog Needle & Safe Wheel Smooth Motion */
.meter-needle-group {
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.safe-wheel-group {
  cursor: pointer;
  transition: transform 0.52s cubic-bezier(0.34, 1.25, 0.64, 1), filter 0.15s ease;
}

.safe-wheel-group:hover {
  filter: brightness(1.08);
}

.screw-sprite {
  cursor: pointer;
  transition: transform 0.32s ease-in, opacity 0.28s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.screw-sprite:hover {
  filter: brightness(1.15);
}

/* Full-Bleed First-Person Close-up Camera Layer */
.closeup-view {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #05070b;
  animation: cameraPushIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.closeup-view[hidden] {
  display: none !important;
}

@keyframes cameraPushIn {
  from {
    opacity: 0;
    transform: scale(1.035);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.step-back-pill {
  position: absolute;
  bottom: 16px;
  left: 18px;
  z-index: 24;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(8, 11, 16, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(201, 162, 85, 0.42);
  color: #e5e7eb;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.72);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}

.step-back-pill:hover {
  background: rgba(18, 24, 36, 0.92);
  border-color: var(--brass-bright);
  color: var(--brass-bright);
}

.step-back-pill:active {
  transform: scale(0.96);
}

/* UV Flashlight Real-time Lens Overlay */
.uv-overlay-mount {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 12;
  --uv-x: 50%;
  --uv-y: 50%;
}

.uv-overlay-mount.active {
  opacity: 1;
}

.uv-dark-tint {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 125px at var(--uv-x) var(--uv-y),
    rgba(124, 58, 237, 0.22) 0%,
    rgba(67, 20, 138, 0.38) 65%,
    rgba(3, 4, 10, 0.78) 100%
  );
}

.uv-secret-layer {
  position: absolute;
  inset: 0;
  clip-path: circle(114px at var(--uv-x) var(--uv-y));
}

.uv-secret-layer svg {
  width: 100%;
  height: 100%;
  display: block;
}

.uv-lens-ring {
  position: absolute;
  width: 228px;
  height: 228px;
  left: var(--uv-x);
  top: var(--uv-y);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid rgba(167, 139, 250, 0.55);
  box-shadow: 0 0 36px rgba(124, 58, 237, 0.6), inset 0 0 28px rgba(79, 244, 216, 0.18);
}

/* Subtle Wall Turn Arrows */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 10, 16, 0.52);
  backdrop-filter: blur(6px);
  color: rgba(241, 245, 249, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-arrow[hidden] {
  display: none !important;
}

.nav-arrow:hover {
  background: rgba(18, 24, 36, 0.85);
  border-color: rgba(201, 162, 85, 0.6);
  color: var(--brass-bright);
}

.nav-arrow.left {
  left: 0;
  border-left: none;
  border-radius: 0 10px 10px 0;
}

.nav-arrow.right {
  right: 0;
  border-right: none;
  border-radius: 10px 0 0 10px;
}

/* Door Escape Light Bloom */
.door-bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 28;
  background: radial-gradient(circle at 50% 45%, #ffffff 0%, #dbeafe 42%, rgba(14, 22, 38, 0.95) 100%);
  transition: opacity 0.65s ease-in;
}

.door-bloom.open {
  opacity: 1;
}

/* Subtle First-Person Monologue Caption (Top edge so floor items are never covered) */
.caption-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(86%, 620px);
  background: rgba(6, 8, 13, 0.86);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(201, 162, 85, 0.34);
  color: #f1f5f9;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  z-index: 26;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.78);
}

.caption-toast[hidden] {
  display: none !important;
}

/* Bottom Diegetic Inventory Bar (Painted Item Sprites) */
.inventory-bar {
  background: linear-gradient(180deg, #0a0d14 0%, #07090e 100%);
  border-top: 1px solid #1b2230;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 14px;
  z-index: 30;
}

.inv-slots {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  padding: 2px;
}

.inv-slot {
  width: 80px;
  height: 70px;
  flex: 0 0 80px;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 42%, #171d2b 0%, #0c1018 100%);
  border: 1px solid #232c3d;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 4px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.inv-slot.filled:hover {
  border-color: rgba(201, 162, 85, 0.55);
}

.inv-slot.selected {
  border-color: var(--brass-bright);
  background: radial-gradient(circle at 50% 42%, #242b3d 0%, #111622 100%);
  box-shadow: 0 0 0 1.5px var(--brass-glow), inset 0 0 14px rgba(201, 162, 85, 0.18);
  transform: translateY(-2px);
}

.inv-item-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.85));
  pointer-events: none;
}

.inv-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: #cbd5e1;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 74px;
}

.equipped-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brass-bright);
  min-width: 126px;
  text-align: left;
}

/* Intro / Victory Overlays */
.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: radial-gradient(circle at 50% 35%, rgba(15, 20, 32, 0.92), rgba(4, 6, 10, 0.98));
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}

.overlay-screen[hidden] {
  display: none !important;
}

.title-box {
  max-width: 460px;
  width: 100%;
  background: linear-gradient(180deg, #111622 0%, #0a0d15 100%);
  border: 1px solid #263044;
  border-radius: 16px;
  padding: 30px 26px;
  text-align: center;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.9);
}

.eyebrow-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--brass-bright);
  letter-spacing: 0.18em;
  margin-bottom: 8px;
}

.title-logo {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.accent-dot {
  color: #3b82f6;
}

.title-desc {
  margin: 12px 0 0;
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.6;
}

.rival-banner {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #bfdbfe;
  font-size: 0.82rem;
  font-weight: 700;
}

.btn-brass {
  width: 100%;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid #e5c172;
  background: linear-gradient(180deg, #d4ac5c 0%, #a88034 100%);
  color: #090c12;
  font-size: 0.96rem;
  font-weight: 900;
  margin-top: 16px;
  transition: filter 0.15s, transform 0.1s;
}

.btn-brass:hover {
  filter: brightness(1.08);
}

.btn-iron {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #2d384f;
  background: #141a28;
  color: #e2e8f0;
  font-size: 0.88rem;
  font-weight: 800;
  transition: border-color 0.15s;
}

.btn-iron:hover {
  border-color: var(--brass);
}

/* Victory Screen */
.victory-card {
  max-width: 820px;
  width: 100%;
  background: linear-gradient(180deg, #111623 0%, #0b0e17 100%);
  border: 1px solid #27334c;
  border-radius: 18px;
  padding: 26px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  align-items: center;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.92);
}

.escaped-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: #4ade80;
  letter-spacing: 0.14em;
}

.victory-title {
  margin: 6px 0 8px;
  font-size: 1.85rem;
  font-weight: 900;
}

.victory-sub {
  margin: 0 0 16px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brass-bright);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-cell {
  background: #090c14;
  border: 1px solid #1f283b;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.rank-cell {
  background: rgba(37, 99, 235, 0.14);
  border-color: #3b82f6;
}

.stat-label {
  font-size: 0.72rem;
  color: #8b95ab;
}

.stat-val {
  font-size: 1.25rem;
  font-weight: 900;
  margin-top: 3px;
}

.rank-val {
  color: #60a5fa;
}

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

.poster-canvas {
  width: 100%;
  max-width: 330px;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

/* Subtle Notebook Hint Dialog */
dialog.game-modal {
  background: #0e131e;
  color: #f1f5f9;
  border: 1px solid #2a354d;
  border-radius: 14px;
  max-width: 400px;
  width: calc(100% - 28px);
  padding: 18px;
}

dialog.game-modal::backdrop {
  background: rgba(3, 5, 10, 0.76);
  backdrop-filter: blur(4px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

@media (max-width: 720px) {
  .game-app {
    grid-template-rows: 44px minmax(0, 1fr) 76px;
  }
  .hud-bar {
    padding-inline: 8px;
    gap: 6px;
  }
  .hud-left {
    min-width: 0;
    gap: 6px;
  }
  .brand-mini,
  .hud-right {
    flex: none;
    white-space: nowrap;
  }
  .hud-right {
    gap: 5px;
  }
  .room-compass {
    min-width: 0;
    padding-inline: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hud-pill {
    padding-inline: 6px;
  }
  .equipped-tag {
    display: none;
  }
  .inventory-bar {
    padding-inline: 8px;
  }
  .inv-slots {
    width: min(100%, 380px);
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
  }
  .inv-slot {
    width: 100%;
    min-width: 0;
    height: 54px;
  }
  .inv-name {
    max-width: 100%;
  }
  .inv-item-img {
    width: 36px;
    height: 36px;
  }
  .victory-card {
    grid-template-columns: 1fr;
  }
  .step-back-pill {
    bottom: 10px;
    left: 10px;
    padding: 6px 12px;
    font-size: 0.75rem;
  }
}

.intro-home { display: table; margin: 16px auto 0; color: #cbd5e1; font-size: .85rem; text-underline-offset: 3px; }
