:root {
  color-scheme: light;
  --ink: #13295b;
  --ink-soft: #28447a;
  --sky: #78d9ff;
  --sky-deep: #50bde9;
  --cream: #fff8df;
  --paper: #ffffff;
  --coral: #ff756b;
  --yellow: #ffd947;
  --mint: #79e3bd;
  --shadow: 0 26px 70px rgba(19, 41, 91, 0.24);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.95) 0 4%, transparent 16%),
    radial-gradient(circle at 87% 90%, rgba(255, 217, 71, 0.28) 0 6%, transparent 24%),
    linear-gradient(145deg, #dff7ff 0%, #85ddff 45%, #52c5ee 100%);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.page-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 38px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
}

.game-card {
  width: 100%;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow), 8px 8px 0 rgba(19, 41, 91, 0.98);
}

.game-header {
  min-height: 78px;
  padding: 13px 16px 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--cream);
  border-bottom: 4px solid var(--ink);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-kicker {
  color: #e24e50;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.brand-title {
  margin-top: 5px;
  font-size: clamp(1rem, 2.3vw, 1.55rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 9px;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--yellow);
  outline: none;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.icon-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--sky);
  isolation: isolate;
}

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

.hud {
  position: absolute;
  z-index: 4;
  inset: 14px 14px auto;
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
}

.hud-chip {
  min-height: 44px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 3px solid var(--ink);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  backdrop-filter: blur(8px);
}

.hud-label {
  color: var(--ink-soft);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.hud-chip strong {
  font-size: 0.96rem;
  font-variant-numeric: tabular-nums;
}

.hud-chip--note {
  background: rgba(255, 246, 187, 0.96);
}

.hud-chip--lives {
  margin-left: auto;
  background: rgba(255, 238, 239, 0.96);
  color: #e84e55;
}

.note-mark {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
}

.game-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  padding: clamp(18px, 4vw, 42px);
  display: grid;
  place-items: center;
  background: rgba(19, 41, 91, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 240ms ease, visibility 240ms ease;
  backdrop-filter: blur(3px);
}

.game-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.overlay-panel {
  position: relative;
  width: min(540px, 100%);
  padding: clamp(22px, 4vw, 38px);
  border: 4px solid var(--ink);
  border-radius: 27px;
  background: var(--cream);
  text-align: center;
  box-shadow: 8px 8px 0 var(--ink);
}

.overlay-panel--start {
  padding-right: clamp(128px, 24vw, 210px);
  text-align: left;
}

.hero-tena {
  position: absolute;
  right: -22px;
  bottom: -8px;
  width: min(44%, 220px);
  height: auto;
  filter: drop-shadow(5px 7px 0 rgba(19, 41, 91, 0.18));
  transform: rotate(-4deg);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 7px;
  color: #e24e50;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.overlay-panel h1,
.overlay-panel h2 {
  margin: 0;
  color: var(--ink);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1.15;
}

.overlay-panel h1 {
  font-size: clamp(1.8rem, 4.5vw, 3.25rem);
}

.overlay-panel h2 {
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.overlay-copy {
  margin: 13px 0 20px;
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.75;
}

.primary-button {
  min-height: 54px;
  padding: 10px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--coral);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  filter: brightness(1.07);
  outline: none;
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.primary-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.35);
  opacity: 0.72;
  transform: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.keyboard-hint {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

kbd {
  min-width: 25px;
  padding: 3px 7px;
  display: inline-block;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  font-family: inherit;
  text-align: center;
}

.result-score {
  margin: 22px auto 0;
  padding: 12px 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  border: 3px solid var(--ink);
  border-radius: 15px;
  background: #fff;
}

.result-score span {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 900;
}

.result-score strong {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

.pause-label {
  position: absolute;
  z-index: 7;
  top: 50%;
  left: 50%;
  padding: 15px 24px;
  border: 4px solid var(--ink);
  border-radius: 16px;
  background: var(--yellow);
  color: var(--ink);
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 1000;
  letter-spacing: 0.12em;
  box-shadow: 6px 6px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.9);
  transition: opacity 160ms ease, transform 160ms ease;
}

.pause-label.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.control-bar {
  min-height: 64px;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 4px solid var(--ink);
  background: var(--cream);
}

.control-copy {
  flex: 1;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.controller-status,
.controller-guide {
  display: block;
  margin-top: 5px;
  font-size: 0.75rem;
  line-height: 1.65;
}

.controller-status[data-connected="true"] {
  color: #17644c;
}

.controller-guide[hidden] {
  display: none;
}

.progress-track {
  position: relative;
  flex: 0 1 300px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--mint);
}

.progress-runner {
  position: absolute;
  top: 50%;
  left: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  color: var(--coral);
  font-size: 0.52rem;
  box-shadow: 2px 2px 0 var(--ink);
  transform: translate(-50%, -50%);
}

.touch-controls {
  width: 100%;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  user-select: none;
}

.touch-direction {
  display: flex;
  gap: 13px;
}

.touch-button {
  width: 68px;
  height: 60px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: rgba(255, 248, 223, 0.96);
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 5px 5px 0 var(--ink);
  touch-action: none;
}

.touch-button--jump {
  width: 92px;
  background: var(--coral);
  color: #fff;
  font-size: 0.9rem;
}

.touch-button.is-pressed {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.mobile-only {
  display: none;
}

@media (hover: none), (pointer: coarse) {
  .page-shell {
    align-content: center;
  }

  .touch-controls {
    display: flex;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline;
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 10px;
    align-content: start;
  }

  .game-card {
    border-width: 3px;
    border-radius: 20px;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .game-header {
    min-height: 62px;
    padding: 9px 10px 8px 13px;
    border-bottom-width: 3px;
  }

  .brand-kicker {
    font-size: 0.58rem;
  }

  .brand-title {
    font-size: 0.91rem;
  }

  .icon-button {
    width: 37px;
    height: 37px;
    border-width: 2px;
    border-radius: 11px;
  }

  .hud {
    inset: 7px 7px auto;
    gap: 5px;
  }

  .hud-chip {
    min-height: 32px;
    padding: 3px 7px;
    gap: 5px;
    border-width: 2px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .hud-label {
    display: none;
  }

  .hud-chip strong {
    font-size: 0.74rem;
  }

  .note-mark {
    width: 19px;
    height: 19px;
    font-size: 0.68rem;
  }

  .overlay-panel {
    border-width: 3px;
    border-radius: 18px;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .overlay-panel--start {
    padding: 20px 112px 18px 18px;
  }

  .overlay-panel h1 {
    font-size: clamp(1.28rem, 6.2vw, 2rem);
  }

  .overlay-copy {
    margin: 8px 0 12px;
    font-size: 0.76rem;
    line-height: 1.55;
  }

  .hero-tena {
    right: -8px;
    width: 38%;
  }

  .primary-button {
    min-height: 43px;
    padding: 7px 12px;
    gap: 10px;
    border-width: 2px;
    border-radius: 12px;
    font-size: 0.78rem;
    box-shadow: 3px 3px 0 var(--ink);
  }

  .keyboard-hint {
    display: none;
  }

  .control-bar {
    flex-wrap: wrap;
    min-height: 48px;
    padding: 8px 10px;
    gap: 12px;
    border-top-width: 3px;
  }

  .control-copy {
    flex-basis: 100%;
    font-size: 0.66rem;
  }

  .progress-track {
    flex-basis: 130px;
    height: 11px;
  }

  .progress-runner {
    width: 17px;
    height: 17px;
  }
}

@media (max-width: 480px) {
  .page-shell {
    min-height: auto;
  }

  .game-overlay {
    padding: 10px;
  }

  .overlay-panel--start {
    padding-right: 104px;
  }

  .overlay-panel h1 {
    font-size: 1.22rem;
  }

  .overlay-copy {
    font-size: 0.7rem;
  }
}

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