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

    html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #87ceeb;
      font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "Yu Gothic UI", "Meiryo", system-ui, -apple-system, sans-serif;
      touch-action: none;
    }

    #game-container {
      position: relative;
      width: 100vw;
      height: 100%;
      height: 100dvh;
      overflow: hidden;
    }

    @media (min-width: 769px) {
      .modal-card {
        max-width: 560px;
        padding: 28px 30px 26px;
      }
      .hud-pill {
        font-size: 16px;
        padding: 8px 16px;
      }
      .hud-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
      }
      .stick-zone {
        opacity: 0.65;
      }
      .stick-zone:hover {
        opacity: 0.95;
      }
    }

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

    .title-screen :is(#hud, #controls-layer, #desktop-hint) {
      visibility: hidden;
    }

    #hud-layer {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
      pointer-events: none;
    }

    /* Top HUD */
    #hud {
      position: relative;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      z-index: 10;
      gap: 8px;
    }

    #hud-left-col {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 6px;
      min-width: 0;
      flex: 1 1 auto;
    }

    .hud-group {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }

    #hud-actions {
      flex-shrink: 0;
      flex-wrap: nowrap;
    }

    .hud-pill {
      background: rgba(255, 255, 255, 0.94);
      border-radius: 999px;
      padding: 6px 14px;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
      font-weight: 800;
      font-size: 14px;
      color: #1e293b;
      display: flex;
      align-items: center;
      gap: 6px;
      border: 2px solid rgba(255, 255, 255, 0.95);
    }

    #role-badge {
      transition: background 0.25s, color 0.25s, transform 0.25s;
      font-size: 15px;
    }

    #role-badge.runner {
      background: linear-gradient(135deg, #2563eb, #38bdf8);
      color: #ffffff;
      border-color: #bae6fd;
    }

    #role-badge.oni {
      background: linear-gradient(135deg, #dc2626, #f97316);
      color: #ffffff;
      border-color: #fecaca;
      animation: pulseOni 1s infinite alternate;
    }

    @keyframes pulseOni {
      from { transform: scale(1); box-shadow: 0 3px 12px rgba(220, 38, 38, 0.45); }
      to { transform: scale(1.05); box-shadow: 0 4px 18px rgba(239, 68, 68, 0.75); }
    }

    .hud-btn {
      pointer-events: auto;
      background: rgba(255, 255, 255, 0.92);
      border: 2px solid #ffffff;
      border-radius: 999px;
      width: 38px;
      height: 38px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      cursor: pointer;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
      color: #1e293b;
      transition: transform 0.12s;
    }

    .hud-btn:active {
      transform: scale(0.92);
    }

    /* Temporary warnings below the main HUD */
    #sub-hud {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      pointer-events: none;
      max-width: 100%;
    }

    .mini-chip {
      background: rgba(15, 23, 42, 0.65);
      color: #f8fafc;
      font-size: 12px;
      font-weight: 700;
      padding: 4px 10px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      width: fit-content;
    }

    #oni-count-pill[hidden], #fall-count-pill[hidden] {
      display: none;
    }

    /* Role swap banner */
    #banner {
      position: relative;
      width: max-content;
      max-width: 100%;
      margin: 5px auto 0;
      transform: scale(0.9);
      transform-origin: center top;
      padding: 5px 10px;
      border-radius: 999px;
      font-weight: 900;
      font-size: clamp(13px, 3.5vw, 16px);
      color: #ffffff;
      text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
      opacity: 0;
      transition: opacity 0.22s ease, transform 0.22s ease;
      z-index: 25;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      text-align: center;
      line-height: 1.3;
      border: 2px solid rgba(255, 255, 255, 0.85);
    }

    #banner.show {
      opacity: 1;
      transform: scale(1);
    }

    #banner.oni-banner {
      background: linear-gradient(135deg, #dc2626, #ea580c);
    }

    #banner.runner-banner {
      background: linear-gradient(135deg, #0284c7, #10b981);
    }

    /* Damage / Oni flash overlay */
    #screen-flash {
      position: absolute;
      inset: 0;
      pointer-events: none;
      opacity: 0;
      z-index: 20;
      transition: opacity 0.35s ease;
    }

    /* Fleeing kid speech bubbles */
    #speech-bubbles {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 13;
      overflow: hidden;
    }

    .speech-bubble {
      position: absolute;
      left: 0;
      top: 0;
      display: none;
      will-change: transform;
      background: rgba(255, 255, 255, 0.96);
      color: #0f172a;
      font-size: 12px;
      font-weight: 800;
      padding: 5px 10px;
      border-radius: 14px;
      border: 2px solid #38bdf8;
      box-shadow: 0 3px 8px rgba(15, 23, 42, 0.18);
      white-space: nowrap;
      max-width: 190px;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.25;
    }

    body.mobile-lite .speech-bubble,
    body.mobile-lite .hud-pill,
    body.mobile-lite .hud-btn {
      box-shadow: none !important;
    }
    body.mobile-lite #role-badge.oni {
      animation: none !important;
    }

    .speech-bubble::after {
      content: "";
      position: absolute;
      left: 50%;
      bottom: -8px;
      transform: translateX(-50%);
      border-width: 8px 6px 0 6px;
      border-style: solid;
      border-color: #38bdf8 transparent transparent transparent;
    }

    .speech-bubble::before {
      content: "";
      position: absolute;
      left: 50%;
      bottom: -5px;
      transform: translateX(-50%);
      border-width: 6px 4.5px 0 4.5px;
      border-style: solid;
      border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
      z-index: 1;
    }

    @keyframes bubblePop {
      from { transform: translate(-50%, -85%) scale(0.7); opacity: 0; }
      to { transform: translate(-50%, -100%) scale(1); opacity: 1; }
    }

    /* Off-screen kid edge arrows (鬼むずモード) */
    #edge-arrows {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 14;
      overflow: hidden;
    }

    .edge-arrow {
      position: absolute;
      left: 0;
      top: 0;
      display: none;
      will-change: transform;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }

    .edge-arrow-tri {
      width: 0;
      height: 0;
      border-left: 11px solid transparent;
      border-right: 11px solid transparent;
      border-bottom: 20px solid #ffffff;
    }

    .edge-arrow-tag {
      margin-top: 2px;
      font-size: 10px;
      font-weight: 900;
      color: #ffffff;
      background: rgba(15, 23, 42, 0.78);
      padding: 1px 6px;
      border-radius: 999px;
      white-space: nowrap;
      border: 1.5px solid rgba(255, 255, 255, 0.85);
    }

    /* Controls Layer */
    #controls-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 15;
    }

    .stick-zone {
      position: absolute;
      bottom: max(18px, env(safe-area-inset-bottom));
      width: 132px;
      height: 132px;
      pointer-events: auto;
      touch-action: none;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    #left-stick-zone {
      left: max(16px, env(safe-area-inset-left));
    }

    #right-stick-zone {
      right: max(16px, env(safe-area-inset-right));
    }

    .stick-base {
      position: relative;
      width: 118px;
      height: 118px;
      border-radius: 50%;
      background: radial-gradient(circle at center, rgba(255, 255, 255, 0.28), rgba(15, 23, 42, 0.36));
      border: 2.5px solid rgba(255, 255, 255, 0.65);
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22), inset 0 0 14px rgba(255, 255, 255, 0.2);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .stick-arrows {
      position: absolute;
      inset: 6px;
      pointer-events: none;
      font-size: 11px;
      font-weight: 800;
      color: rgba(255, 255, 255, 0.85);
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    .stick-arrows span {
      position: absolute;
    }

    .stick-arrows .a-up { top: 0; left: 50%; transform: translateX(-50%); }
    .stick-arrows .a-down { bottom: 0; left: 50%; transform: translateX(-50%); }
    .stick-arrows .a-left { left: 2px; top: 50%; transform: translateY(-50%); }
    .stick-arrows .a-right { right: 2px; top: 50%; transform: translateY(-50%); }

    .stick-knob {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: radial-gradient(circle at 35% 30%, #ffffff, #cbd5e1);
      border: 2.5px solid #ffffff;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32);
      transform: translate(0px, 0px);
      pointer-events: none;
      transition: background 0.15s;
    }

    #left-stick-knob.active {
      background: radial-gradient(circle at 35% 30%, #e0f2fe, #38bdf8);
    }

    #right-stick-knob.active {
      background: radial-gradient(circle at 35% 30%, #fef3c7, #f59e0b);
    }

    .stick-label {
      position: absolute;
      top: -22px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(15, 23, 42, 0.65);
      color: #ffffff;
      font-size: 11px;
      font-weight: 800;
      padding: 2px 8px;
      border-radius: 999px;
      white-space: nowrap;
      pointer-events: none;
    }

    /* Touch (Reach Hand) Button — shown ONLY when Player is Oni */
    #touch-btn {
      position: absolute;
      right: max(18px, env(safe-area-inset-right));
      bottom: calc(max(18px, env(safe-area-inset-bottom)) + 174px);
      width: 92px;
      height: 92px;
      border-radius: 50%;
      border: 4px solid #fef08a;
      background: radial-gradient(circle at 35% 30%, #ff6b6b, #dc2626 70%, #991b1b);
      color: #ffffff;
      font-weight: 900;
      font-size: 16px;
      line-height: 1.15;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      pointer-events: auto;
      touch-action: none;
      box-shadow: 0 8px 22px rgba(220, 38, 38, 0.55), inset 0 2px 6px rgba(255, 255, 255, 0.45);
      transition: transform 0.08s, filter 0.12s;
      z-index: 18;
    }

    #touch-btn.visible {
      display: flex;
      animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    #touch-btn:active, #touch-btn.pressed {
      transform: scale(0.9);
      filter: brightness(1.15);
    }

    #touch-btn.cooldown {
      opacity: 0.58;
      filter: grayscale(0.35);
    }

    #touch-btn .touch-icon {
      font-size: 28px;
      margin-bottom: 2px;
    }

    #touch-btn .touch-sub {
      font-size: 10px;
      font-weight: 800;
      opacity: 0.95;
    }

    @keyframes popIn {
      from { transform: scale(0.2); opacity: 0; }
      to { transform: scale(1); opacity: 1; }
    }

    /* Desktop hint */
    #desktop-hint {
      position: absolute;
      bottom: 10px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(15, 23, 42, 0.58);
      color: #e2e8f0;
      font-size: 11px;
      font-weight: 600;
      padding: 5px 12px;
      border-radius: 14px;
      pointer-events: none;
      max-width: calc(100vw - 340px);
      white-space: normal;
      text-align: center;
      line-height: 1.35;
      z-index: 12;
    }

    body.mobile-lite #desktop-hint { display: none; }

    @media (max-width: 768px) {
      #desktop-hint { display: none; }
      .hud-pill { padding: 4px 9px; font-size: 12px; gap: 4px; }
      #role-badge { font-size: 12.5px; }
      .hud-btn { width: 34px; height: 34px; font-size: 16px; }
      .mini-chip { font-size: 11px; padding: 3px 8px; }
      .stick-zone { width: 114px; height: 114px; bottom: max(14px, env(safe-area-inset-bottom)); }
      .stick-base { width: 104px; height: 104px; }
      #touch-btn { width: 84px; height: 84px; font-size: 14px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 154px); }
    }

    @media (max-height: 460px) {
      .stick-zone { width: 100px; height: 100px; bottom: max(10px, env(safe-area-inset-bottom)); }
      .stick-base { width: 92px; height: 92px; }
      #touch-btn {
        width: 78px;
        height: 78px;
        font-size: 13px;
        bottom: max(16px, env(safe-area-inset-bottom));
        right: calc(max(16px, env(safe-area-inset-right)) + 116px);
      }
    }

    /* Modals (Start & Result & Pause) */
    .overlay {
      position: absolute;
      inset: 0;
      background: rgba(15, 23, 42, 0.62);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      z-index: 30;
    }

    .overlay.hidden {
      display: none;
    }

    .modal-card {
      background: #ffffff;
      border-radius: 24px;
      max-width: 440px;
      width: 100%;
      padding: 22px 22px 20px;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
      text-align: center;
      border: 4px solid #fde047;
      max-height: calc(100dvh - 32px);
      overflow-y: auto;
      overscroll-behavior: contain;
      touch-action: pan-y;
    }

    .home-card .modal-title {
      margin: 4px 0 16px;
      line-height: 1.2;
    }

    .x-post-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      min-height: 44px;
      margin-top: 8px;
      padding: 6px 12px;
      border: 0;
      border-radius: 11px;
      background: #0f172a;
      color: #fff;
      font-family: inherit;
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
    }

    .home-language {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 8px;
      margin-bottom: 12px;
      min-width: 0;
      font-size: 12px;
      font-weight: 700;
      color: #334155;
    }

    #language-select {
      min-width: 0;
      max-width: min(68%, 180px);
      min-height: 38px;
      padding: 5px 9px;
      border: 1px solid #94a3b8;
      border-radius: 9px;
      color: #172554;
      background: #f8fafc;
      font: inherit;
      font-size: 16px;
    }

    .home-name {
      display: grid;
      gap: 5px;
      text-align: left;
      font-size: 13px;
      font-weight: 800;
      color: #334155;
    }

    #player-name {
      width: 100%;
      min-width: 0;
      min-height: 44px;
      border: 1.5px solid #94a3b8;
      border-radius: 11px;
      padding: 8px 12px;
      color: #0f172a;
      background: #f8fafc;
      font: inherit;
      font-size: 16px;
      user-select: text;
      -webkit-user-select: text;
      touch-action: manipulation;
    }

    .action-link {
      display: block;
      text-decoration: none;
    }

    .home-card .secondary-btn,
    .modal-card .action-link {
      min-height: 44px;
    }

    .modal-card :focus-visible {
      outline: 3px solid #2563eb;
      outline-offset: 2px;
    }

    #result-player-name {
      overflow-wrap: anywhere;
      margin: 5px 0 10px;
    }

    @media (max-height: 500px) and (min-width: 580px) {
      .home-card {
        max-width: 500px;
        padding-top: 13px;
        padding-bottom: 13px;
      }
    }

    .modal-title {
      margin: 0 0 6px;
      font-size: clamp(22px, 5.5vw, 28px);
      font-weight: 900;
      color: #0f172a;
      letter-spacing: -0.02em;
    }

    .modal-sub {
      margin: 0 0 14px;
      font-size: 13px;
      color: #475569;
      font-weight: 600;
    }

    #game-load-status {
      margin: 8px 0 0;
      color: #991b1b;
    }

    #game-load-status:empty {
      display: none;
    }

    .modal-card button:disabled {
      cursor: default;
      opacity: 0.6;
    }

    .guide-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-bottom: 12px;
      text-align: left;
    }

    .guide-box {
      background: #f8fafc;
      border: 1.5px solid #e2e8f0;
      border-radius: 14px;
      padding: 10px;
    }

    .guide-box.full {
      grid-column: 1 / -1;
      background: #fef2f2;
      border-color: #fecaca;
    }

    .guide-box-title {
      font-size: 12px;
      font-weight: 800;
      color: #0f172a;
      margin: 0 0 3px;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .guide-box-desc {
      margin: 0;
      font-size: 13px;
      color: #475569;
      line-height: 1.4;
    }

    .diff-row {
      display: flex;
      gap: 8px;
      margin: 12px 0 16px;
    }

    .diff-btn {
      flex: 1;
      min-width: 0;
      overflow-wrap: anywhere;
      padding: 9px 6px;
      border-radius: 12px;
      border: 2px solid #cbd5e1;
      background: #f8fafc;
      color: #334155;
      font-weight: 800;
      font-size: 13px;
      cursor: pointer;
      transition: all 0.15s;
    }

    .guide-box.points-guide { background: #eff6ff; border-color: #bfdbfe; }
    .guide-box.modes-guide { background: #fff7ed; border-color: #fed7aa; }

    .diff-btn small {
      display: block;
      margin-top: 4px;
      font-size: 10px;
    }

    .diff-btn[data-diff="oni_hard"]:not(.selected) {
      border-color: #fca5a5;
      color: #b91c1c;
    }

    .diff-btn.selected {
      background: #eff6ff;
      border-color: #2563eb;
      color: #1d4ed8;
      box-shadow: 0 2px 8px rgba(37, 99, 235, 0.22);
    }

    .primary-btn {
      width: 100%;
      padding: 14px 20px;
      border-radius: 16px;
      border: none;
      background: linear-gradient(135deg, #f97316, #ef4444);
      color: #ffffff;
      font-size: 18px;
      font-weight: 900;
      cursor: pointer;
      box-shadow: 0 6px 18px rgba(239, 68, 68, 0.4);
      transition: transform 0.12s;
    }

    .primary-btn:active {
      transform: scale(0.97);
    }

    .secondary-btn {
      width: 100%;
      margin-top: 8px;
      padding: 11px 16px;
      border-radius: 14px;
      border: 2px solid #cbd5e1;
      background: #ffffff;
      color: #334155;
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin: 14px 0 16px;
    }

    .stat-card {
      background: #f8fafc;
      border-radius: 14px;
      padding: 10px 8px;
      border: 1.5px solid #e2e8f0;
    }

    .stat-label {
      font-size: 11px;
      color: #64748b;
      font-weight: 700;
    }

    .stat-val {
      font-size: 20px;
      font-weight: 900;
      color: #0f172a;
      margin-top: 2px;
    }

    .result-badge {
      display: inline-block;
      padding: 5px 14px;
      border-radius: 999px;
      font-size: 13px;
      font-weight: 800;
      margin-bottom: 8px;
    }

    .result-badge.win {
      background: #dcfce7;
      color: #15803d;
    }

    .result-badge.lose {
      background: #fee2e2;
      color: #b91c1c;
    }

    .rank-title-box {
      background: linear-gradient(135deg, #fef9c3, #fde047);
      border: 2.5px solid #eab308;
      border-radius: 16px;
      padding: 10px 14px;
      margin: 10px 0 6px;
      box-shadow: 0 4px 12px rgba(234, 179, 8, 0.25);
    }

    .rank-title-label {
      font-size: 11px;
      font-weight: 800;
      color: #854d0e;
    }

    .rank-title-name {
      font-size: 21px;
      font-weight: 900;
      color: #713f12;
      margin-top: 2px;
    }

    .setting-row {
      background: #f8fafc;
      border: 1.5px solid #e2e8f0;
      border-radius: 14px;
      padding: 12px 14px;
      margin: 12px 0 16px;
      text-align: left;
    }

    .setting-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 13px;
      font-weight: 800;
      color: #0f172a;
      margin-bottom: 8px;
    }

    .setting-val {
      color: #2563eb;
      font-weight: 900;
    }

    input[type="range"].styled-slider {
      width: 100%;
      accent-color: #2563eb;
      cursor: pointer;
    }

    .ranking-plays {
      margin: 10px 0 0;
      color: #334155;
      font-size: 13px;
    }

    .result-ranking h3 {
      margin: 14px 0 5px;
      font-size: 15px;
    }

    #result-ranking-status {
      margin: 6px 0;
      font-size: 13px;
    }

    #result-ranking-list {
      max-height: 240px;
      overflow-y: auto;
      overscroll-behavior: contain;
      touch-action: pan-y;
      padding: 0;
      margin: 8px 0 0;
      list-style: none;
    }

    #result-ranking-list li {
      display: grid;
      grid-template-columns: 3ch minmax(0, 1fr) auto;
      gap: 8px;
      padding: 7px 6px;
      border-top: 1px solid #e2e8f0;
      text-align: left;
      overflow-wrap: anywhere;
    }
