/* Layout: full-bleed WebGL canvas; HUD pinned top, overlays centered. One deliberate look: a bar at night. */
@font-face { font-family: 'Bungee'; src: url('../fonts/bungee-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlow-condensed-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlow-condensed-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --night: #140d0a;
  --amber: #f2b230;
  --neon: #ff3d7f;
  --neon-soft: #ffd6e4;
  --foam: #fff4dc;
  --paper: #f3ecdf;
  --ink: #2b211b;
  --ink-soft: #7a6a5c;
  --display: 'Bungee', Impact, 'Arial Black', sans-serif;
  --ui: 'Barlow Condensed', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--foam);
  font-family: var(--ui);
  font-weight: 500;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 0;
  pointer-events: none;
}
.hud-score { display: flex; flex-direction: column; gap: 2px; }
.score {
  font-family: var(--display); font-size: clamp(34px, 7vw, 52px); line-height: 1;
  color: var(--amber); text-shadow: 0 2px 0 #6b3d05, 0 0 18px rgba(242, 178, 48, 0.35);
  font-variant-numeric: tabular-nums;
}
.tips { font-weight: 700; font-size: 18px; letter-spacing: 0.04em; color: var(--foam); font-variant-numeric: tabular-nums; }
.combo { font-weight: 700; font-size: 18px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--neon-soft); min-height: 1.2em; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.lives { display: flex; gap: 6px; }
.life {
  width: 18px; height: 24px; background: var(--amber);
  clip-path: polygon(0 0, 100% 0, 84% 100%, 16% 100%);
  box-shadow: inset 0 6px 0 var(--foam);
  transition: opacity 0.3s, transform 0.3s;
}
.life.lost { opacity: 0.18; transform: rotate(-18deg) translateY(4px); }
.best { font-size: 16px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 244, 220, 0.6); }

/* Speech bubbles over glasses */
#bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.bubble {
  position: absolute; transform: translate(-50%, -100%);
  max-width: 46vw; padding: 6px 11px; border-radius: 12px;
  background: var(--paper); color: var(--ink);
  font-weight: 700; font-size: clamp(14px, 3.6vw, 18px); line-height: 1.15; text-align: center;
  white-space: nowrap;
  animation: bubble 1.5s ease-out forwards;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
  border: 7px solid transparent; border-bottom: 0; border-top-color: var(--paper);
}
.bubble .detail { display: block; margin-top: 1px; font-size: 0.8em; font-weight: 500; opacity: 0.85; }
.bubble.great { background: var(--amber); }
.bubble.great::after { border-top-color: var(--amber); }
.bubble.bad { background: var(--neon); color: #fff; }
.bubble.bad::after { border-top-color: var(--neon); }
@keyframes bubble {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(0.8); }
  12% { opacity: 1; transform: translate(-50%, -100%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -190%); }
}

/* Event banner */
.banner {
  position: fixed; left: 50%; top: 22%; transform: translate(-50%, -50%);
  font-family: var(--display); font-size: clamp(26px, 7vw, 46px); text-align: center; white-space: nowrap;
  color: var(--neon-soft); text-shadow: 0 0 8px var(--neon), 0 0 24px var(--neon);
  opacity: 0; pointer-events: none;
}
.banner.show { animation: banner 2.2s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Title */
.title {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px 20px; text-align: center;
  background: radial-gradient(ellipse at center, rgba(20, 13, 10, 0.55), rgba(20, 13, 10, 0.88));
  cursor: pointer;
}
.neon {
  margin: 0; font-family: var(--display); font-weight: 400;
  font-size: clamp(46px, 13vw, 104px); line-height: 0.95; text-wrap: balance;
  color: var(--neon-soft);
  text-shadow: 0 0 6px var(--neon), 0 0 22px var(--neon), 0 0 48px rgba(255, 61, 127, 0.6);
  animation: hum 5s infinite;
}
@keyframes hum { 0%, 91%, 95%, 100% { opacity: 1; } 92%, 94% { opacity: 0.55; } }
.how { margin: 0; max-width: 30ch; font-size: clamp(19px, 4.6vw, 24px); font-weight: 700; line-height: 1.2; text-wrap: balance; }
.how.small { max-width: 40ch; font-size: 16px; font-weight: 500; color: rgba(255, 244, 220, 0.72); }
.start {
  margin: 10px 0 0; padding: 10px 22px; border: 2px solid var(--amber); border-radius: 999px;
  font-weight: 700; font-size: 20px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(242, 178, 48, 0.18); } }
.record { margin: 0; font-size: 16px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 244, 220, 0.6); }

/* Bar tab */
.tab {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 20px 16px; background: rgba(20, 13, 10, 0.72); overflow-y: auto; touch-action: pan-y;
}
.receipt {
  position: relative; width: min(360px, 100%); padding: 22px 20px 26px;
  background: var(--paper); color: var(--ink);
  transform: rotate(-1.2deg);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
  user-select: text; -webkit-user-select: text;
}
.tab-head { margin: 0; font-family: var(--display); font-size: 24px; text-align: center; letter-spacing: 0.02em; }
.tab-sub { margin: 4px 0 14px; font-size: 14px; text-align: center; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.tab-lines { display: flex; flex-direction: column; gap: 5px; padding-bottom: 8px; border-bottom: 2px dashed rgba(43, 33, 27, 0.35); }
.stub-sec { margin: 10px 0 4px; font-weight: 700; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.stub-note { margin: 6px 0 0; font-size: 14px; line-height: 1.25; color: var(--ink-soft); }
.line.neg span:last-child { color: #a3243f; }
.line.total.owed { color: #a3243f; }
.stub-verdict { margin: 2px 0 0; font-size: 15px; text-align: right; color: var(--ink-soft); }
.line { display: flex; align-items: baseline; gap: 6px; font-size: 16px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.line > span:first-child { min-width: 0; }
.line .dots { flex: 1; min-width: 12px; border-bottom: 2px dotted rgba(43, 33, 27, 0.35); transform: translateY(-4px); }
.line.total { margin-top: 10px; font-weight: 700; font-size: 21px; }
.tip { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.tip-label { font-weight: 700; font-size: 16px; line-height: 1.15; margin-right: auto; }
.tip button, .again, .mute { font: inherit; cursor: pointer; }
.tip button {
  padding: 4px 12px; border: 2px solid var(--ink); border-radius: 6px; background: transparent; color: var(--ink);
  font-weight: 700; font-size: 16px;
}
.tip button:hover, .tip button:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.tip-note { margin: 8px 0 0; min-height: 1.3em; font-size: 15px; color: var(--ink-soft); text-align: right; }
.tab-score { position: relative; display: flex; gap: 22px; margin-top: 14px; }
.tab-score div { display: flex; flex-direction: column; }
.tab-score .k { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.tab-score .v { font-family: var(--display); font-size: 32px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stamp {
  position: absolute; right: -4px; top: 2px; padding: 4px 10px;
  border: 3px solid var(--neon); border-radius: 6px; color: var(--neon);
  font-family: var(--display); font-size: 15px; text-transform: uppercase; transform: rotate(-12deg); opacity: 0.85;
}
.again {
  width: 100%; margin-top: 18px; padding: 13px 16px; border: 0; border-radius: 10px;
  background: var(--ink); color: var(--amber);
  font-weight: 700; font-size: 20px; letter-spacing: 0.08em; text-transform: uppercase;
}
.again:hover { background: #3d2f26; }
.again:focus-visible, .mute:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.home-link {
  margin-top: 6px; padding: 6px 4px;
  font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(255, 244, 220, 0.7); text-decoration: underline; text-underline-offset: 3px;
}
.home-link:hover, .home-link:focus-visible { color: var(--foam); outline: none; }
.home-link.on-paper { display: block; margin-top: 12px; text-align: center; color: var(--ink-soft); }
.home-link.on-paper:hover, .home-link.on-paper:focus-visible { color: var(--ink); }

.mute {
  position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  padding: 6px 12px; border: 1px solid rgba(255, 244, 220, 0.3); border-radius: 999px;
  background: rgba(20, 13, 10, 0.6); color: rgba(255, 244, 220, 0.75);
  font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase;
}
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  .neon, .start { animation: none; }
  .bubble { animation-duration: 0.01s; animation-delay: 1.2s; }
  .banner.show { animation: none; opacity: 1; }
}
