:root {
  color-scheme: dark;
  --bg: #070913;
  --panel: rgba(13, 17, 34, 0.86);
  --panel-solid: #10152b;
  --line: rgba(151, 169, 255, 0.18);
  --muted: #8490b5;
  --text: #f2f5ff;
  --cyan: #55efff;
  --pink: #ff4fa8;
  --lime: #b8ff62;
  --yellow: #ffd866;
  --purple: #9f82ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 10%, rgba(69, 97, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 86% 80%, rgba(255, 48, 163, 0.12), transparent 28rem),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button { font: inherit; }

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 48px) 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand { display: grid; gap: 2px; }
.brand-kicker, .eyebrow, .tip-label, .stat-card span, .combo-top span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: clamp(21px, 3vw, 32px);
  line-height: 1;
  letter-spacing: .08em;
  font-weight: 900;
}

.brand h1 span, .menu-panel h2 span { color: var(--cyan); }

.top-actions { display: flex; gap: 8px; }

.icon-button, .close-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: rgba(18, 23, 46, .7);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, color .18s ease;
}

.icon-button:hover, .close-button:hover { transform: translateY(-2px); border-color: var(--cyan); color: var(--cyan); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  gap: 18px;
  align-items: start;
}

.game-card, .info-panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(20, 25, 52, .86), rgba(8, 11, 25, .86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.game-card { padding: 12px; border-radius: 24px; }

.game-frame {
  position: relative;
  width: 100%;
  height: min(76vh, 770px);
  min-height: 510px;
  overflow: hidden;
  border-radius: 17px;
  background: #070a17;
  isolation: isolate;
}

.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: inherit;
  box-shadow: inset 0 0 80px rgba(52, 73, 175, .18);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(180deg, rgba(3, 5, 15, .18), rgba(3, 5, 15, .56));
  pointer-events: none;
  z-index: 3;
}

.menu-panel, .help-panel {
  position: relative;
  width: min(100%, 480px);
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgba(142, 169, 255, .26);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(17, 21, 47, .94), rgba(7, 10, 24, .9));
  box-shadow: 0 24px 100px rgba(0,0,0,.55), 0 0 80px rgba(71, 95, 255, .1);
  text-align: center;
  pointer-events: auto;
  animation: panel-in .35s ease both;
}

@keyframes panel-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.menu-panel h2, .help-panel h2 {
  margin: 8px 0 12px;
  font-size: clamp(36px, 8vw, 64px);
  line-height: .98;
  letter-spacing: -.04em;
  font-weight: 950;
}

.menu-panel h2 span { display: block; }
.menu-panel .lead, .help-panel .lead { margin: 0; color: #c4cbed; line-height: 1.7; font-size: 14px; }

.difficulty-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 24px 0 13px;
}

.difficulty-button {
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  cursor: pointer;
  transition: .18s ease;
}

.difficulty-button:hover, .difficulty-button.is-active {
  color: var(--text);
  border-color: rgba(85, 239, 255, .75);
  background: rgba(85, 239, 255, .12);
  box-shadow: 0 0 24px rgba(85, 239, 255, .12);
}

.primary-button, .ghost-button {
  min-height: 48px;
  width: 100%;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 850;
  letter-spacing: .04em;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.primary-button {
  border: 0;
  color: #07101c;
  background: linear-gradient(100deg, var(--cyan), #b8faff 52%, var(--lime));
  box-shadow: 0 9px 30px rgba(85, 239, 255, .18);
}

.primary-button span { display: inline-block; margin-left: 8px; font-size: 19px; transition: transform .18s ease; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(85,239,255,.32); }
.primary-button:hover span { transform: translateX(4px); }

.ghost-button {
  margin-top: 10px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,.04);
}

.ghost-button:hover { background: rgba(255,255,255,.08); }

.micro-copy, .touch-note, .footer-note {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .03em;
}

.micro-copy { margin: 18px 0 0; line-height: 1.6; }
.touch-note { margin: 10px 4px 0; text-align: center; }

.result-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 25px 0 20px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
}

.result-line strong { color: var(--yellow); font-size: 27px; letter-spacing: .02em; }

.help-panel { text-align: left; padding-top: 38px; }
.help-panel h2 { font-size: clamp(31px, 6vw, 48px); }
.close-button { position: absolute; top: 14px; right: 14px; border: 0; background: transparent; font-size: 24px; }
.help-list { display: grid; gap: 12px; margin: 22px 0 25px; }
.help-list div { display: grid; grid-template-columns: 29px 1fr; gap: 11px; align-items: start; color: #c7cdea; font-size: 13px; line-height: 1.55; }
.help-list b { color: var(--cyan); font-size: 11px; letter-spacing: .1em; }

.orientation-note {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 8px 12px;
  border-radius: 999px;
  color: #0a0f19;
  background: var(--yellow);
  font-size: 11px;
  font-weight: 850;
  box-shadow: 0 6px 20px rgba(255,216,102,.16);
}

.info-panel { display: grid; gap: 12px; padding: 12px; border-radius: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat-card { padding: 14px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.035); }
.stat-card strong { display: block; margin-top: 6px; color: var(--text); font-size: 18px; letter-spacing: .04em; }
.stat-score strong { color: var(--cyan); }

.combo-card, .tip-card { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(140deg, rgba(85,239,255,.06), rgba(255,79,168,.05)); }
.combo-card.is-fever { border-color: rgba(255,79,168,.6); background: linear-gradient(140deg, rgba(255,79,168,.16), rgba(184,255,98,.08)); box-shadow: 0 0 34px rgba(255,79,168,.12); }
.combo-top { display: flex; justify-content: space-between; align-items: baseline; }
.combo-top strong { color: var(--yellow); font-size: 25px; }
.meter { height: 8px; margin: 11px 0 9px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.08); }
.meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--purple), var(--pink)); transition: width .2s ease; }
.combo-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.tip-card { display: grid; gap: 10px; }
.tip-label { margin-bottom: 2px; }
.power-row { display: grid; grid-template-columns: 13px 54px 1fr; gap: 8px; align-items: center; color: var(--text); font-size: 11px; font-weight: 800; }
.power-row small { color: var(--muted); font-size: 10px; font-weight: 500; }
.power-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.power-wide { color: var(--lime); background: var(--lime); }
.power-multi { color: var(--pink); background: var(--pink); }
.power-pierce { color: var(--yellow); background: var(--yellow); }

.side-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-controls button { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: rgba(255,255,255,.04); cursor: pointer; font-size: 16px; transition: .18s ease; }
.side-controls button span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.side-controls button:hover { border-color: var(--cyan); background: rgba(85,239,255,.08); }

.footer-note { margin-top: 15px; text-align: center; }
.footer-note span { color: var(--cyan); font-weight: 800; letter-spacing: .1em; }

.is-hidden { display: none !important; }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) 238px; }
  .info-panel { padding: 9px; }
  .stat-card { padding: 11px 9px; }
  .stat-card strong { font-size: 15px; }
}

@media (max-width: 740px) {
  .app-shell { padding: 14px 10px 13px; }
  .topbar { margin-bottom: 10px; }
  .game-layout { display: flex; flex-direction: column; gap: 10px; }
  .game-card { width: 100%; padding: 7px; border-radius: 18px; }
  .game-frame { height: min(75dvh, 700px); min-height: 450px; border-radius: 13px; }
  .touch-note { margin-top: 7px; font-size: 10px; }
  .info-panel { width: 100%; grid-template-columns: 1.3fr 1fr 1fr; align-items: stretch; padding: 8px; }
  .stat-grid { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
  .stat-card { padding: 9px 8px; }
  .stat-card strong { margin-top: 5px; font-size: 14px; }
  .combo-card, .tip-card { min-height: 104px; }
  .side-controls { grid-column: 1 / -1; }
  .footer-note { margin-top: 9px; font-size: 10px; }
}

@media (max-width: 470px) {
  .brand h1 { font-size: 20px; }
  .icon-button { width: 34px; height: 34px; }
  .game-frame { height: min(72dvh, 640px); min-height: 410px; }
  .screen-overlay { padding: 13px; }
  .menu-panel, .help-panel { padding: 25px 18px; border-radius: 18px; }
  .menu-panel h2 { font-size: 40px; }
  .menu-panel .lead { font-size: 13px; }
  .micro-copy { font-size: 10px; }
  .info-panel { grid-template-columns: 1fr 1fr; }
  .combo-card, .tip-card { min-height: 0; }
  .stat-grid { grid-column: 1 / -1; }
}

@media (orientation: landscape) and (max-height: 640px) {
  .app-shell { padding-top: 8px; }
  .topbar { margin-bottom: 6px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 230px; }
  .game-frame { height: calc(100dvh - 92px); min-height: 430px; }
  .footer-note { display: none; }
}

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