:root {
  --ink: #120e18;
  --cream: #faf2e6;
  --gold: #f7c948;
  --pink: #d9467a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink);
  touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
body { font-family: 'VT323', monospace; color: var(--cream); }
#stage { position: fixed; left: 0; top: 0; overflow: hidden; }
#game { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
#ui, #hud { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }

/* HUD */
#hud { font-family: 'Press Start 2P', monospace; }
.hud-btn {
  pointer-events: auto; position: absolute; left: 10px; top: calc(10px + env(safe-area-inset-top));
  width: 38px; height: 38px; border: 3px solid var(--ink); background: var(--cream); color: var(--ink);
  font: 12px 'Press Start 2P', monospace; box-shadow: 0 3px 0 var(--ink); border-radius: 4px; padding: 0;
}
#hudPlace {
  position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center;
  font-size: 9px; letter-spacing: 1px; color: var(--cream); text-shadow: 2px 2px 0 var(--ink);
}
#hudCount {
  position: absolute; right: 26px; top: calc(12px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 6px;
  background: rgba(18,14,24,0.7); border: 2px solid var(--ink); padding: 4px 8px 4px 6px; border-radius: 4px;
  font-size: 11px;
}
#hudCount img { width: 18px; height: 18px; image-rendering: pixelated; }
#hudPower {
  position: absolute; left: 10px; top: calc(56px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 6px;
  background: rgba(18,14,24,0.7); border: 2px solid var(--ink); padding: 4px 6px; border-radius: 4px;
}
#hudPower img { width: 22px; height: 22px; image-rendering: pixelated; }
#hudPower .bar { width: 60px; height: 6px; background: #3a3348; border-radius: 2px; overflow: hidden; }
#hudPowerBar { height: 100%; width: 100%; background: var(--gold); }
#toast {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%);
  font-size: 13px; color: var(--cream); text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink);
  text-align: center; white-space: nowrap; animation: pop 1.6s ease-out forwards;
}
#toast small { display: block; font-family: 'VT323', monospace; font-size: 20px; margin-top: 6px; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%); }
}

/* Screens */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom)); text-align: center; gap: 16px;
}
.screen.top { justify-content: flex-start; }
.screen.dim { background: rgba(18,14,24,0.55); }
.screen.scroll { overflow-y: auto; justify-content: flex-start; touch-action: pan-y; }
h1, h2, h3 { font-family: 'Press Start 2P', monospace; font-weight: normal; margin: 0; line-height: 1.5; }
h1 { font-size: 20px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); }
h2 { font-size: 14px; }
h3 { font-size: 10px; }
p { margin: 0; font-size: 22px; line-height: 1.1; }
.sub { font-size: 22px; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); }
.btn {
  font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--ink); background: var(--gold);
  border: 3px solid var(--ink); border-radius: 6px; padding: 14px 20px; box-shadow: 0 4px 0 var(--ink);
  cursor: pointer; min-width: 180px; line-height: 1.4;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.ghost { background: var(--cream); }
.btn.small { font-size: 9px; padding: 10px 12px; min-width: 0; }
.btn[disabled] { opacity: 0.5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.col { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.card {
  background: var(--cream); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px;
  box-shadow: 0 6px 0 var(--ink); padding: 18px 16px; width: min(340px, 100%);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.card p { font-size: 21px; }
.card .meta { font-size: 18px; opacity: 0.75; }

.choice {
  width: min(320px, 100%); text-align: left; display: flex; gap: 12px; align-items: center;
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 8px; padding: 12px;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer; font-family: inherit;
}
.choice:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.choice b { font-family: 'Press Start 2P', monospace; font-weight: normal; font-size: 11px; display: block; margin-bottom: 6px; }
.choice span { font-size: 19px; line-height: 1.05; display: block; }
.choice img { width: 72px; height: 72px; image-rendering: pixelated; flex: none; }
.choice.sel { background: var(--gold); }
.pip { font-size: 18px; }

.pin {
  position: absolute; transform: translate(-50%, -100%); pointer-events: auto; background: none; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
}
.pin .bubble {
  width: 46px; height: 46px; border: 3px solid var(--ink); border-radius: 50%; background: var(--cream);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 var(--ink);
}
.pin .bubble img { width: 30px; height: 30px; image-rendering: pixelated; }
.pin.next .bubble { background: var(--gold); animation: bob 0.9s ease-in-out infinite; }
.pin.locked .bubble { background: #9a93a8; }
.pin.done .bubble { background: #9fd36a; }
.pin .label {
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--cream); background: var(--ink);
  padding: 4px 6px; border-radius: 3px; white-space: nowrap;
}
@keyframes bob { 50% { transform: translateY(-5px); } }

/* Reveal cards */
.reveal {
  width: min(340px, 100%); border: 4px solid var(--ink); border-radius: 10px; box-shadow: 0 8px 0 var(--ink);
  padding: 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: rise 0.6s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes rise { from { transform: translateY(60px) scale(0.8); opacity: 0; } }
.reveal .found { font-family: 'Press Start 2P', monospace; font-size: 9px; letter-spacing: 2px; opacity: 0.8; }
.reveal .amount { font-family: 'Press Start 2P', monospace; font-size: 22px; margin: 4px 0; }
.reveal .amount small { display: block; font-size: 10px; margin-top: 8px; letter-spacing: 1px; }
.reveal .logo { image-rendering: pixelated; }
.reveal p { font-size: 21px; line-height: 1.1; }
.reveal .addr { font-size: 19px; opacity: 0.8; }
.reveal .stats { font-size: 18px; opacity: 0.7; }
.reveal hr { width: 100%; border: 0; border-top: 2px dashed currentColor; opacity: 0.3; margin: 2px 0; }

.r-tea { background: #f6f1e7; color: #1a1a1a; }
.r-tea .word { font-family: 'Press Start 2P', monospace; font-size: 15px; letter-spacing: 6px; line-height: 1.8; }
.r-tea .tag { font-size: 22px; color: #4f7a5a; }
.r-wine { background: #efe7c8; color: #3e3423; }
.r-wine .word { font-family: 'Press Start 2P', monospace; font-size: 18px; letter-spacing: 5px; }
.r-wine .word2 { font-family: 'Press Start 2P', monospace; font-size: 9px; letter-spacing: 6px; color: #6d7a2a; }
.r-cocktail { background: #14101f; color: #f2e6c8; border-color: #000; }
.r-cocktail .word { font-family: 'Press Start 2P', monospace; font-size: 17px; letter-spacing: 3px; color: #f2d49a; }
.r-cocktail .btn { background: #f2d49a; }

.letter {
  background: var(--cream); color: var(--ink); border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 6px 0 var(--ink);
  padding: 18px; width: min(340px, 100%); text-align: left;
}
.letter p { font-size: 22px; margin-bottom: 10px; }
.letter .sig { text-align: right; }
.gifts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.gift { background: var(--ink); color: var(--cream); border: 2px solid var(--cream); border-radius: 6px; padding: 6px 8px; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.gift img { width: 20px; height: 20px; image-rendering: pixelated; }

#rotate {
  display: none; position: fixed; inset: 0; background: var(--ink); color: var(--cream); z-index: 10;
  align-items: center; justify-content: center; text-align: center; font: 14px/2 'Press Start 2P', monospace;
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 500px) {
  #rotate { display: flex; }
}
