:root {
  --ink: #2b1d1a;
  --cream: #fff4e0;
  --coral: #f0605a;
  --coral-dark: #c8433e;
  --teal: #1f8a86;
  --teal-dark: #156663;
  --gold: #ffc93c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink);
  font-family: 'Baloo 2', system-ui, sans-serif; color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
canvas#c {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none;
}
#safe-probe { position: fixed; top: 0; left: 0; width: 0; height: env(safe-area-inset-top); pointer-events: none; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; z-index: 5; }
h2, h3, .btn, .coins-pill { font-family: 'Lilita One', system-ui, sans-serif; font-weight: 400; letter-spacing: 0.5px; }

/* Menu */
#menu { background: var(--ink); display: flex; flex-direction: column; justify-content: flex-end; }
.menu-art {
  position: absolute; inset: 0; background: url(img/key-art.jpg) center top / max(100%, 52vh) auto no-repeat;
}
.menu-art::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 45%, rgba(43, 29, 26, 0.85) 72%, var(--ink) 100%);
}
.coins-pill {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 16px; z-index: 2;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 14px 2px;
  font-size: 20px; box-shadow: 0 3px 0 var(--ink);
}
.coins-pill.inline { position: static; }
.coin { color: var(--gold); -webkit-text-stroke: 1.5px var(--ink); }
.sheet {
  position: relative; z-index: 2; padding: 0 16px calc(env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; gap: 10px; max-width: 520px; width: 100%; margin: 0 auto;
}
.scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scene {
  position: relative; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4;
  background: #444 center / cover no-repeat; cursor: pointer; padding: 0; color: var(--cream);
  box-shadow: 0 3px 0 var(--ink); font: inherit;
}
.scene.sel { outline: 4px solid var(--gold); outline-offset: -1px; }
.scene .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); text-align: center; line-height: 1.1;
}
.scene .label b { font-family: 'Lilita One', system-ui; font-weight: 400; font-size: 17px; display: block; }
.scene .label small { font-size: 12px; opacity: 0.9; }
.scene.locked { filter: grayscale(1) brightness(0.6); }
.scene .lock { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-size: 28px; }

.btn {
  border: 3px solid var(--ink); border-radius: 16px; background: var(--coral); color: var(--cream);
  font-size: 20px; padding: 10px 16px 7px; box-shadow: 0 4px 0 var(--ink); cursor: pointer;
  -webkit-text-stroke: 0; text-shadow: 0 2px 0 var(--coral-dark);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { font-size: 30px; padding: 12px 16px 8px; }
.btn.alt { background: var(--teal); text-shadow: 0 2px 0 var(--teal-dark); }
.btn.small { font-size: 16px; padding: 6px 12px 4px; }
.btn:disabled { background: #9a8f86; text-shadow: none; cursor: default; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.how { color: var(--cream); text-align: center; margin: 2px 0 0; font-size: 14px; line-height: 1.3; opacity: 0.9; }

/* Shop */
#shop { background: var(--cream); display: flex; flex-direction: column; }
#shop header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; border-bottom: 3px solid var(--ink); background: #ffe7c2;
}
#shop h2 { margin: 0; font-size: 26px; }
.shop-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(env(safe-area-inset-bottom) + 24px); flex: 1; }
.shop-body h3 { font-size: 22px; margin: 18px 0 8px; }
.up, .skin {
  display: flex; align-items: center; gap: 12px; background: #fff; border: 3px solid var(--ink); border-radius: 16px;
  padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 3px 0 var(--ink); max-width: 560px;
}
.up .ico, .skin .ico { font-size: 34px; width: 44px; text-align: center; flex: none; }
.up .info, .skin .info { flex: 1; min-width: 0; line-height: 1.2; }
.up .info b, .skin .info b { font-family: 'Lilita One', system-ui; font-weight: 400; font-size: 19px; }
.up .info small, .skin .info small { display: block; font-size: 14px; color: #6b5a52; }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.pip.on { background: var(--teal); }
.up .btn, .skin .btn { font-size: 16px; padding: 7px 10px 4px; white-space: nowrap; flex: none; }

/* Results */
#over { background: rgba(43, 29, 26, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
#over .card {
  background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink);
  padding: 18px 18px 16px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; text-align: center;
}
#over h2 { margin: 0; font-size: 34px; color: var(--coral); -webkit-text-stroke: 1.5px var(--ink); }
#over p { margin: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats div { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 4px 6px; }
.stats b { display: block; font-family: 'Lilita One', system-ui; font-weight: 400; font-size: 22px; }
.stats small { font-size: 13px; color: #6b5a52; }
.unlock { background: var(--gold); border: 2px solid var(--ink); border-radius: 12px; padding: 6px; font-weight: 800; }

#debug {
  position: fixed; left: 8px; bottom: 8px; z-index: 20; background: rgba(0, 0, 0, 0.7); color: #0f0;
  font: 12px ui-monospace, monospace; padding: 6px 8px; border-radius: 6px; pointer-events: none; white-space: pre;
}
