:root {
  color-scheme: dark;
  --ink: #f7f0e5;
  --muted: #b9a998;
  --bg: #18130f;
  --panel: rgba(30, 23, 18, 0.84);
  --line: rgba(255,255,255,0.13);
  --gold: #f2c84b;
  --gold-2: #ffde72;
  --red: #ef7059;
  --shadow: 0 24px 70px rgba(0,0,0,0.46);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; }
a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 38%, rgba(242,200,75,0.08), transparent 34%),
    linear-gradient(145deg, #201710, #100d0b 68%);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#game.is-grabbing { cursor: grabbing; }
#game:focus-visible {
  outline: 3px solid var(--gold-2);
  outline-offset: -5px;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
body.is-playing .topbar { opacity: 1; }
.brand { display: grid; gap: 1px; text-shadow: 0 2px 18px #000; }
.brand-kicker { font-size: 10px; letter-spacing: .18em; color: var(--muted); }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: clamp(25px, 3vw, 42px); letter-spacing: -.04em; }

.icon-button {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(22, 17, 13, .65);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.icon-button:hover { transform: scale(1.06); background: rgba(58, 44, 31, .8); }
.icon-button[aria-pressed="true"] { opacity: .48; }

.hud {
  position: absolute;
  z-index: 5;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  width: min(680px, calc(100% - 170px));
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
body.is-playing .hud { opacity: 1; }
.meter-card {
  flex: 1;
  min-width: 0;
  padding: 10px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(25, 19, 15, .67);
  box-shadow: 0 10px 35px rgba(0,0,0,.18);
  backdrop-filter: blur(12px);
}
.meter-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 10px; letter-spacing: .1em; color: var(--muted); }
.meter-label strong { color: var(--ink); font-size: 11px; }
.meter-track { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.meter-fill { width: 0%; height: 100%; border-radius: inherit; transition: width .08s linear; }
.meter-fill.consistency { background: linear-gradient(90deg, #c99818, var(--gold-2)); box-shadow: 0 0 12px rgba(242,200,75,.55); }
.meter-fill.stick { background: linear-gradient(90deg, #b84232, #ff8a70); box-shadow: 0 0 12px rgba(239,112,89,.52); }
.meter-fill.combo { background: linear-gradient(90deg, #e8e2ff, #b99cff); box-shadow: 0 0 12px rgba(185,156,255,.5); }
.combo-card.is-hot { border-color: rgba(202,181,255,.42); box-shadow: 0 0 24px rgba(155,120,255,.13); }
.combo-card.is-powered .meter-fill.combo { background: linear-gradient(90deg, #fff3ae, #ffb84c); }

.event-banner {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: clamp(118px, 17vh, 168px);
  display: grid;
  justify-items: center;
  gap: 3px;
  width: min(430px, calc(100% - 36px));
  padding: 11px 18px 12px;
  border: 1px solid rgba(255,232,139,.3);
  border-radius: 16px;
  background: rgba(30,22,15,.82);
  box-shadow: 0 16px 42px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.08);
  backdrop-filter: blur(14px);
  transform: translate(-50%, -8px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .22s cubic-bezier(.2,.8,.2,1);
}
.event-banner.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.event-banner strong { color: #ffe778; font-size: 12px; letter-spacing: .13em; }
.event-banner span { color: #e4d8ca; font-size: 12px; text-align: center; }
.event-banner.is-success { border-color: rgba(174,255,170,.3); }
.event-banner.is-success strong { color: #c8ffc5; }
.event-banner.is-challenge { border-color: rgba(199,179,255,.38); }
.event-banner.is-challenge strong { color: #d8c8ff; }

.screen {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(12, 9, 7, .22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .36s ease;
}
.screen.is-visible { opacity: 1; pointer-events: auto; }
.panel {
  width: min(600px, 100%);
  padding: clamp(26px, 5vw, 54px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(120%);
  transform: translateY(14px) scale(.985);
  transition: transform .45s cubic-bezier(.22,.8,.22,1);
}
.screen.is-visible .panel { transform: none; }
.intro-panel { text-align: left; }
.result-panel { text-align: center; }
.eyebrow { margin: 0 0 14px; font-size: 11px; font-weight: 750; letter-spacing: .17em; color: var(--gold); }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -.052em; line-height: .88; }
h1 { font-size: clamp(56px, 10vw, 104px); }
h2 { font-size: clamp(58px, 9vw, 92px); }
h1 em { color: var(--gold); font-weight: 400; }
.lede { max-width: 52ch; margin: 24px 0 0; color: #d8ccbf; font-size: clamp(15px, 2vw, 18px); line-height: 1.58; }
.result-panel .lede { margin-inline: auto; }

.controls-hint { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 26px 0 24px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.controls-hint span { display: flex; align-items: center; gap: 7px; }
.controls-hint b { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 11px; }
.mouse-icon { display: inline-block; width: 14px; height: 21px; border: 1.5px solid currentColor; border-radius: 8px; position: relative; }
.mouse-icon::after { content: ""; position: absolute; top: 3px; left: 50%; width: 2px; height: 5px; background: currentColor; transform: translateX(-50%); border-radius: 2px; }

.primary-button {
  border: 0;
  border-radius: 999px;
  padding: 16px 24px;
  color: #22190c;
  background: linear-gradient(180deg, #ffe984, var(--gold));
  box-shadow: 0 12px 30px rgba(242,200,75,.23), inset 0 1px rgba(255,255,255,.65);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(242,200,75,.3), inset 0 1px rgba(255,255,255,.65); }
.primary-button:active { transform: translateY(1px) scale(.99); }
.primary-button:focus-visible,
.icon-button:focus-visible,
.project-meta a:focus-visible {
  outline: 3px solid #fff2a4;
  outline-offset: 4px;
}

.project-meta {
  margin: 20px 0 0;
  color: rgba(239,228,213,.58);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.project-meta a {
  color: #eadfce;
  text-underline-offset: 3px;
}
.project-meta a:visited { color: #eadfce; }
.project-meta a:hover { color: var(--gold-2); }

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 28px 0 24px;
}
.score-grid > div { padding: 15px 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.score-grid span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .13em; }
.score-grid strong { display: block; margin-top: 6px; font-family: Georgia, serif; font-size: clamp(22px, 4vw, 34px); }

.toast {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 21%;
  transform: translate(-50%, 10px) scale(.96);
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(24,18,13,.75);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(10px);
  transition: opacity .16s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.is-warning { color: #ffd2c9; border-color: rgba(239,112,89,.35); }
.toast.is-gold { color: #ffe789; border-color: rgba(242,200,75,.36); }
.toast.is-purple { color: #ddceff; border-color: rgba(185,156,255,.4); }

.footer-note {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  width: calc(100% - 40px);
  text-align: center;
  color: rgba(239,228,213,.55);
  font-size: 11px;
  letter-spacing: .025em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
body.is-playing .footer-note { opacity: 1; }

@media (max-width: 720px) {
  .brand-kicker { display: none; }
  .hud { top: 72px; width: calc(100% - 26px); gap: 6px; }
  .meter-card { padding-inline: 9px; }
  .event-banner { top: 145px; }
  .topbar { left: 16px; right: 16px; }
  .screen { padding: 16px; }
  .panel { border-radius: 20px; }
  .footer-note { bottom: 10px; font-size: 10px; }
}

@media (max-width: 460px) {
  .meter-card { padding: 9px 9px 10px; }
  .meter-label { letter-spacing: .06em; }
  .controls-hint { gap: 9px 14px; }
  .score-grid { gap: 5px; }
  .score-grid > div { padding-inline: 3px; }
}

@media (max-height: 620px) {
  .panel { padding-block: 22px; }
  .eyebrow { margin-bottom: 9px; }
  h1 { font-size: clamp(50px, 16vh, 72px); }
  .lede { margin-top: 16px; line-height: 1.48; }
  .controls-hint { margin-block: 18px; }
  .project-meta { margin-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
