:root {
  --bg: radial-gradient(circle at 20% 10%, #365a3b 0%, #143124 48%, #08180f 100%);
  --panel: rgba(15, 23, 42, 0.82);
  --line: rgba(148, 163, 184, 0.4);
  --text: #e2e8f0;
  --sub: #94a3b8;
  --good: #22c55e;
  --miss: #f97316;
  --bad: #ef4444;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}

body.scene-title {
  display: block;
  align-items: initial;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
}

body.scene-play {
  overflow: hidden;
  align-items: center;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body.scene-play * {
  -webkit-user-select: none;
  user-select: none;
}

.app {
  width: 100vw;
  max-width: none;
  margin: auto;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  padding: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  overflow: hidden;
}

.screens {
  min-height: 0;
  overflow: auto;
}

.screens > .panel {
  min-height: 0;
  height: auto;
}

body.scene-play .screens {
  overflow: hidden;
}

body.scene-play .screens > .panel {
  height: 100%;
}

#titleScreen,
#resultScreen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

body.scene-result .app {
  grid-template-rows: auto 1fr;
}

body.scene-result {
  display: block;
  align-items: initial;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
}

body.scene-result .app {
  grid-template-rows: auto auto;
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: visible;
  display: block;
}

body.scene-result .screens {
  overflow: visible;
  min-height: auto;
}

body.scene-result #resultScreen {
  overflow: visible;
  -webkit-overflow-scrolling: auto;
  overscroll-behavior: auto;
  touch-action: auto;
}

body.scene-result .controls-panel,
body.scene-result .brand-bottom {
  display: none;
}

body.scene-title .controls-panel {
  display: none;
}

body.scene-title .app {
  grid-template-rows: auto auto;
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: visible;
  display: block;
}

body.scene-title .screens {
  overflow: visible;
  min-height: auto;
}

body.scene-title #titleScreen {
  overflow: visible;
  -webkit-overflow-scrolling: auto;
  overscroll-behavior: auto;
  touch-action: auto;
}

body.scene-title .brand-bottom {
  display: none;
}

#playScreen {
  overflow: hidden;
  border-radius: 0;
  border: 0;
  background: transparent;
  aspect-ratio: 4 / 5;
  padding: 0;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.controls-panel {
  display: none;
  margin-top: 0;
  --ctrl-panel-h: clamp(220px, 30svh, 320px);
  height: var(--dynamic-ctrl-panel-h, var(--ctrl-panel-h));
  max-height: var(--dynamic-ctrl-panel-h, var(--ctrl-panel-h));
  min-height: var(--dynamic-ctrl-panel-h, var(--ctrl-panel-h));
  width: min(100%, var(--dynamic-play-size, 100%));
  margin-left: auto;
  margin-right: auto;
  padding: var(--dynamic-ctrl-panel-pad, 6px 6px 8px);
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 16px;
}

body.scene-play .controls-panel {
  display: flex;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.badge {
  margin: 0;
  font-size: 0.75rem;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(44vw, 220px);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.brand-bottom {
  display: none;
  text-align: center;
  color: var(--sub);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding-bottom: max(env(safe-area-inset-bottom), 2px);
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body.scene-play .app {
  grid-template-rows: auto 1fr auto auto;
}

body.scene-play .brand-bottom {
  display: block;
}

.panel {
  border: 0;
  border-radius: 0;
  padding: 12px;
}

#titleScreen,
#resultScreen {
  padding: 12px;
}

#titleScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: clamp(12px, 3vw, 24px);
}

#titleScreen .title-art,
#titleScreen .title-card,
#titleScreen .title-screen__cta,
#titleScreen .title-meta-card {
  width: min(100%, 760px);
}

#resultScreen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 1.8vw, 14px);
  background: transparent;
}

#resultScreen::before {
  content: none;
}

#resultScreen > * {
  position: relative;
  z-index: 1;
}

.result-modal-card {
  width: min(100%, 920px);
  border: 2px solid rgba(148, 163, 184, 0.38);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.32);
  box-shadow: 0 6px 0 rgba(7, 20, 13, 0.55);
  padding: clamp(8px, 1.9vw, 14px);
  text-align: center;
}

.result-kicker {
  margin: 0;
  text-align: center;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: #f1f5f9;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.5);
  font-size: clamp(1.28rem, 4.2vw, 2.6rem);
}

.result-kicker--outside {
  width: min(100%, 920px);
  margin: 0 auto 10px;
  text-align: center;
}

.result-top-name {
  margin: 0 0 2px;
  color: #ffef5a;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.45);
  font-size: clamp(0.9rem, 2.7vw, 1.5rem);
}

.result-big-score-label {
  margin: clamp(8px, 1.8vw, 12px) 0 0;
  text-align: center;
  color: #f1f5f9;
  font-weight: 700;
  font-size: clamp(0.95rem, 2.5vw, 1.3rem);
}

.result-big-score {
  margin: 2px 0 clamp(12px, 2.2vw, 16px);
  text-align: center;
  color: #ffef5a;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(15, 23, 42, 0.45);
  font-size: clamp(2rem, 8.8vw, 4.4rem);
}

.result-big-score::after {
  content: " 点";
  font-size: 0.65em;
}

.result-top-title {
  margin: 0 0 clamp(10px, 2vw, 16px);
  color: #e2e8f0;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.5);
  font-size: clamp(1rem, 3.2vw, 1.85rem);
}

.result-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.result-pill {
  border: 2px solid rgba(118, 168, 229, 0.85);
  border-radius: 8px;
  background: rgba(38, 76, 126, 0.92);
  padding: 8px 10px 10px;
  text-align: center;
}

.result-pill span {
  display: block;
  color: #cfe4fb;
  font-size: clamp(0.8rem, 2.2vw, 1rem);
  letter-spacing: 0.04em;
}

.result-pill strong {
  display: block;
  margin-top: 4px;
  color: #f8fbff;
  font-size: clamp(1.35rem, 4.1vw, 2.1rem);
  line-height: 1.1;
}

#playScreen {
  padding: 0;
}

.hidden { display: none; }
.panel.hidden { display: none !important; }
.eyebrow { color: var(--sub); margin: 0; }
.desc { color: var(--sub); }
.rule { margin-top: 22px; }

.title-guide {
  margin-top: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.28);
  padding: 10px 12px;
  text-align: left;
}

.title-guide p {
  margin: 0 0 6px;
  font-size: 0.84rem;
  color: #cbd5e1;
  font-weight: 700;
}

.title-guide ul {
  margin: 0;
  padding-left: 1.1rem;
  color: #e2e8f0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.title-card {
  margin-top: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.28);
  padding: clamp(12px, 2.8vw, 18px);
  text-align: center;
}

.title-card__heading {
  margin: 0;
  font-size: clamp(1.15rem, 4.6vw, 1.8rem);
  letter-spacing: 0.04em;
  color: #f1f5f9;
}

.title-card__label {
  margin: 0;
  color: #ffffff;
  font-size: clamp(1.05rem, 3.5vw, 1.45rem);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.5);
}

.title-card__nickname {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.15rem, 4.2vw, 1.6rem);
  color: #ffef5a;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.45);
}

.rules-detail {
  margin-top: 10px;
}

.rules-detail__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.72);
  color: #e2e8f0;
  min-height: 46px;
  display: grid;
  place-items: center;
  font-size: clamp(0.9rem, 3vw, 1.08rem);
  letter-spacing: 0.04em;
}

.rules-detail__summary::-webkit-details-marker {
  display: none;
}

.rules-detail[open] .rules-detail__summary {
  margin-bottom: 10px;
}

.rules-detail__body {
  text-align: left;
}

.title-card__list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: clamp(0.92rem, 2.9vw, 1.12rem);
  line-height: 1.52;
}

.title-card__list li + li {
  margin-top: 6px;
}

.title-card__nickname-action {
  margin-top: 8px;
}

.title-choice-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.title-choice-btn {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: clamp(1rem, 3.2vw, 1.2rem);
  letter-spacing: 0.04em;
}

.title-choice-btn.is-active {
  border-color: rgba(125, 211, 252, 0.95);
  background: rgba(14, 116, 144, 0.82);
  color: #e0f2fe;
  box-shadow: inset 0 0 0 1px rgba(186, 230, 253, 0.35);
}

.title-rank-note {
  margin: 10px 0 0;
  color: #cbd5e1;
  font-size: clamp(0.82rem, 2.6vw, 1rem);
  line-height: 1.45;
}

.nickname-edit-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
  font-size: clamp(0.96rem, 3vw, 1.12rem);
}

.title-screen__cta {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.title-meta-card {
  margin-top: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.24);
  padding: clamp(10px, 2.4vw, 14px);
  text-align: center;
}

.title-meta-btn {
  width: 100%;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.74);
  color: #e2e8f0;
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: clamp(0.98rem, 3vw, 1.1rem);
  letter-spacing: 0.06em;
}

.title-meta-btn.is-off {
  background: rgba(51, 65, 85, 0.66);
  border-color: rgba(100, 116, 139, 0.6);
  color: #94a3b8;
}

.title-meta-links {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #94a3b8;
  font-size: clamp(0.82rem, 2.6vw, 0.95rem);
}

.title-meta-link {
  color: #93c5fd;
  text-decoration: none;
}

.title-meta-link:hover,
.title-meta-link:focus-visible {
  text-decoration: underline;
}

.title-meta-credit {
  margin: 8px 0 0;
  color: #94a3b8;
  font-size: clamp(0.74rem, 2.2vw, 0.86rem);
  letter-spacing: 0.05em;
}

.title-start-btn {
  width: 100%;
  min-height: 78px;
  height: 78px;
  border-width: 2px;
  border-radius: 18px;
  border-color: rgba(96, 165, 250, 0.95);
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 6px 0 #1e40af;
  color: #eef6ff;
  font-family: "DotGothic16", monospace;
  font-size: clamp(1.35rem, 4.8vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
  padding: 8px 10px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.title-start-btn:hover,
.title-start-btn:focus-visible {
  filter: brightness(1.04);
}

.title-start-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #1e40af;
}

.title-rank-btn {
  width: 100%;
  min-height: 54px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.74);
  color: #e2e8f0;
  font-size: clamp(0.98rem, 3.1vw, 1.18rem);
  letter-spacing: 0.05em;
}

.title-rank-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.title-rank-modal[hidden] {
  display: none;
}

.title-rank-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.68);
}

.title-rank-modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(96vw, 1200px);
  max-height: min(92vh, 960px);
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(186, 230, 253, 0.45);
  background: linear-gradient(180deg, rgba(67, 118, 200, 0.96) 0%, rgba(42, 88, 170, 0.98) 100%);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.5);
  padding: 10px 10px 12px;
}

.title-rank-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.title-rank-modal__title {
  margin: 0;
  color: #eaf2ff;
  text-shadow: 0 3px 0 rgba(44, 77, 140, 0.85);
  font-size: clamp(1.45rem, 5.2vw, 2.7rem);
  letter-spacing: 0.04em;
}

.title-rank-modal__close {
  min-height: 64px;
  min-width: 136px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid rgba(125, 211, 252, 0.8);
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #eff6ff;
  font-size: clamp(1.3rem, 3.2vw, 2rem);
  font-weight: 700;
  box-shadow: 0 6px 0 #1e40af;
}

.leaderboard-box {
  margin-top: 4px;
}

.leaderboard-title {
  margin: 8px 0 4px;
  color: #ffef5a;
  font-size: clamp(1.28rem, 3vw, 1.9rem);
  letter-spacing: 0.02em;
  font-weight: 700;
}

.title-rank-modal .leaderboard-box {
  margin-top: 0;
  border: 1px solid rgba(191, 219, 254, 0.5);
  border-radius: 6px;
  background: rgba(40, 77, 150, 0.78);
  padding: 8px 10px 10px;
}

.title-rank-modal .leaderboard-list {
  border-left: 1px solid rgba(191, 219, 254, 0.45);
  border-right: 1px solid rgba(191, 219, 254, 0.45);
  margin-bottom: 8px;
}

.title-rank-modal .leaderboard-list:last-child {
  margin-bottom: 0;
}

.title-rank-modal .leaderboard-row {
  grid-template-columns: 4.5rem 4rem 1fr auto;
  gap: 10px;
  min-height: 38px;
  padding: 4px 6px;
  border-bottom: 1px dotted rgba(219, 234, 254, 0.6);
  font-size: clamp(1rem, 2.3vw, 1.65rem);
  color: #f8fbff;
  text-align: left;
}

.title-rank-modal .leaderboard-row .lb-rank {
  color: #ffef5a;
  text-align: center;
}

.title-rank-modal .leaderboard-row .lb-time {
  color: #dbeafe;
  text-align: center;
}

.title-rank-modal .leaderboard-row .lb-score {
  color: #f8fbff;
  text-align: right;
}

.title-rank-modal .leaderboard-row .lb-name {
  display: block;
  width: 100%;
  text-align: left;
  justify-self: stretch;
}

.title-rank-modal .leaderboard-empty {
  min-height: 44px;
  font-size: clamp(0.9rem, 2vw, 1.3rem);
  color: #e2e8f0;
}

.title-art {
  display: block;
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  image-rendering: pixelated;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.78rem, 2.8vw, 1rem);
}

.hud > div {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arena-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background-image: var(--arena-wrap-bg, none);
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

#playScreen .arena-wrap {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-top: 0;
  border: 0;
  border-radius: 0;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
  touch-action: none;
  background: var(--game-canvas-bg, linear-gradient(180deg, #2563eb 0%, #22d3ee 60%, #166534 60%, #14532d 100%));
}

/* Layout debug: visualize playScreen / arena-wrap / gameCanvas bounds. */
body.layout-debug #playScreen {
  position: relative;
  outline: 4px solid rgba(239, 68, 68, 0.98);
  outline-offset: 0;
  box-shadow: inset 0 0 0 1px rgba(254, 202, 202, 0.95);
  background: transparent !important;
}

body.layout-debug #playScreen::before {
  content: "playScreen";
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 34;
  font-size: 12px;
  font-weight: 700;
  color: #fee2e2;
  background: rgba(127, 29, 29, 0.88);
  padding: 2px 6px;
  border-radius: 6px;
}

body.layout-debug #playScreen .arena-wrap {
  position: relative;
  outline: 4px solid rgba(59, 130, 246, 0.98);
  outline-offset: -4px;
  box-shadow: inset 0 0 0 2px rgba(191, 219, 254, 0.92);
}

body.layout-debug #playScreen .arena-wrap::before {
  content: "arena-wrap";
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 31;
  font-size: 12px;
  font-weight: 700;
  color: #dbeafe;
  background: rgba(30, 64, 175, 0.88);
  padding: 2px 6px;
  border-radius: 6px;
}

body.layout-debug #playScreen #gameCanvas {
  outline: 4px solid rgba(34, 197, 94, 0.98);
  outline-offset: -8px;
  box-shadow: inset 0 0 0 1px rgba(187, 247, 208, 0.98);
}

.judge {
  margin: 8px 0 0;
  min-height: 1.2em;
  text-align: center;
}

.controls {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  height: 100%;
}

.controls.gamepad {
  grid-template-columns: auto auto;
  width: max-content;
  max-width: 100%;
  gap: var(--dynamic-gamepad-gap, 20px);
  align-items: center;
  align-content: center;
  justify-content: center;
  --ctrl-size: var(--dynamic-ctrl-size, clamp(56px, 10.2svh, 88px));
}

.controls.gamepad.classic3 {
  width: 100%;
  max-width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2.8vw, 18px);
  padding-inline: clamp(8px, 2.8vw, 18px);
}

.controls.gamepad.classic3 .input-btn {
  width: 100%;
  min-height: 0;
  height: clamp(82px, 15svh, 124px);
  aspect-ratio: auto;
  font-size: clamp(2rem, 8vw, 3rem);
}

.controls.gamepad.classic3 .input-btn.action {
  font-size: clamp(1rem, 3.8vw, 1.5rem);
  font-weight: 700;
  white-space: nowrap;
}

.controls.gamepad.classic3 .input-btn.has-sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.controls.gamepad.classic3 .input-btn .btn-main {
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1;
}

.controls.gamepad.classic3 .input-btn .btn-sub {
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: clamp(0.9rem, 2.8vw, 1.2rem);
  line-height: 1.1;
  font-weight: 700;
}

.pad-left {
  display: block;
}

.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, var(--ctrl-size));
  justify-content: center;
  --dpad-gap-x: var(--dynamic-dpad-gap-x, 4px);
  --dpad-gap-y: var(--dynamic-dpad-gap-y, 5px);
  column-gap: var(--dpad-gap-x);
  row-gap: var(--dpad-gap-y);
}

.dpad-grid > :nth-child(2) { grid-column: 2; }
.dpad-grid > :nth-child(4) { grid-column: 1; }
.dpad-grid > :nth-child(5) { grid-column: 2; }
.dpad-grid > :nth-child(6) { grid-column: 3; }
.dpad-grid > :nth-child(8) { grid-column: 2; }

.pad-right {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--dynamic-pad-right-gap, 8px);
  align-items: start;
  align-self: center;
}

.action-stack {
  display: grid;
  grid-template-rows: auto;
  gap: 0;
  align-items: center;
  justify-items: center;
}

.action-caption {
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  text-align: center;
  color: var(--sub);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  white-space: nowrap;
}

.pad-ghost {
  width: var(--ctrl-size);
  height: var(--ctrl-size);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.35);
  color: rgba(226, 232, 240, 0.82);
  display: grid;
  place-items: center;
  font-size: calc(var(--ctrl-size) * 0.36);
  font-weight: 700;
  user-select: none;
  pointer-events: none;
}

.pad-spacer {
  width: var(--ctrl-size);
  height: var(--ctrl-size);
}

.pad-spacer-center {
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.16);
}

.primary,
.secondary {
  font: inherit;
  border-radius: 18px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(30, 41, 59, 0.75);
  min-height: 72px;
  line-height: 1.2;
  padding: 10px 12px;
  white-space: nowrap;
}

.input-btn {
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: calc(var(--ctrl-size) * 0.44);
  font-weight: 500;
  width: var(--ctrl-size);
  height: var(--ctrl-size);
  min-height: var(--ctrl-size);
  padding: 0;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.95);
  color: rgba(226, 232, 240, 0.84);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.input-btn.action {
  background: rgba(15, 23, 42, 0.95);
  font-size: calc(var(--ctrl-size) * 0.5);
  font-weight: 500;
  color: rgba(226, 232, 240, 0.84);
}

.input-btn.is-pressed {
  background: rgba(14, 116, 144, 0.92);
  border-color: rgba(125, 211, 252, 0.95);
  box-shadow: inset 0 0 0 2px rgba(125, 211, 252, 0.22);
}

.input-btn.action.is-pressed {
  background: rgba(22, 163, 74, 0.9);
  border-color: rgba(134, 239, 172, 0.95);
  box-shadow: inset 0 0 0 2px rgba(134, 239, 172, 0.24);
}

.input-btn.action.action-sub {
  padding-bottom: 12px;
}

.input-btn.action.action-sub .action-label,
.input-btn.action.action-sub .action-gauge {
  display: none;
}

.action-symbol {
  display: block;
  font-size: 1.9rem;
  line-height: 1;
}

.action-label {
  font-family: "DotGothic16", "Hiragino Sans", "Noto Sans JP", sans-serif;
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: rgba(226, 232, 240, 0.9);
}

.action-gauge {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  height: 6px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(30, 41, 59, 0.9);
  overflow: hidden;
}

.action-gauge-fill {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 80ms linear, background-color 120ms linear;
  background: #f59e0b;
}

.input-btn.action.dash-ready .action-gauge-fill {
  background: #22c55e;
}

.primary {
  background: rgba(14, 116, 144, 0.65);
  width: 100%;
  margin-top: 0;
}

.secondary {
  background: rgba(71, 85, 105, 0.55);
}

.launcher-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 6px;
  margin-top: 2px;
}

.result-grid-item {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.32);
  border-radius: 8px;
  padding: 10px 10px 12px;
}

.result-grid dt,
.result-detail-grid dt {
  color: #cbd5e1;
  font-size: clamp(0.9rem, 2.5vw, 1.12rem);
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.result-grid dd,
.result-detail-grid dd {
  margin: 0;
  font-weight: 700;
  color: #e2e8f0;
  font-size: clamp(1.1rem, 3.1vw, 1.45rem);
  min-width: 0;
  white-space: nowrap;
  text-align: left;
}

.result-detail-toggle {
  margin-top: 10px;
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.72);
  color: #e2e8f0;
  font-family: inherit;
  font-size: clamp(0.95rem, 2.7vw, 1.2rem);
  letter-spacing: 0.05em;
  font-weight: 700;
  cursor: pointer;
}

.result-detail-grid {
  margin: 10px 0 2px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.result-detail-grid.hidden {
  display: none !important;
}

.result-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.result-actions .primary,
.result-actions .secondary {
  min-height: 78px;
  height: 78px;
  border-width: 2px;
  border-radius: 18px;
  font-size: clamp(1.08rem, 3.4vw, 1.6rem);
  letter-spacing: 0.06em;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
  padding: 8px 10px;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.result-actions .primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow: 0 6px 0 #1e40af;
  color: #eef6ff;
}

.result-actions .secondary {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
  border-color: rgba(74, 222, 128, 0.9);
  box-shadow: 0 6px 0 #047857;
  color: #f0fdf4;
}

.result-actions .primary:hover,
.result-actions .secondary:hover,
.result-actions .primary:focus-visible,
.result-actions .secondary:focus-visible {
  filter: brightness(1.04);
}

.result-actions .primary:active,
.result-actions .secondary:active {
  transform: translateY(4px);
}

.result-actions .primary:active {
  box-shadow: 0 2px 0 #1e40af;
}

.result-actions .secondary:active {
  box-shadow: 0 2px 0 #047857;
}

.result-disclosure {
  margin-top: 10px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.3);
  overflow: hidden;
}

.result-disclosure summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  display: grid;
  place-items: center;
  color: #dbeafe;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  margin: 8px;
  background: rgba(39, 82, 140, 0.65);
}

.result-disclosure summary::-webkit-details-marker {
  display: none;
}

.result-disclosure[open] summary {
  margin-bottom: 0;
}

.result-disclosure .leaderboard-box {
  margin: 8px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 10px;
  background: rgba(35, 74, 132, 0.82);
  padding: 6px 8px;
}

.result-disclosure .leaderboard-title {
  margin: 8px 0 6px;
  color: #ffef5a;
  font-weight: 700;
  font-size: clamp(1rem, 2.8vw, 1.28rem);
  letter-spacing: 0.02em;
}

.leaderboard-list {
  border-left: 1px solid rgba(203, 213, 225, 0.45);
  border-right: 1px solid rgba(203, 213, 225, 0.45);
}

.leaderboard-head {
  display: grid;
  grid-template-columns: 3.4rem 3.8rem 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  padding: 2px 6px 4px;
  border-bottom: 1px solid rgba(191, 219, 254, 0.55);
  color: #dbeafe;
  font-size: clamp(0.78rem, 2.2vw, 0.92rem);
  letter-spacing: 0.04em;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 3.4rem 3.8rem 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  padding: 3px 6px;
  border-bottom: 1px dashed rgba(191, 219, 254, 0.45);
  color: #f1f5f9;
  font-size: clamp(0.84rem, 2.4vw, 1rem);
}

.leaderboard-row .lb-rank {
  color: #ffef5a;
  font-weight: 700;
}

.leaderboard-row .lb-time {
  color: #cfe2fa;
  font-variant-numeric: tabular-nums;
}

.leaderboard-row .lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-row .lb-score {
  color: #f1f5f9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.leaderboard-row.is-me .lb-name,
.leaderboard-row.is-me .lb-score {
  color: #bbf7d0;
}

.leaderboard-empty {
  min-height: 36px;
  display: grid;
  place-items: center;
  color: #cbd5e1;
  font-size: clamp(0.82rem, 2.3vw, 0.96rem);
}

/* Legacy ranking list styles (used by title leaderboard modal). */
.result-ranking-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
}

.result-ranking-list li {
  display: grid;
  grid-template-columns: 2.8rem 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: clamp(0.88rem, 2.5vw, 1.05rem);
  line-height: 1.4;
  padding: 4px 0;
  color: #e2e8f0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.4);
}

.result-ranking-list .rank-pos {
  color: #ffef5a;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.result-ranking-list .rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-ranking-list .rank-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #e2e8f0;
}

.result-ranking-list li.is-me .rank-name,
.result-ranking-list li.is-me .rank-score {
  color: #bbf7d0;
}

.result-ranking-empty {
  color: #cbd5e1;
}

.ads-slot {
  margin-top: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  color: #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  background: rgba(15, 23, 42, 0.24);
}

.judge.good { color: var(--good); }
.judge.miss { color: var(--miss); }
.judge.bad { color: var(--bad); }

@supports not (height: 100dvh) {
  .app {
    min-height: 100vh;
  }
}
