/* ==========================================================================
   PSYCHIC CLUES — Snappy 60fps Layered-Item Crime Scene HOG UI
   Separate Transparent PNG Item Layers + Item-to-Tray Flight Animation
   ========================================================================== */

:root {
  --bg-deep: #07090f;
  --bg-bar: #0f1421;
  --bg-slot: #161d2e;
  --border-gold: rgba(226, 174, 92, 0.36);
  --gold: #f0be67;
  --gold-bright: #ffe59e;
  --cyan: #3ee8df;
  --crimson: #ff365e;
  --text-main: #f3efe6;
  --text-muted: #939db2;
  --font-display: 'Cinzel', serif;
  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

.game-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 20% 0%, #1d1222 0%, #090c14 50%, var(--bg-deep) 100%);
}

/* ==========================================================================
   TOP HUD BAR
   ========================================================================== */

.top-hud {
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: linear-gradient(180deg, #161c2c 0%, #0d111c 100%);
  border-bottom: 1px solid var(--border-gold);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.58);
  z-index: 20;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 195px;
}

.case-badge {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(255, 54, 94, 0.16);
  border: 1px solid rgba(255, 54, 94, 0.48);
  color: #ff7b96;
  white-space: nowrap;
}

.case-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.case-timer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Center Score & Star Bar */
.hud-center {
  flex: 1;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.score-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.score-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
  margin-right: auto;
  transition: transform 0.12s ease;
}

.score-value.bump {
  transform: scale(1.14);
}

.found-counter {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
}

.star-bar-wrap {
  position: relative;
  height: 12px;
  display: flex;
  align-items: center;
}

.star-bar-track {
  width: 100%;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.star-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #d48d3b, var(--gold), var(--gold-bright));
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.star-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star-icon {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -52%);
  font-size: 16px;
  color: #343d52;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  transition: color 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star-icon.earned {
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(255, 226, 153, 0.85);
  transform: translate(-50%, -52%) scale(1.25);
}

/* Right Combo + Controls */
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.combo-box {
  width: 112px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #0a0e18;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.combo-box.hot { border-color: var(--cyan); }
.combo-box.blazing { border-color: var(--gold); }
.combo-box.pop { transform: scale(1.08); }

.combo-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.combo-label {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.combo-mult {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.combo-box.hot .combo-mult { color: var(--cyan); }
.combo-box.blazing .combo-mult { color: var(--gold-bright); }

.combo-timer-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.combo-timer-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold-bright));
  transform-origin: left center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
  background: rgba(240, 190, 103, 0.16);
  border-color: var(--border-gold);
}

.icon-btn:active { transform: scale(0.94); }

/* ==========================================================================
   MAIN CRIME SCENE STAGE (EXACT 1376:768 + LAYERED TRANSPARENT ITEM SPRITES)
   ========================================================================== */

.stage-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  overflow: hidden;
}

.scene-container {
  position: relative;
  width: min(100%, calc((100vh - 162px) * 1.7916667));
  aspect-ratio: 1376 / 768;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(212, 162, 89, 0.36);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.78);
  background: #070a10;
  cursor: crosshair;
}

.scene-container.shake {
  animation: sceneShake 0.24s ease;
}

@keyframes sceneShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-5px, 0, 0); }
  65% { transform: translate3d(5px, 0, 0); }
}

.scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Lightweight GPU Police Siren Ambient Pulse (opacity-only!) */
.siren-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: screen;
}

.siren-red {
  background: radial-gradient(ellipse 36% 60% at 18% 48%, rgba(255, 32, 78, 0.24) 0%, transparent 72%);
  animation: sirenPulseA 2.2s ease-in-out infinite;
}

.siren-blue {
  background: radial-gradient(ellipse 34% 58% at 33% 46%, rgba(36, 152, 255, 0.22) 0%, transparent 72%);
  animation: sirenPulseB 2.2s ease-in-out infinite;
}

@keyframes sirenPulseA {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.1; }
}

@keyframes sirenPulseB {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.85; }
}

.items-layer,
.fx-layer {
  position: absolute;
  inset: 0;
}

.items-layer {
  z-index: 5;
  pointer-events: none;
}

.fx-layer {
  pointer-events: none;
  z-index: 12;
}

/* Individual Transparent PNG Collectible Item Sprite on the Crime Scene */
.scene-item {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--item-rot, 0deg));
  border: none;
  background: transparent;
  padding: 0;
  cursor: crosshair;
  pointer-events: auto;
  display: block;
  line-height: 0;
  transition: opacity 0.08s ease;
}

.scene-item:focus-visible {
  outline: 2px solid var(--gold);
  border-radius: 6px;
}

.scene-item-img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  /* Blends each sprite naturally onto the dark crime scene surfaces */
  filter: var(--item-filter, brightness(0.84) contrast(1.06)) drop-shadow(0 4px 5px rgba(0, 0, 0, 0.72));
}

/* Once found, the actual sprite vanishes completely from the background! */
.scene-item.collected {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Penalty notice if player spams wrong clicks */
.penalty-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 18px;
  border-radius: 99px;
  background: rgba(25, 10, 16, 0.94);
  border: 1px solid var(--crimson);
  color: #ffc2d0;
  font-size: 13px;
  font-weight: 700;
  z-index: 25;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
}

.penalty-banner.hidden { display: none; }

/* ==========================================================================
   SNAPPY GPU-ONLY CLICK, ITEM DETACH & FLIGHT FX
   ========================================================================== */

.fx-ring {
  position: absolute;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  margin-top: -36px;
  border-radius: 50%;
  border: 3px solid var(--gold-bright);
  box-shadow: 0 0 18px rgba(255, 229, 158, 0.9), inset 0 0 12px rgba(62, 232, 223, 0.55);
  animation: fxRingBurst 0.42s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fxRingBurst {
  0%   { transform: scale(0.35); opacity: 1; }
  60%  { transform: scale(1.25); opacity: 0.9; }
  100% { transform: scale(1.7); opacity: 0; }
}

.fx-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 8px var(--gold-bright);
  animation: fxSparkFly 0.48s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fxSparkFly {
  0%   { transform: translate3d(0, 0, 0) scale(1.25); opacity: 1; }
  100% { transform: translate3d(var(--dx), var(--dy), 0) scale(0.12); opacity: 0; }
}

.fx-score-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--gold-bright);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 0 12px rgba(240, 190, 103, 0.7);
  white-space: nowrap;
  animation: fxFloatUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.fx-score-pop .combo-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--cyan);
  color: #071018;
  text-shadow: none;
  vertical-align: middle;
}

@keyframes fxFloatUp {
  0%   { transform: translate(-50%, -10%) scale(0.75); opacity: 0; }
  18%  { transform: translate(-50%, -60%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -170%) scale(0.98); opacity: 0; }
}

.fx-miss {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 900;
  color: var(--crimson);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
  animation: fxMissPop 0.45s ease-out forwards;
}

@keyframes fxMissPop {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 1; }
  40%  { transform: translate(-50%, -70%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -110%) scale(0.9); opacity: 0; }
}

.fx-hint-pulse {
  position: absolute;
  width: 96px;
  height: 96px;
  margin-left: -48px;
  margin-top: -48px;
  border-radius: 50%;
  border: 3px solid var(--cyan);
  background: radial-gradient(circle, rgba(62, 232, 223, 0.28) 0%, transparent 70%);
  box-shadow: 0 0 24px rgba(62, 232, 223, 0.8);
  animation: hintBeat 0.8s ease-in-out 3 forwards;
}

@keyframes hintBeat {
  0%   { transform: scale(0.7); opacity: 0.95; }
  50%  { transform: scale(1.18); opacity: 0.6; }
  100% { transform: scale(0.85); opacity: 0; }
}

/* Flying ACTUAL ITEM SPRITE from Crime Scene -> Bottom Word Slot! */
.fly-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 65;
}

.fx-fly-item {
  position: fixed;
  top: 0;
  left: 0;
  transform-origin: center center;
  will-change: transform, opacity;
  filter: brightness(1.18) contrast(1.08) drop-shadow(0 0 14px rgba(255, 229, 158, 0.95));
}

.fx-tray-burst {
  position: fixed;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  border-radius: 50%;
  border: 2.5px solid var(--gold-bright);
  box-shadow: 0 0 20px var(--gold-bright);
  animation: fxRingBurst 0.34s ease-out forwards;
}

/* ==========================================================================
   BOTTOM ITEM TRAY (CRIMINAL CASE 6-SLOT BAR + HINT BUTTON)
   ========================================================================== */

.bottom-tray {
  height: 82px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #131828 0%, #0b0e17 100%);
  border-top: 1px solid var(--border-gold);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.58);
  z-index: 20;
}

.item-slots {
  flex: 1;
  max-width: 1060px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.item-slot {
  height: 54px;
  border-radius: 9px;
  background: linear-gradient(180deg, #1b2438 0%, #131a29 100%);
  border: 1px solid rgba(212, 162, 89, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.item-slot.empty {
  opacity: 0.25;
  border-style: dashed;
  background: rgba(15, 20, 32, 0.45);
}

.item-slot.hinted {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 16px rgba(62, 232, 223, 0.35);
}

.item-slot.found-flash {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(240, 190, 103, 0.42), rgba(240, 190, 103, 0.16));
  color: var(--gold-bright);
  transform: scale(1.08);
  box-shadow: 0 0 24px rgba(255, 229, 158, 0.52);
}

.item-slot.slide-in {
  animation: slotPopIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slotPopIn {
  0%   { transform: translateY(12px) scale(0.92); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Circular Criminal Case Hint Button */
.hint-btn {
  position: relative;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #24344f 0%, #101726 100%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease;
}

.hint-btn:hover:not(:disabled) { transform: scale(1.06); }
.hint-btn:active:not(:disabled) { transform: scale(0.95); }
.hint-btn:disabled { cursor: not-allowed; opacity: 0.72; }

.hint-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hint-ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 3.5; }
.hint-ring-prog {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 150.8;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.12s linear;
}

.hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 2px;
}

.hint-icon { font-size: 16px; color: var(--cyan); }
.hint-text { font-size: 10px; font-weight: 700; color: var(--text-main); }

/* ==========================================================================
   VICTORY SCORECARD MODAL
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.84);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 20px;
}

.modal-backdrop.hidden { display: none; }

.result-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, #171f32 0%, #0f1523 100%);
  border: 1.5px solid var(--border-gold);
  border-radius: 16px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.78);
  animation: slotPopIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-bottom: 6px;
}

.result-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--gold-bright);
  margin-bottom: 14px;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
}

.r-star {
  font-size: 40px;
  color: #2b3449;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s ease;
}

.r-star.earned {
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(255, 226, 153, 0.8);
  transform: scale(1.12);
}

.score-breakdown {
  background: rgba(8, 11, 18, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.bd-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.accent-gold { color: var(--gold); font-weight: 700; }
.accent-cyan { color: var(--cyan); font-weight: 700; }

.bd-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 16px;
  font-weight: 800;
  color: var(--gold-bright);
}

.play-again-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: 10px;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, #e3a748, #c78128);
  color: #0b0e16;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.play-again-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

@media (max-width: 900px) {
  .item-slots { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .bottom-tray { height: auto; padding: 8px 12px; }
  .item-slot { height: 40px; font-size: 12.5px; }
  .hud-left { min-width: auto; }
  .case-badge { display: none; }
}
