:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #687086;
  --line: #dfe4ef;
  --primary: #ff6b4a;
  --primary-dark: #dd472c;
  --secondary: #2f80ed;
  --navy: #111827;
  --success: #19a974;
  --ad-height: 60px;
  --radius: 20px;
  --shadow: 0 16px 44px rgba(25, 36, 62, .15);
  --font: "Hiragino Maru Gothic ProN", "Yu Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
a {
  font: inherit;
}

button {
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: calc(100dvh - var(--ad-height) - env(safe-area-inset-bottom));
  min-height: 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.title-screen {
  padding: calc(22px + env(safe-area-inset-top)) 20px 22px;
  background:
    radial-gradient(circle at 18% 20%, rgba(47, 128, 237, .19), transparent 28%),
    radial-gradient(circle at 82% 75%, rgba(255, 107, 74, .22), transparent 32%),
    linear-gradient(145deg, #f9fbff, #eef2fa);
}

.title-card,
.panel,
.result-card,
.modal-card {
  width: min(92vw, 420px);
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.title-card {
  padding: 30px 22px 26px;
  text-align: center;
}

.brand,
.eyebrow {
  color: var(--secondary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
}

h1 {
  margin: 8px 0 12px;
  font-size: clamp(34px, 10vw, 48px);
  line-height: 1.08;
  font-weight: 1000;
  letter-spacing: -.04em;
}

h1 span {
  color: var(--primary);
}

.tagline {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease;
}

.btn:active {
  transform: translateY(2px) scale(.99);
}

.btn-large {
  min-height: 58px;
  font-size: 19px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  box-shadow: 0 5px 0 #b9321d;
}

.btn-secondary {
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
}

.btn-disabled {
  color: #8c93a4;
  background: #eceff5;
  cursor: default;
}

.mrs-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid #aab1c1;
}

.panel {
  max-height: calc(100% - 24px - env(safe-area-inset-top));
  padding: 20px 16px;
  overflow: hidden;
}

.stage-panel {
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin-bottom: 14px;
  text-align: center;
}

.panel-header h2 {
  margin-top: 3px;
  font-size: 21px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: #eef1f7;
  font-weight: 1000;
  font-size: 18px;
  cursor: pointer;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 10px;
}

.stage-button {
  min-height: 76px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.stage-button:active {
  transform: scale(.98);
  border-color: var(--secondary);
}

.stage-button strong,
.stage-button span {
  display: block;
}

.stage-button strong {
  font-size: 15px;
}

.stage-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.stage-button em {
  display: block;
  margin-top: 5px;
  color: var(--success);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.game-screen {
  flex-direction: column;
  background: #ccd5e4;
}

.game-header {
  flex: 0 0 auto;
  width: 100%;
  min-height: 48px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  display: grid;
  grid-template-columns: minmax(78px, 1fr) auto auto 40px;
  gap: 7px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.stage-name {
  overflow: hidden;
  font-size: 11px;
  font-weight: 1000;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-stat {
  font-size: 14px;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.lives {
  color: #e33d52;
}

.game-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, #cad4e4, #aebbd0);
}

#game-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 360 / 560;
  background: #111827;
  box-shadow:
    0 0 0 4px #334155,
    0 0 0 6px rgba(238, 244, 255, .8),
    0 8px 30px rgba(17, 24, 39, .48);
  touch-action: none;
}

.launch-guide {
  position: absolute;
  left: 50%;
  bottom: 54px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
  animation: guide-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes guide-pulse {
  to { transform: translateX(-50%) scale(1.04); opacity: .78; }
}

.effect-bar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  max-width: calc(100% - 16px);
  pointer-events: none;
}

.effect-chip {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .88);
  color: var(--ink);
  font-size: 9px;
  font-weight: 1000;
  white-space: nowrap;
}

.result-screen {
  padding: calc(20px + env(safe-area-inset-top)) 18px 20px;
  background: radial-gradient(circle at top, #fff, #e9eef7);
}

.result-card {
  padding: 28px 22px;
  text-align: center;
}

.result-icon {
  font-size: 48px;
}

.result-card h2 {
  margin-top: 5px;
  font-size: 24px;
}

.result-time {
  margin: 14px 0 4px;
  color: var(--primary-dark);
  font-size: 40px;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.best-message {
  min-height: 20px;
  margin-bottom: 14px;
  color: var(--success);
  font-size: 13px;
  font-weight: 900;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 16, 30, .68);
}

.modal-card {
  padding: 26px 22px;
  text-align: center;
}

.modal-card h2 {
  margin-bottom: 18px;
}

.setting-toggle {
  width: 100%;
  margin: 8px 0;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.setting-toggle strong {
  min-width: 48px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--success);
  font-size: 11px;
}

.setting-toggle.off strong {
  background: #99a0af;
}

.ad-banner {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 1000;
  width: 100%;
  min-height: calc(var(--ad-height) + env(safe-area-inset-bottom));
  padding: 1px 0 calc(1px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  background: #121212;
  border-top: 1px solid #333;
}

.ad-inner {
  max-width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

@media (max-height: 600px) {
  .title-card { padding: 20px 18px; }
  .tagline { margin-bottom: 12px; }
  .mrs-link { margin-top: 11px; }
  .stage-button { min-height: 65px; }
}

@media (min-width: 700px) {
  .stage-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel { width: min(88vw, 680px); }
}

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