
  :root {
    --bg: #0c1322;
    --panel: rgba(14, 22, 42, 0.94);
    --gold: #ffd447;
    --cyan: #38e8ff;
    --green: #38d97c;
    --red: #ff4d6a;
    --ink: #f4f8ff;
    --muted: #93a7cc;
    --font: 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', system-ui, -apple-system, sans-serif;
  }

  * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    touch-action: none;
  }

  #error-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: #991b2b;
    color: #fff;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 800;
    display: none;
    white-space: pre-wrap;
    border-bottom: 2px solid var(--gold);
  }

  #app {
    position: relative;
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: radial-gradient(circle at 50% 25%, #1a2d52 0%, #0b1220 75%);
  }

  /* 上部レトロアーケード風スコアボード */
  #scoreboard {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: linear-gradient(180deg, #16223d 0%, #0d1528 100%);
    border-bottom: 2px solid var(--gold);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
    z-index: 30;
    min-height: 52px;
  }

  .sb-scores {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .sb-player {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 8px;
    background: rgba(8, 13, 26, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    white-space: nowrap;
  }
  .sb-player.serving {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(255, 212, 71, 0.35);
  }
  .sb-serve-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d8ff38;
    box-shadow: 0 0 8px #d8ff38;
    visibility: hidden;
  }
  .sb-player.serving .sb-serve-dot { visibility: visible; }
  .sb-name {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.03em;
  }
  .sb-games {
    font-size: 13px;
    font-weight: 900;
    color: var(--cyan);
    background: rgba(56, 232, 255, 0.12);
    padding: 1px 6px;
    border-radius: 5px;
  }
  .sb-pts {
    font-size: 15px;
    font-weight: 900;
    color: var(--gold);
    min-width: 34px;
    text-align: center;
  }

  .sb-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    white-space: nowrap;
  }
  .sb-speed {
    font-size: 13px;
    font-weight: 900;
    color: #fff;
    background: rgba(255, 77, 106, 0.22);
    border: 1px solid rgba(255, 77, 106, 0.6);
    padding: 2px 9px;
    border-radius: 999px;
  }
  .sb-match-tag {
    font-size: 10px;
    font-weight: 800;
    color: var(--muted);
    margin-top: 2px;
  }

  .sb-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
  }

  .sb-btn {
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    background: rgba(20, 32, 58, 0.9);
    color: var(--ink);
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
  }
  .sb-btn:active { transform: scale(0.95); }
  .sb-btn.on {
    background: rgba(56, 217, 124, 0.22);
    border-color: var(--green);
    color: #dfffea;
  }
  .sb-btn.pad-on {
    background: rgba(56, 232, 255, 0.2);
    border-color: var(--cyan);
    color: var(--cyan);
  }

  /* メイン 2.5D Canvas ステージ */
  #stage-wrap {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 6px;
  }

  #game-canvas {
    display: block;
    border-radius: 12px;
    box-shadow: 0 0 0 2px rgba(255, 212, 71, 0.35), 0 18px 46px rgba(0, 0, 0, 0.72);
    background: #143828;
  }

  /* スマホ用バーチャルタッチUI */
  #touch-ui {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 35;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 14px 18px 18px;
    pointer-events: none;
  }
  #touch-ui.show { display: flex; }

  #v-stick-zone {
    position: relative;
    width: 132px;
    height: 132px;
    border-radius: 50%;
    background: rgba(14, 22, 42, 0.48);
    border: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: auto;
    touch-action: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  }
  #v-stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    margin-left: -26px;
    margin-top: -26px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff, #38e8ff);
    border: 2.5px solid #0b1220;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
    pointer-events: none;
  }

  .v-btns {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
  }
  .v-btn {
    border-radius: 50%;
    font-weight: 900;
    color: #0b1220;
    border: 3px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none;
    cursor: pointer;
  }
  .v-btn:active, .v-btn.pressed { transform: scale(0.92); filter: brightness(1.12); }
  #v-btn-lob {
    width: 62px;
    height: 62px;
    background: linear-gradient(145deg, #d8ff70, #78d638);
    font-size: 12px;
  }
  #v-btn-cut {
    width: 70px;
    height: 70px;
    background: linear-gradient(145deg, #7befff, #1ea8e6);
    font-size: 13px;
  }
  #v-btn-shot {
    width: 86px;
    height: 86px;
    background: linear-gradient(145deg, #ffe566, #ff9922);
    font-size: 16px;
  }
  .v-btn small { font-size: 9px; opacity: 0.85; }

  /* オーバーレイ共通 */
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(7, 11, 22, 0.82);
    backdrop-filter: blur(5px);
  }
  .overlay.show { display: flex; }

  .modal {
    width: min(96vw, 720px);
    max-height: 94dvh;
    overflow-y: auto;
    background: linear-gradient(180deg, #172442 0%, #0e162b 100%);
    border: 2.5px solid var(--gold);
    border-radius: 18px;
    padding: 16px 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.82), 0 0 32px rgba(255, 212, 71, 0.16);
    display: flex;
    flex-direction: column;
    gap: 11px;
  }
  .modal.narrow { width: min(94vw, 470px); text-align: center; }

  .title-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .lang-switch {
    display: inline-flex;
    background: rgba(7, 11, 24, 0.88);
    border: 1.5px solid rgba(56, 232, 255, 0.5);
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
  }
  .lang-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .lang-btn.active {
    background: var(--cyan);
    color: #0b1220;
  }

  .title-head { text-align: center; }
  .title-badge {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 999px;
    background: rgba(255, 212, 71, 0.16);
    border: 1px solid var(--gold);
    color: var(--gold);
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 0.12em;
  }
  .title-logo {
    margin: 4px 0 2px;
    font-size: clamp(24px, 5vw, 35px);
    font-weight: 900;
    letter-spacing: 0.05em;
    background: linear-gradient(180deg, #ffffff 0%, #ffd447 62%, #ff7b3b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .title-sub {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
  }

  .sec-lbl {
    font-size: 11.5px;
    font-weight: 900;
    color: var(--cyan);
    margin-bottom: 5px;
    letter-spacing: 0.04em;
  }

  .char-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  .sel-card {
    background: rgba(10, 16, 32, 0.88);
    border: 2px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 9px 8px;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .sel-card:hover { transform: translateY(-2px); border-color: rgba(255, 212, 71, 0.6); }
  .sel-card.selected {
    border-color: var(--gold);
    background: rgba(34, 48, 84, 0.95);
    box-shadow: 0 0 16px rgba(255, 212, 71, 0.35);
  }

  .c-name { font-size: 13px; font-weight: 900; display: flex; align-items: center; justify-content: space-between; }
  .c-tag { font-size: 10px; font-weight: 800; color: var(--gold); }
  .stat-row { display: flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 800; color: var(--muted); }
  .stat-row span { width: 26px; }
  .stat-bar { flex: 1; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; }
  .stat-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #38e8ff, #ffd447); }

  .opt-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .opt-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

  .opt-pill {
    background: rgba(10, 16, 32, 0.88);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
  }
  .opt-pill small { display: block; font-size: 10px; color: var(--muted); font-weight: 700; margin-top: 2px; }
  .opt-pill.selected {
    border-color: var(--gold);
    background: rgba(34, 48, 84, 0.95);
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 212, 71, 0.3);
  }

  .row-wrap.pad-focus {
    padding: 6px;
    margin: -6px;
    border-radius: 12px;
    background: rgba(56, 232, 255, 0.08);
    box-shadow: inset 0 0 0 1.5px rgba(56, 232, 255, 0.55);
  }

  .btn-start {
    border: none;
    border-radius: 12px;
    padding: 13px 22px;
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: #0b1220;
    background: linear-gradient(135deg, #ffe566 0%, #ffaa2b 100%);
    box-shadow: 0 5px 0 #945908, 0 0 24px rgba(255, 212, 71, 0.45);
    cursor: pointer;
    width: 100%;
  }
  .btn-start:active { transform: translateY(2px); }
  .btn-start.pad-focus { outline: 3px solid var(--cyan); outline-offset: 2px; }

  .btn-share-x {
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 12px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 900;
    color: #ffffff;
    background: linear-gradient(135deg, #11141c 0%, #22293a 100%);
    box-shadow: 0 4px 0 #06080e;
    cursor: pointer;
    width: 100%;
    transition: transform 0.1s ease, border-color 0.15s ease, filter 0.15s ease;
  }
  .btn-share-x:hover { border-color: var(--cyan); filter: brightness(1.12); }
  .btn-share-x:active { transform: translateY(2px) scale(0.98); }

  .btn-sub {
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    background: rgba(16, 24, 46, 0.9);
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
  }

  .studio-link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 13px;
    border-radius: 12px;
    background: rgba(8, 14, 30, 0.85);
    border: 1px solid rgba(56, 232, 255, 0.38);
    color: var(--ink);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  }
  .studio-link-card:hover {
    border-color: var(--gold);
    background: rgba(18, 28, 56, 0.92);
  }
  .studio-link-card:active { transform: scale(0.98); }
  .studio-link-sub {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    margin-top: 1px;
  }
  .studio-link-arrow {
    color: var(--gold);
    font-size: 14px;
    font-weight: 900;
    flex-shrink: 0;
  }

  .ctrl-guide {
    background: rgba(8, 12, 24, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
  }
  .ctrl-guide strong { color: var(--ink); }

  .res-score-big {
    font-size: 32px;
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 0.06em;
  }
  .res-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .res-box {
    background: rgba(8, 13, 26, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 8px 6px;
  }
  .res-lbl { font-size: 10px; color: var(--muted); font-weight: 800; }
  .res-val { font-size: 16px; font-weight: 900; color: var(--cyan); margin-top: 2px; }

  @media (max-width: 720px) {
    .char-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ctrl-guide { grid-template-columns: 1fr; }
    .sb-match-tag { display: none; }
    .sb-name { font-size: 11px; }
    .sb-pts { font-size: 13px; min-width: 26px; }
    .sb-btn { padding: 4px 6px; font-size: 10.5px; }
  }
