    :root {
      color-scheme: dark;
      --bg: #111720;
      --panel: #202633;
      --panel-2: #273140;
      --ink: #f3f5f7;
      --muted: #a8b3c2;
      --line: #374253;
      --accent: #f59e0b;
      --accent-2: #8b5cf6;
      --danger: #f06464;
      --cell: #2a3445;
      --cell-alt: #303c4d;
      --p1-color: #f59e0b;
      --p2-color: #a78bfa;
      --z-session-overlay: 1100;
      --z-settings-tools: 1200;
      --z-settings-open: 1210;
      --z-settings-modal: 1300;
      --z-page-loading: 2000;
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      width: 100%;
      min-height: 100%;
      margin: 0;
      background:
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.14), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.14), transparent 30rem),
        linear-gradient(135deg, #151922 0%, #1c2230 48%, #18212a 100%);
      color: var(--ink);
      font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
      overflow-x: hidden;
      overscroll-behavior: none;
    }

    body {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 18px;
    }

    .page-loading-progress {
      position: fixed;
      top: 50%;
      left: 50%;
      z-index: var(--z-page-loading);
      width: min(560px, calc(100vw - 32px));
      color: var(--ink);
      opacity: 1;
      pointer-events: none;
      transform: translate(-50%, -50%) scale(1);
      transition: opacity 240ms ease, transform 240ms ease, visibility 240ms ease;
    }

    .page-loading-progress[hidden] {
      display: none;
    }

    .page-loading-progress.is-complete {
      opacity: 0;
      visibility: hidden;
      transform: translate(-50%, calc(-50% - 16px)) scale(0.98);
    }

    .page-loading-card {
      position: relative;
      display: grid;
      gap: 14px;
      padding: 18px;
      overflow: hidden;
      border: 1px solid rgba(255, 255, 255, 0.16);
      border-radius: 22px;
      background:
        radial-gradient(circle at 16% 0%, rgba(245, 158, 11, 0.22), transparent 34%),
        radial-gradient(circle at 86% 10%, rgba(167, 139, 250, 0.22), transparent 32%),
        linear-gradient(135deg, rgba(32, 38, 51, 0.97), rgba(17, 23, 32, 0.95));
      box-shadow:
        0 28px 90px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
      backdrop-filter: blur(18px);
    }

    .page-loading-card::before {
      content: "";
      position: absolute;
      inset: -40% -20% auto;
      height: 180px;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.13), transparent);
      transform: rotate(-8deg);
      animation: page-loading-panel-shine 2400ms ease-in-out infinite;
      pointer-events: none;
    }

    .page-loading-copy {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: end;
      justify-content: space-between;
      gap: 16px;
    }

    .page-loading-kicker {
      color: #facc15;
      font-size: 0.74rem;
      font-weight: 950;
      letter-spacing: 0.16em;
    }

    .page-loading-title {
      font-size: clamp(1.18rem, 3.4vw, 1.9rem);
      line-height: 1;
      text-align: right;
      text-shadow: 0 0 24px rgba(245, 158, 11, 0.32);
    }

    .page-loading-portrait {
      position: relative;
      z-index: 1;
      display: grid;
      justify-items: center;
      gap: 8px;
      margin: 2px auto 0;
      width: min(300px, 72vw);
      min-height: 0;
      opacity: 0;
      transform: translateY(10px) scale(0.98);
      animation: page-loading-portrait-in 260ms ease-out forwards;
    }

    .page-loading-portrait[hidden] {
      display: none;
    }

    .page-loading-portrait::before {
      content: "";
      position: absolute;
      inset: 12% 6% 18%;
      z-index: -1;
      border-radius: 40%;
      background:
        radial-gradient(circle, rgba(250, 204, 21, 0.22), transparent 58%),
        radial-gradient(circle at 60% 42%, rgba(167, 139, 250, 0.24), transparent 54%);
      filter: blur(8px);
    }

    .page-loading-portrait img {
      display: block;
      width: min(250px, 58vw);
      max-height: min(34vh, 330px);
      object-fit: contain;
      filter:
        drop-shadow(0 22px 32px rgba(0, 0, 0, 0.54))
        drop-shadow(0 0 24px rgba(250, 204, 21, 0.14));
    }

    .page-loading-portrait-caption {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      max-width: 100%;
      padding: 5px 10px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 999px;
      background: rgba(7, 10, 16, 0.44);
      color: var(--ink);
      font-size: 0.76rem;
      font-weight: 850;
      white-space: nowrap;
    }

    .page-loading-portrait-caption span:first-child {
      max-width: 170px;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .page-loading-portrait-caption span:last-child {
      color: #facc15;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    .page-loading-status {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      align-items: center;
    }

    .page-loading-track {
      position: relative;
      height: 14px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(7, 10, 16, 0.68);
      box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.44);
    }

    .page-loading-bar {
      position: absolute;
      inset: 0 auto 0 0;
      width: var(--page-loading-progress, 0%);
      min-width: 14px;
      border-radius: inherit;
      background:
        linear-gradient(90deg, #f59e0b, #facc15 44%, #a78bfa),
        var(--accent);
      box-shadow: 0 0 22px rgba(245, 158, 11, 0.54);
      transition: width 180ms ease-out, background 180ms ease;
    }

    .page-loading-bar::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.52), transparent);
      transform: translateX(-100%);
      animation: page-loading-shine 950ms ease-in-out infinite;
    }

    .page-loading-label {
      color: var(--ink);
      font-size: 0.78rem;
      font-weight: 950;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }

    .page-loading-progress.is-error .page-loading-bar {
      background: linear-gradient(90deg, #f06464, #fca5a5);
      box-shadow: 0 0 18px rgba(240, 100, 100, 0.46);
    }

    @keyframes page-loading-shine {
      to {
        transform: translateX(120%);
      }
    }

    @keyframes page-loading-panel-shine {
      0%,
      42% {
        transform: translateX(-44%) rotate(-8deg);
      }

      100% {
        transform: translateX(72%) rotate(-8deg);
      }
    }

    @keyframes page-loading-portrait-in {
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @media (max-width: 620px) {
      .page-loading-card {
        gap: 12px;
        padding: 15px;
      }

      .page-loading-copy,
      .page-loading-status {
        grid-template-columns: 1fr;
      }

      .page-loading-copy {
        display: grid;
        gap: 5px;
      }

      .page-loading-title {
        text-align: left;
      }

      .page-loading-status {
        gap: 7px;
      }

      .page-loading-label {
        justify-self: end;
      }
    }

    .app {
      width: min(1200px, 100%);
      display: grid;
      grid-template-columns: minmax(0, 1fr) 312px;
      gap: 18px;
      align-items: stretch;
    }

    .stage {
      min-height: min(78vh, 760px);
      display: grid;
      grid-template-rows: auto minmax(360px, 1fr);
      gap: 12px;
    }

    .topbar,
    .side {
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: rgba(32, 38, 51, 0.86);
      box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
      backdrop-filter: blur(12px);
    }

    .topbar {
      min-height: 74px;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      align-items: stretch;
      padding: 12px 14px;
      border-radius: 8px;
    }

    .report-panel,
    .metrics {
      min-width: 0;
      border-radius: 8px;
      background: rgba(17, 23, 32, 0.42);
      border: 1px solid rgba(255, 255, 255, 0.07);
    }

    .report-panel {
      display: grid;
      align-content: center;
      padding: 10px 12px;
    }

    h1 {
      margin: 0;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: clamp(1.35rem, 2.2vw, 2.1rem);
      line-height: 1.05;
      letter-spacing: 0;
      white-space: nowrap;
    }

    .site-title-logo {
      width: clamp(34px, 3.8vw, 46px);
      aspect-ratio: 1;
      flex: 0 0 auto;
      object-fit: contain;
      filter: drop-shadow(0 8px 18px rgba(56, 189, 248, 0.26));
    }

    .site-title-text {
      min-width: 0;
    }

    .status {
      margin-top: 6px;
      color: var(--muted);
      font-size: 0.95rem;
    }

    .metrics {
      display: contents;
      gap: 8px;
      padding: 0;
      align-items: stretch;
      background: transparent;
      border: 0;
      border-radius: 0;
    }

    .player-status-list,
    .match-metrics {
      min-width: 0;
      display: grid;
      gap: 4px;
      padding: 8px;
      border-radius: 8px;
      background: rgba(17, 23, 32, 0.34);
      border: 1px solid rgba(255, 255, 255, 0.06);
    }

    .match-metrics {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric {
      padding: 4px 0;
      border-radius: 0;
      background: transparent;
      border: 0;
      text-align: center;
      min-width: 0;
    }

    .player-metric {
      display: grid;
      grid-template-columns: auto minmax(124px, 1fr) auto;
      gap: 8px;
      align-items: center;
      text-align: left;
    }

    .health-readout {
      width: 100%;
      min-width: 0;
      display: grid;
      gap: 4px;
    }

    .health-readout strong {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .health-bar {
      position: relative;
      width: 100%;
      min-width: 0;
      height: 7px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(7, 10, 16, 0.62);
      border: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.36);
    }

    .health-bar-fill {
      display: block;
      width: 100%;
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, color-mix(in srgb, var(--health-color), black 12%), var(--health-color));
      box-shadow: 0 0 10px color-mix(in srgb, var(--health-color), transparent 58%);
      transform: scaleX(var(--health-ratio, 1));
      transform-origin: left center;
      transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
    }

    .player-metric[data-owner="player"] {
      --health-color: var(--p1-color);
    }

    .player-metric[data-owner="computer"] {
      --health-color: var(--p2-color);
    }

    .player-metric[data-owner="player"] .health-readout strong {
      color: var(--p1-color);
    }

    .player-metric[data-owner="computer"] .health-readout strong {
      color: var(--p2-color);
    }

    .player-metric.is-low-health {
      --health-color: var(--danger);
    }

    .player-speed {
      color: var(--ink);
      font-size: 1rem;
      font-weight: 950;
      line-height: 1.2;
      white-space: nowrap;
    }

    .metric span {
      display: block;
      color: var(--muted);
      font-size: 0.76rem;
      white-space: nowrap;
    }

    .owner-name {
      color: var(--owner-name-color);
      font-weight: 950;
    }

    .owner-name.is-p1 {
      --owner-name-color: var(--p1-color);
    }

    .owner-name.is-p2 {
      --owner-name-color: var(--p2-color);
    }

    .metric strong {
      display: block;
      font-size: 1.22rem;
      line-height: 1.2;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .player-metric strong {
      overflow: visible;
      text-overflow: clip;
    }

    .match-metrics .metric {
      padding: 3px 0;
    }

    .match-metrics .metric strong {
      font-size: 1rem;
    }

    @media (min-width: 901px) and (max-width: 1080px) {
      .topbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 10px;
      }

      .metrics {
        display: contents;
      }
    }

    .canvas-wrap {
      position: relative;
      min-height: 360px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      overflow: hidden;
      background: #111720;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 20px 80px rgba(0, 0, 0, 0.38);
      touch-action: none;
    }

    canvas {
      display: block;
      width: 100%;
      height: 100%;
      min-height: 360px;
    }

    .target-mode-indicator {
      position: absolute;
      right: max(10px, env(safe-area-inset-right));
      z-index: 18;
      width: 34px;
      height: 34px;
      min-width: 0;
      min-height: 0;
      padding: 0;
      border-radius: 50%;
      border: 1px solid rgba(255, 255, 255, 0.34);
      background:
        radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.24), transparent 30%),
        rgba(15, 23, 42, 0.86);
      color: #fde68a;
      display: grid;
      place-items: center;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
      backdrop-filter: blur(8px);
      touch-action: manipulation;
    }

    #targetModeSmallIndicator {
      bottom: max(10px, env(safe-area-inset-bottom));
    }

    #targetModeBigIndicator {
      bottom: calc(max(10px, env(safe-area-inset-bottom)) + 40px);
    }

    .cooldown-indicator {
      position: absolute;
      left: max(10px, env(safe-area-inset-left));
      z-index: 18;
      width: 38px;
      height: 38px;
      min-width: 0;
      min-height: 0;
      border-radius: 50%;
      border: 1px solid rgba(255, 255, 255, 0.34);
      background:
        radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.22), transparent 30%),
        rgba(15, 23, 42, 0.86);
      color: #fde68a;
      display: grid;
      place-items: center;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
      backdrop-filter: blur(8px);
      pointer-events: none;
    }

    #cooldownSmallIndicator {
      bottom: max(10px, env(safe-area-inset-bottom));
    }

    #cooldownBigIndicator {
      bottom: calc(max(10px, env(safe-area-inset-bottom)) + 40px);
    }

    .cooldown-indicator::after {
      content: attr(data-profile-label);
      position: absolute;
      left: -2px;
      bottom: -2px;
      width: 15px;
      height: 15px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      background: #f59e0b;
      color: #171006;
      border: 1px solid rgba(255, 255, 255, 0.64);
      font-size: 0.56rem;
      font-weight: 950;
      line-height: 1;
    }

    .cooldown-clock {
      position: absolute;
      width: 25px;
      height: 25px;
      border-radius: 50%;
      border: 2px solid currentColor;
      opacity: 0.42;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
    }

    .cooldown-clock::before,
    .cooldown-clock::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      width: 2px;
      border-radius: 999px;
      background: currentColor;
      transform-origin: 50% 100%;
    }

    .cooldown-clock::before {
      height: 7px;
      transform: translate(-50%, -100%) rotate(0deg);
    }

    .cooldown-clock::after {
      height: 9px;
      transform: translate(-50%, -100%) rotate(118deg);
    }

    .cooldown-value {
      position: relative;
      z-index: 1;
      max-width: 30px;
      overflow: hidden;
      color: currentColor;
      font-size: 0.66rem;
      font-weight: 950;
      line-height: 1;
      text-align: center;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.78);
      font-variant-numeric: tabular-nums;
    }

    .cooldown-indicator.is-cooling {
      border-color: rgba(253, 230, 138, 0.78);
      box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16), 0 12px 30px rgba(0, 0, 0, 0.42);
    }

    .cooldown-indicator.is-cooling .cooldown-clock::after {
      animation: cooldown-hand-spin 1.15s linear infinite;
    }

    .cooldown-indicator.is-ready {
      color: #86efac;
      border-color: rgba(134, 239, 172, 0.62);
    }

    .cooldown-indicator.is-blocked {
      color: #cbd5e1;
      border-color: rgba(203, 213, 225, 0.38);
      opacity: 0.78;
    }

    @keyframes cooldown-hand-spin {
      to {
        transform: translate(-50%, -100%) rotate(478deg);
      }
    }

    .target-mode-indicator::after {
      content: attr(data-profile-label);
      position: absolute;
      right: -2px;
      bottom: -2px;
      width: 15px;
      height: 15px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      background: #f59e0b;
      color: #171006;
      border: 1px solid rgba(255, 255, 255, 0.64);
      font-size: 0.56rem;
      font-weight: 950;
      line-height: 1;
    }

    .target-mode-indicator:active,
    .target-mode-indicator.is-active {
      border-color: rgba(253, 230, 138, 0.82);
      box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), 0 12px 30px rgba(0, 0, 0, 0.42);
    }

    .target-mode-icon {
      position: relative;
      width: 25px;
      height: 25px;
      display: block;
    }

    .target-mode-icon::before,
    .target-mode-icon::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }

    .target-mode-icon:has(svg)::before,
    .target-mode-icon:has(svg)::after {
      display: none;
    }

    .target-mode-icon svg {
      display: block;
      width: 100%;
      height: 100%;
      overflow: visible;
    }

    .target-mode-icon[data-mode="head"]::before,
    .target-mode-icon[data-mode="body"]::before,
    .target-mode-icon[data-mode="food"]::before {
      width: 19px;
      height: 19px;
      border-radius: 50%;
      border: 2px solid currentColor;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    }

    .target-mode-icon[data-mode="head"]::after {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #fca5a5;
      box-shadow: 0 0 12px rgba(252, 165, 165, 0.7);
    }

    .target-mode-icon[data-mode="body"]::after {
      width: 15px;
      height: 7px;
      border-radius: 999px;
      background: #a7f3d0;
      box-shadow:
        -7px 0 0 -1px #34d399,
        7px 0 0 -1px #34d399,
        0 0 12px rgba(52, 211, 153, 0.48);
    }

    .target-mode-icon[data-mode="food"]::after {
      width: 10px;
      height: 10px;
      border-radius: 4px 50% 50% 50%;
      background: #facc15;
      transform: translate(-50%, -50%) rotate(45deg);
      box-shadow: 0 0 14px rgba(250, 204, 21, 0.68);
    }

    .target-mode-icon[data-mode="direction"]::before {
      width: 20px;
      height: 5px;
      border-radius: 999px;
      background: currentColor;
      transform: translate(-50%, -50%) rotate(var(--target-direction-angle, 0deg));
      transform-origin: center;
      box-shadow: 0 0 13px rgba(253, 230, 138, 0.5);
    }

    .target-mode-icon[data-mode="direction"]::after {
      width: 9px;
      height: 9px;
      border-top: 5px solid currentColor;
      border-right: 5px solid currentColor;
      transform:
        translate(-12%, -50%)
        rotate(calc(var(--target-direction-angle, 0deg) + 45deg));
      transform-origin: center;
    }

    .overlay {
      position: absolute;
      inset: 0;
      z-index: 24;
      display: grid;
      place-items: center;
      padding: 12px;
      background: rgba(13, 17, 23, 0.54);
      opacity: 0;
      pointer-events: none;
      overflow: hidden;
      transition: opacity 160ms ease;
    }

    .overlay.show {
      opacity: 1;
      pointer-events: auto;
    }

    .overlay.intro-details {
      position: fixed;
      z-index: 80;
      padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    }

    .overlay.is-session-modal {
      position: absolute;
      z-index: var(--z-session-overlay);
      padding: 12px;
    }

    .dialog {
      position: relative;
      isolation: isolate;
      width: min(420px, 100%);
      max-height: 100%;
      overflow: hidden;
      padding: 16px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(32, 38, 51, 0.94);
      text-align: center;
      box-shadow: 0 18px 80px rgba(0, 0, 0, 0.45);
    }

    .dialog h2 {
      margin: 0 0 8px;
      font-size: 1.55rem;
    }

    .dialog-actions {
      position: relative;
      z-index: 12;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      justify-content: center;
      align-items: stretch;
    }

    .overlay.logo-transition {
      z-index: calc(var(--z-session-overlay) + 10);
      background:
        radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.08), transparent 34%),
        radial-gradient(circle at 50% 52%, rgba(245, 158, 11, 0.14), transparent 48%),
        rgba(8, 12, 18, 0.48);
      backdrop-filter: blur(2px);
      overflow: visible;
    }

    .overlay.logo-transition.is-session-modal {
      align-items: center;
    }

    .overlay.logo-transition .dialog {
      width: min(420px, calc(100% - 24px));
      padding: 0;
      border: 0;
      background: transparent;
      box-shadow: none;
      overflow: visible;
    }

    .logo-transition-card {
      position: relative;
      --logo-size: clamp(144px, min(36vw, 40dvh), 270px);
      display: grid;
      justify-items: center;
      align-content: center;
      gap: 12px;
      min-height: 0;
      padding: 6px 0;
    }

    .logo-spiral-shell {
      position: relative;
      width: var(--logo-size);
      aspect-ratio: 1;
      display: grid;
      place-items: center;
      pointer-events: none;
      filter:
        drop-shadow(0 26px 48px rgba(0, 0, 0, 0.54))
        drop-shadow(0 0 22px rgba(191, 219, 254, 0.24));
    }

    .logo-spiral-shell::before,
    .logo-spiral-shell::after {
      content: "";
      position: absolute;
      inset: 3%;
      border-radius: 50%;
      pointer-events: none;
    }

    .logo-spiral-shell::before {
      border: 1px solid rgba(255, 255, 255, 0.18);
      background:
        conic-gradient(from 0deg, transparent, rgba(245, 158, 11, 0.26), transparent, rgba(139, 92, 246, 0.22), transparent);
      animation: logo-orbit 3000ms linear both;
      mask: radial-gradient(circle, transparent 54%, #000 55%, #000 58%, transparent 59%);
    }

    .logo-spiral-shell::after {
      inset: 14%;
      background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 62%);
      opacity: 0.72;
    }

    .logo-spiral-logo {
      position: relative;
      z-index: 1;
      width: 100%;
      height: 100%;
      overflow: visible;
    }

    .logo-spiral-piece {
      opacity: 1;
      transform-box: fill-box;
      transform-origin: 50% 50%;
      filter: saturate(1.06) contrast(1.04);
    }

    .logo-transition-out .logo-spiral-piece {
      animation: logo-piece-out var(--logo-piece-duration, 520ms) ease-in both;
      animation-delay: var(--logo-delay, 0ms);
    }

    .logo-transition-in .logo-spiral-piece {
      opacity: 0;
      animation: logo-piece-in var(--logo-piece-duration, 520ms) ease-out both;
      animation-delay: var(--logo-delay, 0ms);
    }

    .logo-transition-aux {
      position: relative;
      width: 100%;
      display: grid;
      justify-items: center;
      gap: 10px;
      align-items: start;
    }

    .logo-countdown {
      position: relative;
      z-index: 3;
      min-width: 1.4em;
      color: #ffffff;
      font-size: clamp(2.4rem, min(10vw, 12dvh), 5rem);
      font-weight: 1000;
      line-height: 1;
      text-align: center;
      text-shadow:
        0 3px 18px rgba(0, 0, 0, 0.86),
        0 0 30px rgba(245, 158, 11, 0.42);
      font-variant-numeric: tabular-nums;
      animation: logo-countdown-pulse 1000ms ease-in-out infinite;
    }

    .logo-transition-message {
      position: relative;
      z-index: 3;
      display: inline-flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 1px;
      min-height: 1.2em;
      color: #f8fafc;
      font-size: clamp(1.08rem, 4vw, 1.5rem);
      font-weight: 700;
      line-height: 1.2;
      letter-spacing: 0.01em;
      white-space: nowrap;
      text-align: center;
      text-shadow: 0 2px 10px rgba(0, 0, 0, 0.52);
      pointer-events: none;
    }

    .logo-transition-message-char {
      opacity: 0;
      transform: translateY(6px) scale(0.98);
      animation: logo-message-reveal 180ms ease-out both;
      animation-delay: var(--logo-message-delay);
      display: inline-block;
    }

    .logo-transition-skip {
      position: relative;
      z-index: 3;
      pointer-events: auto;
      min-width: 0;
      min-height: 0;
      padding: 3px 10px;
      border: 1px solid rgba(226, 232, 240, 0.42);
      color: #f8fafc;
      background: rgba(15, 23, 42, 0.72);
      box-shadow: none;
      text-shadow: none;
      border-radius: 999px;
      white-space: nowrap;
      line-height: 1.05;
      font-size: 0.74rem;
      letter-spacing: 0.04em;
      font-weight: 600;
      transition: background-color 120ms ease, border-color 120ms ease;
    }

    .logo-transition-skip:hover {
      border-color: rgba(226, 232, 240, 0.64);
      background: rgba(30, 41, 59, 0.82);
    }

    @keyframes logo-message-reveal {
      0% {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
      }
      100% {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @keyframes logo-piece-out {
      0% {
        opacity: 1;
        transform: rotate(0deg) scale(1);
        filter: blur(0) saturate(1.08);
      }
      100% {
        opacity: 0;
        transform: rotate(22deg) scale(0.86);
        filter: blur(2.2px) saturate(1.24);
      }
    }

    @keyframes logo-piece-in {
      0% {
        opacity: 0;
        transform: rotate(-22deg) scale(0.86);
        filter: blur(2.2px) saturate(1.24);
      }
      100% {
        opacity: 1;
        transform: rotate(0deg) scale(1);
        filter: blur(0) saturate(1.08);
      }
    }

    @keyframes logo-orbit {
      from { transform: rotate(0deg) scale(0.96); }
      to { transform: rotate(720deg) scale(1.04); }
    }

    @keyframes logo-countdown-pulse {
      0%, 100% { transform: scale(1); opacity: 0.98; }
      50% { transform: scale(1.08); opacity: 0.74; }
    }

    @media (prefers-reduced-motion: reduce) {
      .logo-spiral-shell::before,
      .logo-countdown {
        animation: none;
      }

      .logo-transition-out .logo-spiral-piece {
        animation: logo-piece-out-reduced 280ms ease-out both;
        animation-delay: 0ms;
      }

      .logo-transition-in .logo-spiral-piece {
        animation: logo-piece-in-reduced 280ms ease-out both;
        animation-delay: 0ms;
      }
    }

    @keyframes logo-piece-out-reduced {
      to { opacity: 0; }
    }

    @keyframes logo-piece-in-reduced {
      to { opacity: 1; }
    }

    .overlay.tutorial-open {
      position: fixed;
      z-index: 150;
      padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
      touch-action: pan-y;
      user-select: none;
      -webkit-user-select: none;
      background:
        linear-gradient(180deg, rgba(7, 10, 16, 0.94), rgba(13, 17, 23, 0.98)),
        radial-gradient(circle at 50% 12%, rgba(251, 191, 36, 0.16), transparent 42%);
    }

    .overlay.tutorial-open .dialog {
      width: min(1280px, 100%);
      height: min(900px, 100%);
      max-height: 100%;
      padding: 0;
      border: 0;
      background: transparent;
      box-shadow: none;
      text-align: left;
    }

    .overlay.tutorial-open #winnerPortrait {
      width: 100%;
      height: 100%;
      min-height: 0;
    }

    .tutorial-card {
      --tutorial-actions-height: 44px;
      display: grid;
      grid-template-rows: auto minmax(280px, 46%) minmax(0, 1fr) var(--tutorial-actions-height);
      gap: 14px;
      height: 100%;
      min-height: 0;
      overflow: hidden;
      text-align: left;
      outline: none;
    }

    .overlay.tutorial-open .tutorial-card,
    .overlay.tutorial-open .tutorial-card * {
      touch-action: pan-y;
      user-select: none;
      -webkit-user-select: none;
    }

    .tutorial-card > .tutorial-progress {
      grid-row: 1;
    }

    .tutorial-card > .tutorial-visual {
      grid-row: 2;
    }

    .tutorial-card > .tutorial-copy {
      grid-row: 3;
    }

    .tutorial-card > .tutorial-actions {
      grid-row: 4;
      align-self: stretch;
    }

    .tutorial-card:not(:has(.tutorial-copy)) > .tutorial-visual {
      grid-row: 2 / 4;
      align-self: center;
      max-height: 100%;
    }

    .tutorial-progress {
      display: flex;
      justify-content: center;
      gap: 6px;
      padding: 2px 0;
    }

    .tutorial-progress span {
      width: 28px;
      height: 4px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.2);
    }

    .tutorial-progress span.is-active {
      background: #fbbf24;
    }

    .tutorial-visual {
      min-height: 220px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.72), rgba(42, 52, 69, 0.86)),
        repeating-linear-gradient(30deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 34px);
      position: relative;
      overflow: hidden;
    }

    .tutorial-visual.is-capture {
      --tutorial-control-size: clamp(148px, 14vw, 176px);
      --tutorial-capture-size: clamp(280px, min(420px, calc(100vw - 320px), calc(100dvh - 560px)), 420px);
      display: grid;
      grid-template-columns: minmax(280px, var(--tutorial-capture-size)) var(--tutorial-control-size);
      grid-template-rows: minmax(280px, var(--tutorial-capture-size));
      align-items: center;
      gap: 12px;
      margin: 0;
      width: fit-content;
      max-width: 100%;
      height: var(--tutorial-capture-size);
      max-height: none;
      min-height: 0;
      min-width: 0;
      justify-self: center;
      align-self: center;
      border: 0;
      background: transparent;
      box-shadow: none;
      overflow: visible;
    }

    .tutorial-visual.is-capture.is-move {
      grid-template-columns: var(--tutorial-control-size) minmax(280px, var(--tutorial-capture-size));
    }

    .tutorial-capture-stage {
      position: relative;
      display: grid;
      place-items: center;
      min-height: 0;
      min-width: 0;
      width: 100%;
      max-width: var(--tutorial-capture-size);
      aspect-ratio: 1;
      height: auto;
      justify-self: center;
      align-self: center;
      overflow: hidden;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: #111720;
      box-shadow: 0 26px 80px rgba(0, 0, 0, 0.48);
    }

    .tutorial-capture-stage img {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: contain;
      filter: saturate(1.08) contrast(1.04);
    }

    .tutorial-capture-stage::after {
      content: "";
      position: absolute;
      inset: 0;
      background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.12), transparent 34%, rgba(15, 23, 42, 0.5)),
        radial-gradient(circle at 50% 46%, transparent 0 34%, rgba(0, 0, 0, 0.28) 72%);
      pointer-events: none;
    }

    .tutorial-board-diagram {
      position: relative;
      min-width: 0;
      min-height: 0;
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      grid-template-rows: repeat(4, minmax(0, 1fr));
      gap: 6px;
      width: 100%;
      height: 100%;
      padding: 18px;
      background:
        radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.08), transparent 58%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(17, 24, 39, 0.9));
    }

    .tutorial-board-diagram::before {
      content: "";
      position: absolute;
      inset: 18px;
      border-radius: 8px;
      background:
        linear-gradient(30deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(150deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
      background-size: 32px 28px;
      opacity: 0.7;
      pointer-events: none;
    }

    .tutorial-demo-hex {
      position: relative;
      z-index: 2;
      grid-column: var(--col);
      grid-row: var(--row);
      align-self: center;
      justify-self: center;
      width: min(64px, 100%);
      aspect-ratio: 1.08;
      display: grid;
      place-items: center;
      clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%);
      background: #334155;
      color: #f8fafc;
      font-size: 0.78rem;
      font-weight: 950;
      line-height: 1;
      text-align: center;
      box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.12),
        0 10px 26px rgba(0, 0, 0, 0.34);
    }

    .tutorial-demo-hex.is-body,
    .tutorial-demo-hex.is-player {
      background: #f59e0b;
      color: #111827;
    }

    .tutorial-demo-hex.is-head {
      background: #fde68a;
      color: #111827;
      box-shadow:
        inset 0 0 0 3px #f59e0b,
        0 0 0 5px rgba(245, 158, 11, 0.2),
        0 12px 28px rgba(0, 0, 0, 0.34);
    }

    .tutorial-demo-hex.is-food {
      background: #22c55e;
      color: #052e16;
      box-shadow:
        inset 0 0 0 3px rgba(255, 255, 255, 0.34),
        0 0 0 5px rgba(34, 197, 94, 0.18),
        0 12px 28px rgba(0, 0, 0, 0.34);
    }

    .tutorial-demo-hex.is-enemy,
    .tutorial-demo-hex.is-enemy-body {
      background: #a78bfa;
      color: #1f1147;
    }

    .tutorial-demo-arrow {
      position: absolute;
      z-index: 3;
      left: 48%;
      top: 43%;
      width: 26%;
      height: 5px;
      transform: rotate(-28deg);
      transform-origin: left center;
      border-radius: 999px;
      background: linear-gradient(90deg, #fbbf24, #fef3c7);
      box-shadow: 0 0 18px rgba(251, 191, 36, 0.52);
    }

    .tutorial-demo-arrow::after {
      content: "";
      position: absolute;
      right: -2px;
      top: 50%;
      width: 15px;
      height: 15px;
      transform: translateY(-50%) rotate(45deg);
      border-top: 5px solid #fef3c7;
      border-right: 5px solid #fef3c7;
    }

    .tutorial-demo-blast {
      position: absolute;
      z-index: 1;
      left: 70%;
      top: 45%;
      width: min(160px, 42%);
      aspect-ratio: 1;
      transform: translate(-50%, -50%);
      border-radius: 50%;
      border: 3px solid rgba(251, 191, 36, 0.95);
      background: radial-gradient(circle, rgba(251, 191, 36, 0.26), rgba(249, 115, 22, 0.18) 48%, transparent 70%);
      box-shadow: 0 0 28px rgba(251, 191, 36, 0.45);
    }

    .tutorial-visual figcaption {
      position: relative;
      z-index: 2;
      min-width: 0;
      margin: 0;
      padding: 6px 9px;
      border-radius: 0;
      background: rgba(17, 24, 39, 0.92);
      color: #e5e7eb;
      font-size: 0.76rem;
      font-weight: 900;
      line-height: 1.15;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      backdrop-filter: blur(6px);
    }

    .tutorial-label {
      position: absolute;
      left: var(--x);
      top: var(--y);
      z-index: 3;
      transform: translate(-50%, -50%);
      max-width: min(210px, 46%);
      padding: 7px 10px;
      border-radius: 8px;
      background: rgba(248, 250, 252, 0.9);
      color: #111827;
      font-weight: 900;
      line-height: 1.2;
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
    }

    .tutorial-label.is-bottom {
      background: rgba(251, 191, 36, 0.94);
    }

    .tutorial-arrow {
      position: absolute;
      left: var(--x);
      top: var(--y);
      z-index: 3;
      width: var(--w, 28%);
      height: 5px;
      transform: translate(-10%, -50%) rotate(var(--angle));
      transform-origin: left center;
      background: linear-gradient(90deg, #fbbf24, rgba(251, 191, 36, 0));
      box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
    }

    .tutorial-arrow::after {
      content: "";
      position: absolute;
      right: 0;
      top: 50%;
      width: 15px;
      height: 15px;
      transform: translateY(-50%) rotate(45deg);
      border-top: 5px solid #fbbf24;
      border-right: 5px solid #fbbf24;
    }

    .tutorial-dashed-path {
      position: absolute;
      left: var(--x);
      top: var(--y);
      z-index: 3;
      width: var(--w, 30%);
      height: 0;
      transform: translate(0, -50%) rotate(var(--angle));
      transform-origin: left center;
      border-top: 4px dashed rgba(251, 191, 36, 0.95);
      filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
      pointer-events: none;
    }

    .tutorial-dashed-path::after {
      content: "";
      position: absolute;
      right: -1px;
      top: -10px;
      width: 18px;
      height: 18px;
      transform: rotate(45deg);
      border-top: 5px solid rgba(251, 191, 36, 0.95);
      border-right: 5px solid rgba(251, 191, 36, 0.95);
    }

    .tutorial-path-svg {
      position: absolute;
      inset: 0;
      z-index: 8;
      width: 100%;
      height: 100%;
      pointer-events: none;
      overflow: visible;
      filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.54));
    }

    .tutorial-path-svg line {
      stroke: rgba(251, 191, 36, 0.98);
      stroke-width: 1.4;
      stroke-linecap: round;
      stroke-dasharray: 3.4 2.2;
      vector-effect: non-scaling-stroke;
      marker-end: url(#tutorialMoveArrowHead);
    }

    .tutorial-path-svg path {
      fill: rgba(251, 191, 36, 0.98);
    }

    .tutorial-soft-ring {
      position: absolute;
      left: var(--x);
      top: var(--y);
      z-index: 3;
      width: var(--size, 56px);
      height: var(--size, 56px);
      transform: translate(-50%, -50%);
      border: 3px dashed rgba(251, 191, 36, 0.95);
      border-radius: 999px;
      background: rgba(251, 191, 36, 0.08);
      box-shadow: 0 0 18px rgba(251, 191, 36, 0.34);
      pointer-events: none;
    }

    .tutorial-soft-ring.is-food {
      border-color: rgba(248, 250, 252, 0.86);
      background: rgba(248, 250, 252, 0.07);
      box-shadow: 0 0 18px rgba(248, 250, 252, 0.28);
    }

    .tutorial-reticle {
      position: absolute;
      left: var(--x);
      top: var(--y);
      z-index: 3;
      width: 70px;
      height: 70px;
      transform: translate(-50%, -50%);
      border: 3px solid #fbbf24;
      border-radius: 999px;
      box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.12), 0 0 22px rgba(251, 191, 36, 0.42);
    }

    .tutorial-reticle::before,
    .tutorial-reticle::after {
      content: "";
      position: absolute;
      background: #fbbf24;
    }

    .tutorial-reticle::before {
      left: 50%;
      top: -12px;
      bottom: -12px;
      width: 3px;
      transform: translateX(-50%);
    }

    .tutorial-reticle::after {
      top: 50%;
      left: -12px;
      right: -12px;
      height: 3px;
      transform: translateY(-50%);
    }

    .tutorial-ui-snapshot {
      position: relative;
      z-index: 1;
      width: 100%;
      min-width: 0;
      min-height: 0;
      display: grid;
      align-content: center;
      gap: 8px;
      pointer-events: none;
    }

    .tutorial-ui-snapshot.is-joystick,
    .tutorial-ui-snapshot.is-skills {
      width: 100%;
      max-width: 176px;
      height: auto;
      justify-self: center;
      align-self: center;
      grid-template-rows: auto auto;
      align-content: center;
      gap: 8px;
    }

    .tutorial-ui-snapshot.is-joystick {
      order: 0;
    }

    .tutorial-visual.is-move .tutorial-capture-stage {
      order: 1;
    }

    .tutorial-visual.is-small .tutorial-capture-stage {
      order: 0;
    }

    .tutorial-ui-snapshot.is-skills {
      order: 1;
    }

    .tutorial-snapshot-label {
      display: grid;
      gap: 2px;
      justify-items: start;
      color: #f8fafc;
      text-shadow: 0 2px 12px rgba(0, 0, 0, 0.58);
      font-weight: 900;
      line-height: 1.15;
    }

    .tutorial-snapshot-label strong {
      color: #fbbf24;
      font-size: 0.98rem;
    }

    .tutorial-snapshot-label span {
      color: #e5e7eb;
      font-size: 0.72rem;
    }

    .tutorial-ui-snapshot.is-joystick .tutorial-snapshot-label,
    .tutorial-ui-snapshot.is-skills .tutorial-snapshot-label {
      position: relative;
      z-index: 2;
      justify-items: center;
      text-align: center;
      min-width: 0;
      padding: 5px 6px;
      border-radius: 8px;
      background: rgba(17, 24, 39, 0.92);
    }

    .tutorial-ui-snapshot.is-joystick .tutorial-snapshot-label strong,
    .tutorial-ui-snapshot.is-skills .tutorial-snapshot-label strong {
      font-size: 0.88rem;
    }

    .tutorial-ui-snapshot.is-joystick .tutorial-snapshot-label span,
    .tutorial-ui-snapshot.is-skills .tutorial-snapshot-label span {
      display: none;
    }

    .tutorial-snapshot-frame {
      min-width: 0;
      width: 100%;
      min-height: 0;
      padding: 10px;
      border-radius: 8px;
      border: 1px solid rgba(251, 191, 36, 0.58);
      background: rgba(17, 24, 39, 0.9);
      box-shadow:
        0 18px 44px rgba(0, 0, 0, 0.44),
        inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    }

    .tutorial-ui-snapshot.is-joystick .tutorial-snapshot-frame,
    .tutorial-ui-snapshot.is-skills .tutorial-snapshot-frame {
      display: grid;
      place-items: center;
      height: auto;
      aspect-ratio: auto;
      border: 0;
      border-radius: 0;
      background: transparent;
      box-shadow: none;
      padding: 0;
    }

    .tutorial-ui-snapshot .joystick-zone,
    .tutorial-ui-snapshot .attack-actions {
      width: 104px;
      margin: 0 auto;
    }

    .tutorial-ui-snapshot .joystick {
      width: 104px;
    }

    .tutorial-ui-snapshot .attack-actions {
      height: 104px;
    }

    .tutorial-ui-snapshot .attack-actions .attack-button {
      width: 34px;
      height: 34px;
      font-size: 0.62rem;
    }

    .tutorial-ui-snapshot .attack-actions .attack-button.secondary {
      width: 34px;
    }

    .tutorial-ui-snapshot .resource-board {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }

    .tutorial-ui-snapshot .resource-panel {
      gap: 6px;
      padding: 8px;
    }

    .tutorial-ui-snapshot .resource-title {
      gap: 8px;
      padding-bottom: 6px;
      font-size: 0.74rem;
    }

    .tutorial-ui-snapshot .resource-chip {
      grid-template-columns: 12px minmax(22px, 1fr) auto;
      padding: 2px 5px;
      font-size: 0.68rem;
    }

    .tutorial-ui-snapshot .resource-icon {
      width: 12px;
      height: 12px;
    }

    .tutorial-ui-snapshot .resource-row {
      grid-template-columns: 42px minmax(0, 1fr) 22px;
      gap: 6px;
      font-size: 0.72rem;
    }

    .tutorial-visual.is-resource-guide {
      display: grid;
      grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
      align-items: stretch;
      gap: 12px;
      width: min(1000px, 100%);
      min-height: 0;
      min-width: 0;
      margin: 0;
      justify-self: center;
      align-self: center;
      border: 0;
      background: transparent;
      overflow: visible;
    }

    .tutorial-visual.is-resource-guide .tutorial-ui-snapshot {
      align-content: stretch;
    }

    .tutorial-resource-guide {
      display: grid;
      gap: 10px;
      min-width: 0;
      min-height: 0;
      align-content: center;
    }

    .tutorial-resource-guide-panel {
      display: grid;
      gap: 5px;
      padding: 14px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(17, 24, 39, 0.82);
      color: var(--muted);
      line-height: 1.4;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    }

    .tutorial-resource-guide-panel strong {
      color: #fbbf24;
      font-size: 1rem;
      font-weight: 950;
    }

    .tutorial-resource-guide-panel span {
      font-size: 0.9rem;
      font-weight: 760;
    }

    .tutorial-resource-guide-panel.is-food-detail-panel {
      align-content: start;
    }

    .tutorial-food-detail-list {
      display: grid;
      gap: 6px;
      margin: 0;
      padding: 0;
      list-style: none;
    }

    .tutorial-food-detail-list li {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      gap: 8px;
      align-items: start;
      min-width: 0;
    }

    .tutorial-food-detail-list b {
      color: var(--ink);
      font-weight: 950;
    }

    .tutorial-food-detail-list span {
      min-width: 0;
      font-size: 0.84rem;
      line-height: 1.32;
    }

    .tutorial-food-stock-limit {
      display: block;
      margin-top: 2px;
      color: #fde68a;
    }

    .tutorial-hex {
      width: 58px;
      height: 52px;
      display: inline-grid;
      place-items: center;
      clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%);
      background: #334155;
      border: 1px solid rgba(255, 255, 255, 0.18);
      color: var(--ink);
      font-weight: 900;
      box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
    }

    .tutorial-hex.is-head {
      background: #f59e0b;
      color: #111827;
    }

    .tutorial-hex.is-enemy {
      background: #7c3aed;
    }

    .tutorial-hex.is-cast {
      background: #2563eb;
    }

    .tutorial-hex.is-blast {
      background: #fb923c;
      color: #111827;
    }

    .tutorial-visual.is-move {
      display: grid;
      grid-template-columns: repeat(3, 58px);
      grid-template-rows: repeat(3, 52px);
      justify-content: center;
      align-content: center;
      gap: 4px 8px;
    }

    .tutorial-visual.is-move .tutorial-hex:nth-child(1) { grid-column: 1; grid-row: 1; }
    .tutorial-visual.is-move .tutorial-hex:nth-child(2) { grid-column: 3; grid-row: 1; }
    .tutorial-visual.is-move .tutorial-hex:nth-child(3) { grid-column: 1; grid-row: 2; }
    .tutorial-visual.is-move .tutorial-hex:nth-child(4) { grid-column: 2; grid-row: 2; }
    .tutorial-visual.is-move .tutorial-hex:nth-child(5) { grid-column: 3; grid-row: 2; }
    .tutorial-visual.is-move .tutorial-hex:nth-child(6) { grid-column: 1; grid-row: 3; }
    .tutorial-visual.is-move .tutorial-hex:nth-child(7) { grid-column: 3; grid-row: 3; }

    .tutorial-path {
      position: absolute;
      left: 50%;
      top: 50%;
      width: 120px;
      height: 4px;
      transform: translate(-6px, -2px) rotate(-30deg);
      transform-origin: left center;
      background: linear-gradient(90deg, #fbbf24, transparent);
    }

    .tutorial-path::after {
      content: "";
      position: absolute;
      right: -1px;
      top: 50%;
      width: 12px;
      height: 12px;
      transform: translateY(-50%) rotate(45deg);
      border-top: 4px solid #fbbf24;
      border-right: 4px solid #fbbf24;
    }

    .tutorial-visual.is-food,
    .tutorial-visual.is-small {
      display: grid;
      place-items: center;
      gap: 14px;
      padding: 18px;
    }

    .tutorial-food-board {
      display: grid;
      grid-template-columns: repeat(2, minmax(104px, 1fr));
      gap: 10px;
      width: min(300px, 100%);
    }

    .tutorial-food-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px;
      border-radius: 8px;
      background: rgba(15, 23, 42, 0.66);
      color: var(--ink);
    }

    .tutorial-resource-flow {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
      width: min(420px, 100%);
    }

    .tutorial-resource-flow span,
    .tutorial-target-pill,
    .tutorial-cost-row {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 34px;
      padding: 6px 10px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.1);
      color: var(--ink);
      font-weight: 800;
    }

    .tutorial-mini-board {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .tutorial-cost-row {
      flex-wrap: wrap;
    }

    .tutorial-copy {
      display: grid;
      gap: 8px;
      width: min(1000px, 100%);
      min-width: 0;
      min-height: 0;
      justify-self: center;
      padding: 16px 18px;
      max-height: 100%;
      overflow-x: hidden;
      overflow-y: auto;
      overscroll-behavior: contain;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(32, 38, 51, 0.88);
      color: var(--muted);
      line-height: 1.42;
    }

    .tutorial-copy > strong {
      color: var(--ink);
      font-size: 1.12rem;
      line-height: 1.15;
    }

    .tutorial-copy strong {
      color: #fbbf24;
      font-weight: 950;
    }

    .tutorial-copy p {
      margin: 0;
    }

    .tutorial-lead {
      font-size: 0.95rem;
      font-weight: 800;
    }

    .tutorial-line {
      display: grid;
      gap: 2px;
      position: relative;
      padding-left: 18px;
      font-size: 0.9rem;
      font-weight: 760;
    }

    .tutorial-line::before {
      content: "";
      position: absolute;
      left: 1px;
      top: 0.64em;
      width: 7px;
      height: 7px;
      border-radius: 999px;
      background: #fbbf24;
      box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.14);
      transform: translateY(-50%);
    }

    .tutorial-line b {
      color: #fbbf24;
      font-size: 0.9rem;
      line-height: 1.2;
    }

    .tutorial-line span,
    .tutorial-line small {
      color: color-mix(in srgb, var(--muted), var(--ink) 14%);
      font-size: 0.84rem;
      font-weight: 740;
      line-height: 1.32;
    }

    .tutorial-line small {
      color: color-mix(in srgb, var(--muted), var(--ink) 28%);
    }

    .tutorial-note {
      margin-top: 2px;
      padding-top: 8px;
      border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .tutorial-note span {
      color: color-mix(in srgb, var(--muted), var(--ink) 18%);
      font-weight: 700;
    }

    .tutorial-actions {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      width: min(620px, 100%);
      height: var(--tutorial-actions-height);
      min-width: 0;
      justify-self: center;
    }

    .tutorial-actions button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      min-height: 0;
      padding: 0 16px;
      line-height: 1.15;
      white-space: nowrap;
    }

    #winnerPortrait:has(.intro-avatar-gate) {
      margin-bottom: 12px;
    }

    .dialog-actions button {
      position: relative;
      z-index: 1;
      width: 100%;
      min-width: 0;
      padding-left: 10px;
      padding-right: 10px;
      white-space: normal;
      overflow: visible;
      text-overflow: clip;
      line-height: 1.18;
    }

    .dialog-actions button.secondary {
      width: 100%;
    }

    .auto-battle-panel,
    .replay-controls {
      position: relative;
      z-index: 3;
      width: 100%;
      max-width: 100%;
      padding: 8px;
      border: 1px solid rgba(255, 255, 255, 0.13);
      border-radius: 8px;
      background: rgba(21, 27, 37, 0.34);
      box-shadow: 0 14px 42px rgba(0, 0, 0, 0.18);
      backdrop-filter: blur(7px);
      pointer-events: auto;
    }

    .auto-battle-panel {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    .replay-controls {
      position: fixed;
      left: 50%;
      right: auto;
      bottom: max(10px, env(safe-area-inset-bottom));
      z-index: calc(var(--z-settings-tools) + 20);
      display: grid;
      gap: 7px;
      align-items: center;
      justify-self: center;
      width: min(360px, calc(100vw - 20px));
      transform: translateX(-50%);
    }

    .auto-battle-panel[hidden],
    .replay-controls[hidden] {
      display: none;
    }

    /* Replay controls and archive modal */
    .replay-primary-controls {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      min-width: 0;
    }

    .replay-timeline-row {
      display: grid;
      grid-template-columns: minmax(78px, 1fr) auto;
      align-items: center;
      gap: 7px;
      min-width: 0;
    }

    .replay-controls input[type="range"] {
      width: 100%;
      min-width: 0;
    }

    .replay-time {
      color: var(--muted);
      font-size: 0.78rem;
      white-space: nowrap;
    }

    .auto-battle-panel label,
    .replay-controls label {
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 800;
      white-space: nowrap;
    }

    .replay-modal {
      position: fixed;
      inset: 0;
      z-index: 1200;
      display: grid;
      place-items: center;
      padding: 1rem;
      background: rgba(5, 8, 13, 0.72);
      backdrop-filter: blur(10px);
    }

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

    .replay-dialog {
      width: min(760px, 100%);
      max-height: min(82vh, 760px);
      overflow: auto;
      border: 1px solid rgba(255, 255, 255, 0.14);
      border-radius: 10px;
      background: #1a2230;
      box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
    }

    .replay-header,
    .replay-list-header,
    .replay-row,
    .replay-empty {
      padding: 0.85rem 1rem;
    }

    .replay-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .replay-header h2,
    .replay-list-header h3 {
      margin: 0;
    }

    .replay-list-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      color: var(--muted);
    }

    .replay-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 0.75rem;
      align-items: center;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .replay-title {
      display: block;
      color: var(--ink);
      font-weight: 700;
    }

    .replay-meta {
      margin-top: 0.25rem;
      color: var(--muted);
      font-size: 0.84rem;
    }

    .replay-actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 0.45rem;
    }

    .replay-message {
      min-height: 1.2rem;
      padding: 0 1rem 0.85rem;
      color: #facc15;
      font-size: 0.86rem;
    }

    .auto-battle-panel label {
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 800;
      white-space: nowrap;
    }

    .speed-scrubber,
    .auto-battle-panel button,
    .replay-controls button {
      min-height: 30px;
      padding: 6px 9px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(17, 23, 32, 0.5);
      color: var(--ink);
      border-radius: 8px;
      font: inherit;
      font-weight: 800;
      font-size: 0.82rem;
      line-height: 1;
    }

    .speed-scrubber {
      width: 62px;
      min-width: 62px;
      padding: 3px 7px;
      cursor: ns-resize;
      display: grid;
      grid-template-rows: 8px 1fr 8px;
      place-items: center;
      gap: 1px;
      touch-action: none;
      user-select: none;
    }

    .speed-scrubber::before,
    .speed-scrubber::after {
      display: block;
      color: rgba(243, 245, 247, 0.62);
      font-size: 0.55rem;
      line-height: 1;
    }

    .speed-scrubber::before {
      content: "▲";
    }

    .speed-scrubber::after {
      content: "▼";
    }

    .speed-scrubber.is-dragging {
      border-color: rgba(245, 158, 11, 0.64);
      background: rgba(245, 158, 11, 0.24);
    }

    .speed-scrubber.is-dragging::before,
    .speed-scrubber.is-dragging::after {
      color: rgba(255, 237, 213, 0.94);
    }

    .auto-speed-menu {
      position: absolute;
      right: 8px;
      top: calc(100% + 8px);
      z-index: 321;
      display: grid;
      grid-template-columns: repeat(2, minmax(44px, 1fr));
      gap: 5px;
      width: 102px;
      padding: 6px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.16);
      background: rgba(17, 23, 32, 0.56);
      box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
      backdrop-filter: blur(7px);
    }

    .auto-speed-menu[hidden] {
      display: none;
    }

    .auto-speed-menu button {
      min-height: 28px;
      padding: 5px 6px;
      font-size: 0.76rem;
    }

    .auto-speed-menu button.is-selected {
      border-color: rgba(245, 158, 11, 0.72);
      background: rgba(245, 158, 11, 0.24);
      color: #ffedd5;
    }

    .auto-battle-panel button[data-auto-pause],
    .replay-controls #replayPrevButton,
    .replay-controls #replayNextButton,
    .replay-controls #replayPlayButton,
    .replay-controls #replayReverseButton,
    .replay-controls #replayExitButton {
      width: 34px;
      min-width: 34px;
      padding: 6px 0;
      font-size: 0.9rem;
    }

    .replay-controls #replayPrevButton:disabled,
    .replay-controls #replayNextButton:disabled {
      opacity: 0.45;
      cursor: default;
    }

    .replay-controls #replayReverseButton.is-selected {
      border-color: rgba(245, 158, 11, 0.72);
      background: rgba(245, 158, 11, 0.24);
      color: #ffedd5;
    }

    .relay-panel {
      position: relative;
      z-index: 2;
      display: grid;
      gap: 4px;
      width: 100%;
      max-width: 100%;
      padding: 8px 10px;
      border: 1px solid rgba(255, 255, 255, 0.13);
      border-radius: 8px;
      background: rgba(21, 27, 37, 0.34);
      box-shadow: 0 14px 42px rgba(0, 0, 0, 0.18);
      backdrop-filter: blur(7px);
      pointer-events: auto;
    }

    .relay-panel[hidden] {
      display: none;
    }

    .relay-panel label {
      display: flex;
      align-items: center;
      gap: 7px;
      color: var(--ink);
      font-size: 0.84rem;
      font-weight: 800;
      white-space: nowrap;
    }

    .relay-panel input {
      width: 16px;
      height: 16px;
      accent-color: var(--accent);
    }

    .relay-score {
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 800;
      white-space: nowrap;
    }

    @media (max-width: 620px) {
      .overlay.tutorial-open {
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
      }

      .overlay.tutorial-open .dialog {
        width: 100%;
        height: 100%;
      }

      .tutorial-card {
        gap: 8px;
      }

      .tutorial-progress span {
        width: 22px;
      }

      .tutorial-visual.is-capture,
      .tutorial-visual.is-capture.is-move {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
        align-content: center;
        gap: 7px;
      }

      .tutorial-visual.is-capture .tutorial-capture-stage {
        order: 0;
      }

      .tutorial-visual.is-capture .tutorial-ui-snapshot {
        order: 1;
      }

      .tutorial-capture-stage img {
        max-height: calc(100dvh - 330px);
      }

      .tutorial-ui-snapshot.is-joystick,
      .tutorial-ui-snapshot.is-skills {
        width: min(116px, 42vw);
      }

      .tutorial-ui-snapshot.is-joystick .tutorial-snapshot-frame,
      .tutorial-ui-snapshot.is-skills .tutorial-snapshot-frame {
        padding: 8px;
      }

      .tutorial-ui-snapshot .joystick-zone,
      .tutorial-ui-snapshot .attack-actions,
      .tutorial-ui-snapshot .joystick {
        width: 88px;
      }

      .tutorial-ui-snapshot .attack-actions {
        height: 88px;
      }

      .tutorial-ui-snapshot .attack-actions .attack-button,
      .tutorial-ui-snapshot .attack-actions .attack-button.secondary {
        width: 30px;
        height: 30px;
        min-height: 30px;
        font-size: 0.56rem;
      }

      .tutorial-visual.is-resource-guide {
        grid-template-rows: minmax(0, auto) auto;
        align-content: center;
        gap: 8px;
      }

      .tutorial-resource-guide {
        gap: 6px;
      }

      .tutorial-resource-guide-panel {
        padding: 8px 10px;
      }

      .tutorial-resource-guide-panel strong {
        font-size: 0.86rem;
      }

      .tutorial-resource-guide-panel span {
        font-size: 0.74rem;
        line-height: 1.28;
      }

      .tutorial-food-detail-list {
        gap: 4px;
      }

      .tutorial-food-detail-list li {
        gap: 6px;
      }

      .tutorial-food-detail-list span {
        font-size: 0.74rem;
        line-height: 1.28;
      }

      .tutorial-copy {
        gap: 5px;
        padding: 8px 10px;
        font-size: 0.82rem;
      }

      .tutorial-copy > strong {
        font-size: 0.98rem;
      }

      .tutorial-lead,
      .tutorial-line,
      .tutorial-line span,
      .tutorial-line small {
        font-size: 0.74rem;
        line-height: 1.28;
      }

      .tutorial-line {
        gap: 1px;
        padding-left: 14px;
      }

      .tutorial-line::before {
        width: 5px;
        height: 5px;
      }

      .tutorial-line b {
        font-size: 0.76rem;
      }

      .tutorial-note {
        font-size: 0.72rem;
        line-height: 1.28;
        padding-top: 5px;
      }

      .tutorial-actions {
        gap: 6px;
      }

      .auto-battle-panel,
      .replay-controls,
      .relay-panel {
        position: fixed;
        top: auto;
        bottom: max(10px, env(safe-area-inset-bottom));
        max-width: min(154px, calc(50vw - 14px));
      }

      .auto-battle-panel {
        right: max(10px, env(safe-area-inset-right));
        z-index: calc(var(--z-settings-tools) + 20);
      }

      .replay-controls {
        left: 50%;
        right: auto;
        z-index: calc(var(--z-settings-tools) + 20);
        transform: translateX(-50%);
        max-width: min(320px, calc(100vw - 20px));
      }

      .relay-panel {
        left: max(10px, env(safe-area-inset-left));
      }

      .relay-panel {
        min-height: 46px;
      }

      .relay-score {
        white-space: normal;
        line-height: 1.15;
      }

      .auto-speed-menu {
        top: auto;
        bottom: calc(100% + 8px);
      }
    }

    .dialog p {
      margin: 0 0 16px;
      color: var(--muted);
    }

    .overlay.intro-details .dialog {
      width: min(760px, 100%);
      height: auto;
      max-height: calc(100dvh - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
      overflow-y: auto;
      overscroll-behavior: contain;
      display: grid;
      grid-template-rows: auto auto;
      align-content: start;
      gap: 10px;
    }

    .intro-close-button {
      justify-self: center;
      min-width: 120px;
    }

    /* Portrait lightbox */
    .portrait-lightbox {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: grid;
      grid-template-rows: minmax(0, 1fr);
      gap: 12px;
      padding:
        calc(max(14px, env(safe-area-inset-top)) + 48px)
        max(14px, env(safe-area-inset-right))
        calc(max(14px, env(safe-area-inset-bottom)) + 54px)
        max(14px, env(safe-area-inset-left));
      background: rgba(7, 10, 16, 0.92);
      place-items: center;
      isolation: isolate;
      touch-action: none;
    }

    .portrait-lightbox[hidden] {
      display: none;
    }

    .portrait-lightbox-figure {
      position: relative;
      z-index: 0;
      min-width: 0;
      min-height: 0;
      width: min(92vw, 680px);
      height: 100%;
      display: grid;
      grid-template-rows: minmax(0, 1fr) auto;
      place-items: center;
      margin: 0;
    }

    .portrait-lightbox-image {
      width: 100%;
      height: 100%;
      min-height: 0;
      object-fit: contain;
      filter: drop-shadow(0 24px 54px rgba(0, 0, 0, 0.58));
      pointer-events: none;
    }

    .portrait-lightbox-caption {
      margin: 8px 0 0;
      color: var(--ink);
      font-weight: 900;
      line-height: 1.25;
      text-align: center;
    }

    .portrait-lightbox-close {
      position: fixed;
      top: max(14px, env(safe-area-inset-top));
      right: max(14px, env(safe-area-inset-right));
      z-index: 1002;
      width: 44px;
      min-width: 44px;
      height: 42px;
      min-height: 42px;
      padding: 0;
      font-size: 0;
      pointer-events: auto;
    }

    .portrait-lightbox-close::before {
      content: "X";
      font-size: 1.35rem;
      line-height: 1;
    }

    .portrait-lightbox-arrow {
      position: absolute;
      top: 50%;
      width: 48px;
      height: 56px;
      min-height: 56px;
      padding: 0;
      transform: translateY(-50%);
      font-size: 2.2rem;
      line-height: 1;
      z-index: 1001;
    }

    .portrait-lightbox-arrow[data-portrait-lightbox-shift="-1"] {
      left: max(14px, env(safe-area-inset-left));
    }

    .portrait-lightbox-arrow[data-portrait-lightbox-shift="1"] {
      right: max(14px, env(safe-area-inset-right));
    }

    .portrait-lightbox-variant {
      position: fixed;
      left: 50%;
      z-index: 1001;
      width: min(112px, 34vw);
      min-height: 38px;
      padding: 6px 10px;
      transform: translateX(-50%);
      pointer-events: auto;
    }

    .portrait-lightbox-variant[data-portrait-lightbox-direction="up"] {
      top: max(14px, env(safe-area-inset-top));
    }

    .portrait-lightbox-variant[data-portrait-lightbox-direction="down"] {
      bottom: max(14px, env(safe-area-inset-bottom));
    }

    .portrait-lightbox-variant.is-selected {
      background: var(--accent);
      color: #171006;
      border-color: color-mix(in srgb, var(--accent), white 34%);
      box-shadow: 0 10px 28px rgba(245, 158, 11, 0.24);
    }

    button {
      border: 0;
      border-radius: 8px;
      background: var(--accent);
      color: #171006;
      font: inherit;
      font-weight: 800;
      cursor: pointer;
      padding: 10px 16px;
      min-height: 42px;
    }

    button:hover {
      filter: brightness(1.05);
    }

    button.secondary {
      width: 100%;
      background: #151b25;
      color: var(--ink);
      border: 1px solid var(--line);
    }

    .gm-preset-row button.secondary.is-selected {
      background: rgba(251, 191, 36, 0.18);
      color: #fde68a;
      border-color: rgba(251, 191, 36, 0.72);
      box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.16) inset;
    }

    button.secondary.portrait-lightbox-arrow {
      width: 48px;
    }

    button.secondary.portrait-lightbox-variant {
      width: min(96px, 28vw);
      min-width: 0;
      min-height: 34px;
      padding: 5px 8px;
      font-size: 0.86rem;
      z-index: 1001;
    }

    button.secondary.portrait-lightbox-close {
      width: 38px;
      min-width: 38px;
      height: 38px;
      min-height: 38px;
      padding: 0;
      z-index: 1002;
    }

    .side {
      min-height: 100%;
      border-radius: 8px;
      padding: 14px;
      display: grid;
      gap: 14px;
      align-content: start;
    }

    .section {
      padding: 12px;
      border-radius: 8px;
      background: rgba(39, 49, 64, 0.72);
      border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .side > .section {
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      box-shadow: none;
    }

    .section h2 {
      margin: 0 0 10px;
      font-size: 1rem;
    }

    .settings-section {
      position: relative;
      display: grid;
      justify-items: end;
      gap: 10px;
      z-index: var(--z-settings-tools);
    }

    .settings-section.open {
      z-index: var(--z-settings-open);
    }

    .settings-actions {
      display: grid;
      grid-template-columns: repeat(4, minmax(42px, 1fr));
      justify-self: end;
      align-items: stretch;
      gap: 6px;
      width: 100%;
    }

    .settings-toggle,
    .replay-toggle,
    .rules-toggle,
    .gm-toggle,
    .surrender-button {
      width: 100%;
      min-width: 0;
      min-height: 44px;
      padding: 0;
      display: inline-grid;
      place-items: center;
      background: #151b25;
      color: var(--ink);
      border: 1px solid var(--line);
    }

    .settings-actions > [hidden] {
      display: none !important;
    }

    .gm-toggle {
      padding: 0;
    }

    .gm-toggle.is-active {
      border-color: rgba(245, 158, 11, 0.72);
      color: #fde68a;
    }

    .gm-toggle.is-auto.is-active {
      background: rgba(245, 158, 11, 0.16);
      box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.22) inset;
    }

    .gm-letter {
      font-weight: 800;
      font-size: 1.12rem;
      line-height: 1;
      letter-spacing: 0;
    }

    .gm-toggle.is-auto .gm-letter {
      font-size: 0.72rem;
    }

    .settings-toggle:hover,
    .settings-toggle:focus-visible,
    .replay-toggle:hover,
    .replay-toggle:focus-visible,
    .gm-toggle:hover,
    .gm-toggle:focus-visible,
    .rules-toggle:hover,
    .rules-toggle:focus-visible,
    .surrender-button:hover,
    .surrender-button:focus-visible {
      border-color: var(--accent);
      outline: 2px solid rgba(245, 158, 11, 0.2);
      outline-offset: 2px;
    }

    .settings-toggle svg,
    .replay-toggle svg,
    .settings-action-icon {
      width: 22px;
      height: 22px;
      stroke: currentColor;
      fill: none;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .settings-action-icon {
      display: block;
    }

    .surrender-icon {
      fill: #fff;
      stroke: none;
    }

    .settings-title,
    .settings-action-label,
    .replay-toggle-label {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      padding: 0;
      overflow: hidden;
      clip: rect(0 0 0 0);
      white-space: nowrap;
      border: 0;
    }

    /* Settings modal and game-master controls */
    .settings-content {
      position: fixed;
      inset: 0;
      z-index: var(--z-settings-modal);
      display: grid;
      place-items: center;
      padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
      background: rgba(7, 10, 16, 0.78);
    }

    .settings-content[hidden] {
      display: none;
    }

    .settings-dialog {
      width: min(760px, 100%);
      max-height: min(86dvh, 760px);
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
      overflow: hidden;
      border-radius: 8px;
      background: rgba(32, 38, 51, 0.98);
      border: 1px solid rgba(255, 255, 255, 0.14);
      box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
    }

    .settings-modal-body {
      overflow-y: auto;
      padding: 16px;
      display: grid;
      gap: 16px;
      color: var(--muted);
      line-height: 1.45;
      overscroll-behavior: contain;
      scrollbar-gutter: stable;
      -webkit-overflow-scrolling: touch;
    }

    .settings-panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .settings-panel-header strong {
      min-width: 0;
      color: var(--ink);
      font-size: 1.2rem;
      line-height: normal;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    button.secondary.settings-panel-close {
      width: 30px;
      height: 30px;
      min-height: 30px;
      flex-basis: 30px;
    }

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

    .settings-quick-row > .field {
      gap: 5px;
      min-height: 0;
      padding: 0;
      border: 0;
      background: transparent;
    }

    .settings-toggle-field {
      color: var(--muted);
      font-weight: 800;
    }

    .settings-toggle-control {
      min-height: 33px;
      height: 33px;
      padding: 4px 8px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      align-items: center;
      gap: 8px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: #151b25;
      color: var(--ink);
    }

    .settings-toggle-control input {
      width: 18px;
      height: 18px;
      min-height: 18px;
      padding: 0;
      accent-color: var(--accent);
    }

    .settings-toggle-control span {
      min-width: 0;
      font-weight: 800;
      line-height: 1.1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .settings-quick-row .field select {
      min-height: 34px;
      padding: 6px 8px;
    }

    .gm-settings {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      padding: 10px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      background: rgba(21, 27, 37, 0.68);
    }

    .gm-settings[hidden] {
      display: none;
    }

    .gm-settings > .food-stock-grid {
      display: contents;
    }

    .gm-preset-row {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
    }

    .gm-settings .field + .field {
      margin-top: 0;
    }

    .gm-settings > button {
      grid-column: 1 / -1;
    }

    .settings-content > button.secondary {
      width: 100%;
    }

    .field {
      display: grid;
      gap: 8px;
    }

    .field label {
      color: var(--muted);
      font-size: 0.9rem;
      font-weight: 700;
    }

    .field + .field {
      margin-top: 10px;
    }

    .field input,
    .field select {
      width: 100%;
      min-height: 42px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: #151b25;
      color: var(--ink);
      font: inherit;
      font-weight: 800;
      padding: 8px 10px;
    }

    .field input:focus,
    .field select:focus {
      border-color: var(--accent);
      outline: 2px solid rgba(245, 158, 11, 0.22);
      outline-offset: 2px;
    }

    .field input:disabled,
    .field select:disabled {
      cursor: not-allowed;
      opacity: 0.58;
    }

    .settings-toggle-control input[type="checkbox"] {
      width: 18px;
      min-width: 18px;
      height: 18px;
      min-height: 18px;
      padding: 0;
      margin: 0;
      justify-self: start;
      flex: 0 0 auto;
    }

    .toggle-field {
      grid-template-columns: auto 1fr;
      align-items: center;
      gap: 10px;
      color: var(--muted);
      font-weight: 800;
    }

    .toggle-field input {
      width: 20px;
      min-height: 20px;
      accent-color: var(--accent);
    }

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

    .keybind-grid .field {
      gap: 5px;
    }

    .keybind-grid .field + .field {
      margin-top: 0;
    }

    .keybind-grid input {
      text-align: center;
      text-transform: uppercase;
    }

    .settings-direction-bindings {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: rgba(21, 27, 37, 0.36);
    }

    .settings-direction-title {
      margin: 0;
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 900;
      align-self: end;
    }

    .settings-dir-pad {
      grid-row: 1 / span 2;
      grid-column: 2;
      justify-self: end;
      width: min(118px, 32vw);
      touch-action: manipulation;
    }

    .settings-dir-pad.joystick {
      width: min(118px, 32vw);
      min-width: 96px;
      aspect-ratio: 1;
      flex: 0 0 auto;
    }

    .settings-dir-pad .hex-dir-button {
      cursor: pointer;
    }

    .settings-dir-pad .hex-dir-button.is-awaiting-key,
    .settings-dir-pad .hex-dir-button:focus-visible {
      background: rgba(245, 158, 11, 0.94);
      color: #171006;
      border-color: rgba(255, 255, 255, 0.78);
      outline: 3px solid rgba(245, 158, 11, 0.28);
      outline-offset: 2px;
      box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
    }

    .settings-dir-hint {
      grid-column: 1;
      min-height: 1.2em;
      color: var(--muted);
      font-size: 0.68rem;
      font-weight: 800;
      text-align: left;
    }

    .resource-board {
      display: grid;
      gap: 12px;
    }

    .resource-board:empty {
      min-height: 0;
    }

    .resource-board {
      margin-top: 0;
    }

    .section:has(> .resource-board) > h2 {
      display: none;
    }

    .character-picks {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .character-picks[hidden] {
      display: none;
    }

    .character-stage {
      position: absolute;
      top: 10px;
      left: 10px;
      right: 10px;
      z-index: 4;
      display: flex;
      justify-content: space-between;
      align-items: start;
      gap: 10px;
      pointer-events: none;
    }

    .character-stage[hidden] {
      display: none;
    }

    .character-stage.is-overlay-visible {
      z-index: calc(var(--z-session-overlay) + 20);
    }

    .character-stage.is-overlay-visible .fighter-card {
      pointer-events: none;
    }

    .fighter-card {
      position: relative;
      min-width: 0;
      display: grid;
      grid-template-columns: 64px;
      gap: 0;
      align-items: center;
      width: auto;
      padding: 8px;
      border-radius: 8px;
      background: rgba(15, 23, 36, 0.84);
      border: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
      backdrop-filter: blur(8px);
      pointer-events: auto;
    }

    .attack-callout {
      position: absolute;
      top: calc(100% + 7px);
      left: 50%;
      z-index: 6;
      max-width: min(220px, 34vw);
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid var(--callout-line, var(--owner-line));
      background: var(--callout-bg, rgba(15, 23, 36, 0.94));
      color: var(--callout-color, #ffffff);
      font-size: 0.78rem;
      font-weight: 950;
      line-height: 1.2;
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
      opacity: 0;
      transform: translate(-50%, -4px) scale(0.96);
      pointer-events: none;
      transition: opacity 120ms ease, transform 120ms ease;
    }

    .attack-callout::before {
      content: "";
      position: absolute;
      left: 50%;
      bottom: 100%;
      width: 9px;
      height: 9px;
      border-left: 1px solid var(--callout-line, var(--owner-line));
      border-top: 1px solid var(--callout-line, var(--owner-line));
      background: var(--callout-bg, rgba(15, 23, 36, 0.94));
      transform: translate(-50%, 4px) rotate(45deg);
    }

    .attack-callout.is-status {
      --callout-line: #93c5fd;
      --callout-bg: rgba(15, 23, 42, 0.96);
      --callout-color: #dbeafe;
    }

    .attack-callout.is-interrupt {
      --callout-line: #fbbf24;
      --callout-bg: rgba(32, 24, 12, 0.96);
      --callout-color: #fef3c7;
    }

    .attack-callout.is-victory {
      --callout-line: #fef08a;
      --callout-bg: rgba(46, 37, 12, 0.96);
      --callout-color: #fef9c3;
    }

    .attack-callout.is-defeat {
      --callout-line: #cbd5e1;
      --callout-bg: rgba(15, 23, 42, 0.96);
      --callout-color: #e2e8f0;
    }

    .attack-callout.is-visible {
      opacity: 1;
      transform: translate(-50%, 0) scale(1);
    }

    .fighter-card[data-owner="player"] {
      border-color: rgba(245, 158, 11, 0.38);
    }

    .fighter-card[data-owner="computer"] {
      border-color: rgba(167, 139, 250, 0.34);
    }

    .fighter-card[data-owner="player"],
    .fighter-card[data-owner="computer"],
    .intro-avatar-button[data-owner],
    .portrait-option[data-owner],
    .fighter-portrait[data-owner] {
      --owner-color: #f59e0b;
      --owner-line: #ffedd5;
    }

    [data-owner="computer"],
    .fighter-card[data-owner="computer"],
    .intro-avatar-button[data-owner="computer"],
    .portrait-option[data-owner="computer"],
    .fighter-portrait[data-owner="computer"] {
      --owner-color: #a78bfa;
      --owner-line: #ede9fe;
    }

    .fighter-module {
      position: relative;
      width: 64px;
      aspect-ratio: 1;
      border-radius: 50%;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
    }

    .fighter-module-clip {
      position: absolute;
      inset: 0;
      border-radius: inherit;
      display: grid;
      place-items: center;
      border: 1px solid color-mix(in srgb, var(--fighter-color), white 26%);
      background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.24), transparent 28px),
        color-mix(in srgb, var(--fighter-color), #101720 70%);
      box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.28);
      overflow: hidden;
    }

    .fighter-module-clip .fighter-avatar-image.portrait {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: var(--avatar-object-position, 50% 16%);
      transform: none;
      animation: module-swim 1500ms ease-in-out infinite;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"] {
      --avatar-object-position: 50% 18%;
      --avatar-scale: 1;
      --avatar-shift-x: 0%;
      --avatar-shift-y: 0%;
      object-fit: cover;
      object-position: var(--avatar-object-position);
      transform: translate(var(--avatar-shift-x), var(--avatar-shift-y)) scale(var(--avatar-scale));
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"] {
      --avatar-object-position: 50% 0%;
      --avatar-scale: 3.05;
      --avatar-shift-y: 76%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"][data-character-id="gu_king"] {
      --avatar-scale: 3.25;
      --avatar-shift-x: 15%;
      --avatar-shift-y: 101%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"][data-character-id="moray"] {
      --avatar-scale: 3.1;
      --avatar-shift-x: -18%;
      --avatar-shift-y: 86%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"][data-character-id="quetzal"] {
      --avatar-scale: 3.28;
      --avatar-shift-x: -4%;
      --avatar-shift-y: 87%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"][data-character-id="dragon"] {
      --avatar-scale: 3;
      --avatar-shift-x: -12%;
      --avatar-shift-y: 86%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"][data-character-id="lobster"] {
      --avatar-shift-y: 76%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="human"][data-character-id="sandworm"] {
      --avatar-scale: 3.15;
      --avatar-shift-y: 88%;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="beast"] {
      --avatar-object-position: 50% 11%;
      --avatar-scale: 1.04;
    }

    .fighter-avatar-image[data-avatar-kind="avatar"][data-portrait-variant="chibi"] {
      --avatar-object-position: 50% 24%;
      --avatar-scale: 1;
    }

    .fighter-module-clip .fighter-avatar-image[data-duel-avatar="true"] {
      --avatar-object-position: 50% 50%;
      --avatar-scale: 1;
      --avatar-shift-x: 0%;
      --avatar-shift-y: 0%;
      object-position: 50% 50%;
      transform: none;
    }

    .fighter-portrait::before {
      content: "";
      position: absolute;
      inset: 5px;
      border-radius: inherit;
      border: 2px solid var(--owner-color);
      opacity: 0.82;
      pointer-events: none;
      z-index: 2;
    }

    .fighter-module::after,
    .fighter-portrait::after {
      content: attr(data-owner-mark);
      position: absolute;
      right: 4px;
      bottom: 4px;
      min-width: 21px;
      height: 17px;
      padding: 0 4px;
      display: grid;
      place-items: center;
      border-radius: 999px;
      border: 1px solid var(--owner-line);
      background: color-mix(in srgb, var(--owner-color), #101720 34%);
      color: #ffffff;
      font-size: 0.6rem;
      font-weight: 950;
      line-height: 1;
      letter-spacing: 0;
      box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28);
      pointer-events: none;
      z-index: 3;
    }

    .fighter-portrait[data-owner="computer"]::before {
      border-style: dashed;
    }

    .fighter-module::after {
      right: -3px;
      bottom: -3px;
      min-width: 17px;
      height: 14px;
      padding: 0 3px;
      font-size: 0.5rem;
      z-index: 5;
    }

    .fighter-module.is-actionable {
      cursor: pointer;
    }

    .fighter-module.is-charging::before {
      content: "";
      position: absolute;
      inset: 5px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 0.76);
      animation: charge-ring 560ms linear infinite;
      pointer-events: none;
      z-index: 3;
    }

    .fighter-avatar {
      width: 92%;
      height: 92%;
      overflow: visible;
      filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.38));
      animation: module-swim 1500ms ease-in-out infinite;
    }

    .fighter-avatar-image {
      position: relative;
      z-index: 1;
      width: 100%;
      height: 100%;
      object-fit: contain;
      filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.38));
      animation: module-swim 1500ms ease-in-out infinite;
      pointer-events: none;
    }

    .fighter-avatar-image[data-pose="attack"] {
      opacity: 0.58;
      animation-duration: 520ms;
    }

    .fighter-avatar .body {
      fill: var(--fighter-color);
      stroke: var(--fighter-line);
      stroke-width: 4;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .fighter-avatar .accent {
      fill: var(--fighter-accent);
      stroke: var(--fighter-line);
      stroke-width: 2;
      stroke-linejoin: round;
    }

    .fighter-avatar .line {
      fill: none;
      stroke: var(--fighter-line);
      stroke-width: 3;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .fighter-avatar .eye {
      fill: #111720;
    }

    .fighter-portrait {
      position: relative;
      width: min(220px, 70vw);
      margin: 0 auto 12px;
      aspect-ratio: 1.05;
      display: grid;
      place-items: center;
      border-radius: 8px;
      border: 1px solid color-mix(in srgb, var(--fighter-color), white 28%);
      background:
        radial-gradient(circle at 50% 28%, color-mix(in srgb, var(--fighter-color), transparent 48%), transparent 64%),
        #101720;
      box-shadow: inset 0 0 40px rgba(255, 255, 255, 0.05), 0 16px 50px rgba(0, 0, 0, 0.38);
      overflow: hidden;
    }

    .fighter-portrait[data-owner="computer"] {
      background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0 7px, transparent 7px 15px),
        radial-gradient(circle at 50% 28%, color-mix(in srgb, var(--fighter-color), transparent 48%), transparent 64%),
        #101720;
    }

    .fighter-portrait .fighter-avatar {
      width: 88%;
      height: 88%;
      animation: portrait-float 1800ms ease-in-out infinite;
    }

    .fighter-portrait .fighter-avatar-image {
      width: 96%;
      height: 96%;
      object-fit: contain;
      animation: portrait-float 1800ms ease-in-out infinite;
    }

    .fighter-portrait.is-defeated {
      opacity: 0.38;
      filter: grayscale(0.78) brightness(0.62) saturate(0.72);
    }

    .result-portrait {
      cursor: pointer;
      overflow: hidden;
    }

    .result-entry {
      min-width: 0;
      display: grid;
      gap: 7px;
      align-content: start;
      cursor: pointer;
    }

    #winnerPortrait {
      position: relative;
      z-index: 1;
    }

    .result-portrait.is-defeated {
      opacity: 0.72;
      filter: grayscale(0.68) brightness(0.78) saturate(0.78);
    }

    .result-badge {
      position: absolute;
      left: 8px;
      top: 8px;
      z-index: 4;
      padding: 5px 9px;
      border-radius: 999px;
      background: rgba(15, 23, 36, 0.82);
      border: 1px solid var(--owner-line);
      color: #ffffff;
      font-size: 0.78rem;
      font-weight: 950;
      line-height: 1;
      box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
    }

    .result-portrait.is-winner .result-badge {
      background: color-mix(in srgb, var(--owner-color), #101720 28%);
    }

    .result-quote {
      display: grid;
      place-items: center;
      width: 100%;
      min-height: 3.05em;
      box-sizing: border-box;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: rgba(15, 23, 36, 0.74);
      color: #f8fafc;
      font-size: 0.86rem;
      font-weight: 850;
      line-height: 1.28;
      text-align: center;
      text-wrap: balance;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(5px);
    }

    .portrait-pair {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-bottom: 12px;
    }

    .result-pair {
      margin-bottom: 20px;
    }

    .dialog:has(.result-pair) h2 {
      margin-bottom: 4px;
      font-size: 1.46rem;
      line-height: 1.16;
    }

    .dialog:has(.result-pair) p {
      margin-bottom: 12px;
      font-size: 0.92rem;
      line-height: 1.22;
    }

    .portrait-pair .fighter-portrait {
      width: 100%;
      margin-bottom: 0;
    }

    .portrait-select {
      position: relative;
      display: grid;
      gap: 10px;
      align-content: start;
      touch-action: pan-y;
      user-select: none;
      -webkit-user-select: none;
      overflow: visible;
    }

    .overlay.intro-details .portrait-select {
      min-height: 0;
    }

    .intro-avatar-gate {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      place-items: center;
    }

    .intro-avatar-button {
      width: 100%;
      padding: 0;
      border-radius: 8px;
      display: grid;
      gap: 8px;
      place-items: center;
      background: transparent;
      color: inherit;
    }

    .intro-avatar-button .fighter-portrait {
      width: 100%;
      margin: 0;
      aspect-ratio: 1.05;
      border-radius: 8px;
      transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
    }

    .intro-avatar-button:hover .fighter-portrait,
    .intro-avatar-button:focus-visible .fighter-portrait {
      transform: scale(1.04);
      border-color: var(--fighter-accent);
      box-shadow: inset 0 0 40px rgba(255, 255, 255, 0.08), 0 18px 58px rgba(0, 0, 0, 0.46);
    }

    .intro-avatar-button .fighter-avatar-image {
      width: 96%;
      height: 96%;
      object-fit: cover;
      object-position: var(--avatar-object-position, 50% 18%);
    }

    .intro-avatar-label {
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 850;
      margin-top: 8px;
    }

    .intro-avatar-label-controls {
      margin-top: 8px;
    }

    .intro-avatar-label-controls .intro-avatar-label {
      margin-top: 0;
      padding: 3px 7px;
      border-radius: 999px;
      line-height: 1.2;
      white-space: nowrap;
    }

    .intro-avatar-motto {
      width: 100%;
      margin: 0;
      padding: 0 4px;
      color: color-mix(in srgb, var(--ink), var(--fighter-line) 22%);
      font-size: 0.76rem;
      font-weight: 760;
      line-height: 1.28;
      text-align: center;
      text-wrap: balance;
      white-space: normal;
      overflow-wrap: normal;
    }

    .intro-avatar-motto-line {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: pre;
    }

    .intro-avatar-motto.is-placeholder {
      color: color-mix(in srgb, var(--muted), transparent 12%);
      font-weight: 700;
    }

    .intro-avatar-logo {
      width: clamp(34px, 5.4vw, 54px);
      aspect-ratio: 1;
      display: grid;
      place-items: center;
      margin-top: -2px;
      border-radius: 50%;
      background:
        radial-gradient(circle, rgba(255, 255, 255, 0.14), transparent 62%),
        color-mix(in srgb, var(--owner-color), transparent 86%);
      border: 1px solid color-mix(in srgb, var(--owner-line), transparent 42%);
      box-shadow: 0 10px 24px color-mix(in srgb, var(--owner-color), transparent 82%);
      opacity: 0.9;
      pointer-events: none;
    }

    .intro-avatar-logo img {
      width: 76%;
      height: 76%;
      object-fit: contain;
      filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.38));
    }

    .portrait-select .portrait-pair {
      margin-bottom: 0;
    }

    .portrait-option {
      min-width: 0;
      display: grid;
      gap: 6px;
      padding: 0;
      border: 0;
      background: transparent;
      color: inherit;
      cursor: pointer;
    }

    .portrait-card-controls {
      position: relative;
      display: grid;
      width: 100%;
      touch-action: pan-y;
    }

    .portrait-label-controls {
      display: grid;
      grid-template-columns: 28px minmax(0, max-content) 28px;
      width: fit-content;
      max-width: 100%;
      justify-self: center;
      gap: 3px;
      align-items: center;
      touch-action: pan-y;
    }

    .portrait-option .fighter-portrait {
      max-width: 100%;
      opacity: 0.66;
      transform: scale(0.96);
      transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
    }

    .portrait-option.is-selected .fighter-portrait {
      opacity: 1;
      transform: scale(1);
      border-color: var(--fighter-accent);
      box-shadow:
        inset 0 0 0 2px color-mix(in srgb, var(--fighter-accent), white 24%),
        inset 0 0 40px rgba(255, 255, 255, 0.08),
        0 0 0 3px color-mix(in srgb, var(--owner-color), transparent 42%),
        0 18px 58px color-mix(in srgb, var(--owner-color), transparent 72%);
    }

    .portrait-option-label {
      justify-self: center;
      max-width: 100%;
      padding: 4px 8px;
      border-radius: 999px;
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 800;
      line-height: 1.2;
      transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
    }

    .portrait-option.is-selected .portrait-option-label {
      color: var(--ink);
      background: color-mix(in srgb, var(--owner-color), #101720 58%);
      border: 1px solid color-mix(in srgb, var(--owner-line), transparent 38%);
      box-shadow: 0 8px 20px color-mix(in srgb, var(--owner-color), transparent 78%);
    }

    .overlay.intro-details .fighter-portrait {
      cursor: zoom-in;
    }

    .fighter-portrait.is-random {
      display: grid;
      place-items: center;
      overflow: hidden;
      cursor: default;
      --random-portrait-mark-size: 100%;
      --random-portrait-mark-font-size: clamp(3.4rem, 13vw, 6.4rem);
    }

    .overlay.intro-details .fighter-portrait.is-random {
      --random-portrait-mark-size: 100%;
      --random-portrait-mark-font-size: clamp(4.25rem, 16vw, 8rem);
      cursor: default;
    }

    .random-portrait-mark {
      width: var(--random-portrait-mark-size);
      aspect-ratio: 1;
      border-radius: 999px;
      display: grid;
      place-items: center;
      border: 2px solid color-mix(in srgb, var(--fighter-line), transparent 20%);
      background:
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.34), transparent 24%),
        color-mix(in srgb, var(--fighter-color), #101720 26%);
      color: var(--ink);
      font-size: var(--random-portrait-mark-font-size, clamp(2.4rem, 9vw, 4.8rem));
      font-weight: 950;
      line-height: 1;
      box-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
    }

    .fighter-portrait.is-random .random-portrait-mark {
      width: var(--random-portrait-mark-size);
      height: var(--random-portrait-mark-size);
      box-sizing: border-box;
      place-self: center;
      border-radius: inherit;
      animation: none;
      transform: none;
    }

    .random-portrait-mark.intro-avatar-logo-mark {
      --random-portrait-mark-size: 66%;
      font-size: clamp(1.1rem, 3.5vw, 1.8rem);
      border-width: 1px;
    }

    .overlay.intro-details .fighter-portrait .fighter-avatar-image,
    .overlay.intro-details .fighter-portrait .fighter-avatar {
      width: 90%;
      height: 90%;
      animation: none;
    }

    .overlay.intro-details .fighter-portrait.is-random .random-portrait-mark {
      width: var(--random-portrait-mark-size);
      height: var(--random-portrait-mark-size);
    }

    .portrait-controls {
      position: relative;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      padding: 0 50px;
      align-items: start;
      min-height: 0;
    }

    .portrait-arrow {
      min-width: 0;
      width: 42px;
      height: 42px;
      padding: 0;
      border-radius: 999px;
      font-size: 1.5rem;
      line-height: 1;
      align-self: center;
      justify-self: center;
      position: absolute;
      top: 73px;
      z-index: 2;
    }

    button.secondary.portrait-arrow {
      width: 42px;
    }

    .portrait-controls > .portrait-arrow {
      display: none;
    }

    .portrait-card-controls .portrait-arrow {
      position: static;
      align-self: center;
      justify-self: center;
      flex: 0 0 auto;
      top: auto;
      transform: none;
    }

    .portrait-label-controls .portrait-arrow {
      position: static;
      width: 28px;
      height: 28px;
      min-height: 28px;
      padding: 0;
      border-radius: 6px;
      font-size: 1rem;
      transform: none;
    }

    button.secondary.portrait-label-arrow {
      width: 28px;
    }

    .portrait-controls .portrait-arrow:first-child {
      left: 0;
    }

    .portrait-controls .portrait-arrow:last-child {
      right: 0;
    }

    .portrait-copy {
      min-width: 0;
      display: grid;
      gap: 4px;
      text-align: left;
      min-height: 0;
    }

    .portrait-copy > strong {
      color: var(--ink);
      font-size: 1.08rem;
      line-height: 1.2;
    }

    .portrait-copy span,
    .portrait-copy small {
      color: var(--muted);
      line-height: 1.35;
    }

    .portrait-copy small {
      font-weight: 800;
    }

    .portrait-story {
      margin-top: 6px;
      display: grid;
      gap: 6px;
      color: color-mix(in srgb, var(--muted), var(--fighter-line) 18%);
      font-size: 0.86rem;
      line-height: 1.55;
    }

    .portrait-story p {
      margin: 0;
    }

    .portrait-motto {
      margin: 0;
      color: var(--ink);
      font-weight: 850;
      line-height: 1.4;
    }

    .portrait-moves {
      display: grid;
      gap: 6px;
    }

    .portrait-moves span {
      display: block;
      padding: 4px 8px;
      border: 1px solid color-mix(in srgb, var(--fighter-line), transparent 34%);
      border-radius: 999px;
      background: color-mix(in srgb, var(--fighter-color), transparent 88%);
      color: color-mix(in srgb, var(--ink), var(--fighter-accent) 18%);
      font-size: 0.78rem;
      font-weight: 800;
    }

    .overlay.intro-details .portrait-copy .portrait-moves .inline-food-term.inline-food-term {
      font-size: 1em;
      line-height: inherit;
      font-weight: inherit;
      padding: 0;
      background: transparent;
    }

    @keyframes module-swim {
      0%, 100% { transform: translateY(1px) rotate(-2deg); }
      50% { transform: translateY(-3px) rotate(3deg); }
    }

    @keyframes portrait-float {
      0%, 100% { transform: translateY(2px) scale(1); }
      50% { transform: translateY(-5px) scale(1.03); }
    }

    @media (min-width: 901px) {
      .overlay.intro-details .portrait-controls {
        position: static;
      }

      .overlay.intro-details .portrait-arrow {
        position: fixed;
        top: calc(50dvh - 196px);
        transform: translateY(-50%);
      }

      .overlay.intro-details .portrait-controls .portrait-arrow:first-child {
        left: calc(50% - 363px);
      }

      .overlay.intro-details .portrait-controls .portrait-arrow:last-child {
        right: calc(50% - 363px);
      }

      .overlay.intro-details .portrait-card-controls .portrait-arrow,
      .overlay.intro-details .portrait-label-controls .portrait-arrow {
        position: static;
        top: auto;
        left: auto;
        right: auto;
        transform: none;
      }
    }

    @keyframes charge-ring {
      from { transform: scale(0.84); opacity: 0.92; }
      to { transform: scale(1.08); opacity: 0.12; }
    }

    .resource-panel {
      --resource-owner-color: var(--p1-color);
      --resource-owner-line: #ffedd5;
      display: grid;
      gap: 8px;
      min-width: 0;
      padding: 10px;
      border-radius: 8px;
      border: 1px solid color-mix(in srgb, var(--resource-owner-color), transparent 24%);
      background:
        linear-gradient(180deg, color-mix(in srgb, var(--resource-owner-color), transparent 78%), color-mix(in srgb, var(--resource-owner-color), transparent 90%)),
        rgba(15, 23, 36, 0.6);
      box-shadow:
        inset 0 0 0 1px color-mix(in srgb, var(--resource-owner-line), transparent 86%),
        0 0 22px color-mix(in srgb, var(--resource-owner-color), transparent 78%);
    }

    .resource-panel[data-owner="computer"] {
      --resource-owner-color: var(--p2-color);
      --resource-owner-line: #ede9fe;
    }

    .resource-title {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      align-items: center;
      gap: 10px;
      min-width: 0;
      padding-bottom: 7px;
      border-bottom: 1px solid color-mix(in srgb, var(--resource-owner-color), transparent 44%);
      font-weight: 800;
      color: var(--ink);
    }

    .resource-owner {
      min-width: 0;
      white-space: nowrap;
    }

    .resource-counters {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: center;
      justify-content: stretch;
      gap: 6px;
      width: 100%;
      min-width: 0;
    }

    .resource-chip {
      --resource-chip-color: var(--accent);
      --resource-chip-line: #fef3c7;
      position: relative;
      display: inline-grid;
      grid-template-columns: 14px minmax(28px, 1fr) auto;
      align-items: center;
      gap: 4px;
      min-width: 0;
      min-height: 20px;
      padding: 2px 6px;
      border-radius: 999px;
      background: #151b25;
      border: 1px solid rgba(255, 255, 255, 0.08);
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 700;
    }

    .resource-chip[data-resource="bomb"] {
      --resource-chip-color: #050505;
      --resource-chip-line: #e5e7eb;
    }

    .resource-chip[data-resource="energy"] {
      --resource-chip-color: #050505;
      --resource-chip-line: #e5e7eb;
    }

    .resource-chip-track {
      position: relative;
      display: block;
      width: 100%;
      height: 7px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(7, 10, 16, 0.64);
      border: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.38);
    }

    .resource-chip-fill {
      display: block;
      width: 100%;
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, color-mix(in srgb, var(--resource-chip-color), black 10%), var(--resource-chip-color));
      box-shadow: 0 0 9px color-mix(in srgb, var(--resource-chip-color), transparent 56%);
      transform: scaleX(var(--resource-ratio, 0));
      transform-origin: left center;
      transition: transform 140ms ease;
    }

    .resource-chip-value {
      min-width: 2.55em;
      color: var(--ink);
      font-variant-numeric: tabular-nums;
      text-align: right;
      white-space: nowrap;
    }

    .resource-chip.is-flashing {
      animation: resource-chip-flash 560ms ease-in-out 3;
      border-color: rgba(250, 204, 21, 0.78);
    }

    .resource-icon {
      position: relative;
      display: inline-block;
      width: 14px;
      height: 14px;
      flex: 0 0 auto;
    }

    .resource-chip.is-flashing .resource-icon {
      animation: resource-flash 560ms ease-in-out 3;
    }

    .energy-icon {
      --icon-rotate: -8deg;
      border-radius: 4px 4px 5px 5px;
      background:
        linear-gradient(90deg, transparent 0 24%, rgba(255, 255, 255, 0.34) 24% 34%, transparent 34%),
        linear-gradient(180deg, #52525b 0 18%, #18181b 18% 58%, #050505 58% 100%);
      border: 1px solid #e5e7eb;
      box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28), 0 0 8px rgba(229, 231, 235, 0.16);
      transform: rotate(-8deg);
    }

    .energy-icon::before {
      content: "";
      position: absolute;
      left: 4px;
      top: -4px;
      width: 6px;
      height: 4px;
      border-radius: 2px 2px 1px 1px;
      background: #e5e7eb;
      border: 1px solid #f8fafc;
    }

    .energy-icon::after {
      content: "";
      position: absolute;
      left: 2px;
      top: 5px;
      width: 8px;
      height: 4px;
      border-radius: 2px;
      background: #f8fafc;
      box-shadow: inset 0 0 0 1px rgba(5, 5, 5, 0.42);
    }

    .missile-icon {
      --icon-rotate: -10deg;
      transform: rotate(-10deg);
    }

    .missile-icon::before {
      content: "";
      position: absolute;
      left: 2px;
      top: 4px;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background:
        radial-gradient(circle at 34% 28%, #f8fafc 0 12%, transparent 13%),
        linear-gradient(180deg, #52525b 0%, #18181b 100%);
      border: 1px solid #a1a1aa;
      box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.34);
    }

    .missile-icon::after {
      content: "";
      position: absolute;
      left: 8px;
      top: 0;
      width: 6px;
      height: 7px;
      border-top: 2px solid #facc15;
      border-right: 2px solid #facc15;
      border-radius: 0 7px 0 0;
      transform: rotate(12deg);
    }

    @keyframes resource-flash {
      0%, 100% {
        filter: brightness(1);
        transform: scale(1) rotate(var(--icon-rotate, 0deg));
      }
      45% {
        filter: brightness(2.35) saturate(1.35) drop-shadow(0 0 12px #fde047);
        transform: scale(1.42) rotate(var(--icon-rotate, 0deg));
      }
    }

    @keyframes resource-chip-flash {
      0%, 100% {
        background: #151b25;
        box-shadow: none;
        color: var(--muted);
      }
      45% {
        background: #3b2f0b;
        box-shadow:
          0 0 0 2px rgba(250, 204, 21, 0.42),
          0 0 18px rgba(250, 204, 21, 0.72);
        color: #fff7d6;
      }
    }

    .resource-row {
      display: grid;
      grid-template-columns: 48px minmax(0, 1fr) 28px;
      gap: 8px;
      align-items: center;
      color: color-mix(in srgb, var(--food-line), var(--food-color) 22%);
      font-size: 0.82rem;
      font-weight: 800;
    }

    .resource-label,
    .resource-count {
      color: color-mix(in srgb, var(--food-line), var(--food-color) 22%);
      text-shadow: 0 0 10px color-mix(in srgb, var(--food-color), transparent 66%);
    }

    .resource-count {
      font-variant-numeric: tabular-nums;
      text-align: right;
    }

    .resource-track {
      position: relative;
      display: block;
      height: 9px;
      border-radius: 999px;
      background:
        linear-gradient(90deg, color-mix(in srgb, var(--food-color), transparent 88%), rgba(21, 27, 37, 0.9)),
        #151b25;
      overflow: hidden;
      border: 1px solid color-mix(in srgb, var(--food-line), transparent 58%);
      box-shadow:
        inset 0 0 0 1px color-mix(in srgb, var(--food-color), transparent 76%),
        0 0 10px color-mix(in srgb, var(--food-color), transparent 84%);
    }

    .resource-track::after {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: inherit;
      background:
        repeating-linear-gradient(
          90deg,
          transparent 0,
          transparent calc(5% - 1px),
          rgba(15, 23, 36, 0.76) calc(5% - 1px),
          rgba(15, 23, 36, 0.76) 5%
        );
      pointer-events: none;
    }

    .resource-fill {
      display: block;
      width: 0%;
      height: 100%;
      border-radius: inherit;
      transition: width 140ms ease;
      background: linear-gradient(90deg, var(--food-color), var(--food-line));
      box-shadow: 0 0 12px color-mix(in srgb, var(--food-color), transparent 52%);
    }

    .control-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .battle-control-panels {
      display: grid;
      gap: 8px;
      margin-top: 10px;
    }

    .control-section {
      position: relative;
      padding-bottom: 12px;
    }

    .control-section h2 {
      display: none;
    }

    .control-row.left-handed {
      direction: rtl;
    }

    .control-row.left-handed > * {
      direction: ltr;
    }

    .control-card {
      display: grid;
      gap: 8px;
      place-items: center;
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 800;
      min-width: 0;
    }

    .joystick-zone {
      display: grid;
      place-items: center;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
      width: 100%;
    }

    .joystick {
      position: relative;
      width: min(118px, 100%);
      aspect-ratio: 1;
      border-radius: 50%;
      background:
        conic-gradient(from 30deg, rgba(245, 158, 11, 0.18), rgba(239, 68, 68, 0.12), rgba(139, 92, 246, 0.16), rgba(245, 158, 11, 0.18)),
        #151b25;
      border: 1px solid var(--line);
      box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.35);
    }

    .hex-dir-button {
      position: absolute;
      left: var(--joy-x);
      top: var(--joy-y);
      width: 35.5%;
      aspect-ratio: 1;
      padding: 0;
      min-height: 0;
      display: grid;
      place-items: center;
      clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0 50%);
      background: rgba(15, 23, 42, 0.84);
      color: var(--ink);
      border: 1px solid rgba(255, 255, 255, 0.2);
      font-size: 0.8rem;
      line-height: 1;
      transform: translate(-50%, -50%) rotate(-30deg);
      z-index: 2;
    }

    .hex-dir-button > span {
      transform: rotate(30deg);
    }

    .hex-dir-button.active {
      background: rgba(245, 158, 11, 0.88);
      color: #171006;
      border-color: rgba(255, 255, 255, 0.6);
    }

    .hex-dir-button[data-dir="0"] { --joy-x: 34.5%; --joy-y: 23.2%; }
    .hex-dir-button[data-dir="1"] { --joy-x: 65.5%; --joy-y: 23.2%; }
    .hex-dir-button[data-dir="2"] { --joy-x: 81%; --joy-y: 50%; }
    .hex-dir-button[data-dir="3"] { --joy-x: 65.5%; --joy-y: 76.8%; }
    .hex-dir-button[data-dir="4"] { --joy-x: 34.5%; --joy-y: 76.8%; }
    .hex-dir-button[data-dir="5"] { --joy-x: 19%; --joy-y: 50%; }

    .joystick.locked {
      border-color: var(--accent);
      box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.35),
        0 0 0 3px rgba(245, 158, 11, 0.2);
    }

    .stick {
      position: absolute;
      left: 50%;
      top: 50%;
      width: 46px;
      aspect-ratio: 1;
      border-radius: 50%;
      translate: -50% -50%;
      background: var(--accent-2);
      border: 5px solid rgba(255, 255, 255, 0.22);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
      transition: transform 80ms ease;
      z-index: 3;
    }

    .stick.is-rebounding {
      transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .target-stick {
      background: var(--accent);
    }

    .action-panel {
      position: relative;
      display: grid;
      grid-template-rows: 1fr;
      gap: 6px;
      width: 100%;
      min-height: 118px;
    }

    .attack-actions {
      position: relative;
      width: 118px;
      height: 118px;
      justify-self: center;
    }

    .attack-actions .attack-button {
      position: absolute;
      box-sizing: border-box;
      width: 38px;
      height: 38px;
      min-width: 0;
      min-height: 0;
      padding: 0;
      border: 1px solid transparent;
      display: grid;
      place-items: center;
      line-height: 1.1;
      border-radius: 50%;
      font-size: 0.66rem;
      white-space: nowrap;
    }

    .attack-actions .attack-button.secondary {
      width: 38px;
    }

    .attack-actions .attack-button[data-pad-pos="top"] {
      left: 50%;
      top: 0;
      transform: translateX(-50%);
    }

    .attack-actions .attack-button[data-pad-pos="right"] {
      right: 0;
      top: 50%;
      transform: translateY(-50%);
    }

    .attack-actions .attack-button[data-pad-pos="bottom"] {
      left: 50%;
      bottom: 0;
      transform: translateX(-50%);
    }

    .attack-actions .attack-button[data-pad-pos="left"] {
      left: 0;
      top: 50%;
      transform: translateY(-50%);
    }

    .attack-button.is-placeholder {
      opacity: 0.42;
      pointer-events: none;
    }

    .attack-button.is-selected {
      border-color: rgba(255, 255, 255, 0.65);
      box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
    }

    .surrender-button {
      background: #7f1d1d;
      color: #fee2e2;
      border: 1px solid rgba(254, 202, 202, 0.24);
    }

    /* Rules modal */
    .rules-modal {
      position: fixed;
      inset: 0;
      z-index: var(--z-settings-modal);
      display: grid;
      place-items: center;
      padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
      background: rgba(7, 10, 16, 0.78);
    }

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

    .rules-dialog {
      width: min(760px, 100%);
      max-height: min(86dvh, 760px);
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
      overflow: hidden;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.14);
      background: rgba(32, 38, 51, 0.98);
      box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
    }

    .rules-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      padding: 14px 16px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .rules-header h2 {
      margin: 0;
      font-size: 1.2rem;
    }

    button.secondary.rules-close,
    button.secondary.replay-close,
    button.secondary.settings-panel-close {
      width: 42px;
      height: 42px;
      min-height: 42px;
      padding: 0;
      display: inline-grid;
      flex: 0 0 42px;
      place-items: center;
      line-height: 1;
      font-size: 1.45rem;
      font-weight: 900;
    }

    .rules-content {
      overflow-y: auto;
      padding: 16px;
      display: grid;
      gap: 16px;
      color: var(--muted);
      line-height: 1.45;
    }

    .rules-block {
      display: grid;
      gap: 8px;
    }

    .rules-block h3 {
      margin: 0;
      color: var(--ink);
      font-size: 1rem;
    }

    .rules-block p {
      margin: 0;
    }

    .rules-tutorial-callout {
      padding: 12px;
      border-radius: 8px;
      border: 1px solid rgba(251, 191, 36, 0.48);
      background:
        linear-gradient(135deg, rgba(245, 158, 11, 0.23), rgba(251, 191, 36, 0.13)),
        rgba(32, 38, 51, 0.88);
      color: #fef3c7;
      cursor: pointer;
      box-shadow: inset 0 0 0 1px rgba(254, 243, 199, 0.08), 0 10px 24px rgba(0, 0, 0, 0.18);
      transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
    }

    .rules-tutorial-callout h3 {
      color: #fde68a;
    }

    .rules-tutorial-callout p {
      color: #fef3c7;
    }

    .rules-tutorial-callout:hover,
    .rules-tutorial-callout:focus-visible {
      border-color: rgba(251, 191, 36, 0.78);
      background:
        linear-gradient(135deg, rgba(245, 158, 11, 0.34), rgba(251, 191, 36, 0.18)),
        rgba(32, 38, 51, 0.94);
      box-shadow: inset 0 0 0 1px rgba(254, 243, 199, 0.14), 0 0 0 3px rgba(245, 158, 11, 0.18), 0 14px 34px rgba(0, 0, 0, 0.24);
      transform: translateY(-1px);
      outline: none;
    }

    .rules-list,
    .rules-character-list {
      display: grid;
      gap: 8px;
      margin: 0;
      padding: 0;
      list-style: none;
    }

    .rules-list b,
    .rules-character-list b,
    .rules-character-list strong {
      color: var(--ink);
    }

    .rule-food-line,
    .rule-food-effect {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .rule-food-effect {
      flex-wrap: wrap;
      margin-top: 4px;
    }

    .rule-move-line {
      display: block;
      margin-top: 4px;
      line-height: 1.45;
    }

    .inline-keyword.inline-keyword {
      color: color-mix(in srgb, var(--ink), #fbbf24 18%);
      font-weight: 950;
    }

    .inline-food-term.inline-food-term {
      --food-term-color: #e5e7eb;
      color: var(--food-term-color);
      font-weight: 950;
      padding: 0 0.08em;
      border-radius: 4px;
      background: color-mix(in srgb, var(--food-term-color), transparent 88%);
    }

    .inline-food-term.is-protein {
      --food-term-color: #fca5a5;
    }

    .inline-food-term.is-fat {
      --food-term-color: #fde68a;
    }

    .inline-food-term.is-fiber {
      --food-term-color: #86efac;
    }

    .inline-food-term.is-carb {
      --food-term-color: #93c5fd;
    }

    .inline-food-term.is-black {
      --food-term-color: #e5e7eb;
      background: rgba(5, 5, 5, 0.32);
      border-bottom: 1px solid rgba(229, 231, 235, 0.26);
    }

    .inline-food-term.is-dual {
      --food-term-color: #fdba74;
      background: linear-gradient(90deg, rgba(252, 165, 165, 0.16), rgba(147, 197, 253, 0.14));
    }

    .food-icon-group {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      flex: 0 0 auto;
      vertical-align: middle;
    }

    .food-icon {
      --food-color: #94a3b8;
      --food-line: #f8fafc;
      position: relative;
      display: inline-block;
      width: 18px;
      height: 18px;
      flex: 0 0 18px;
      background: var(--food-color);
      border: 2px solid var(--food-line);
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
    }

    .food-icon.is-protein {
      border-radius: 999px;
    }

    .food-icon.is-fat {
      transform: rotate(45deg) scale(0.86);
    }

    .food-icon.is-fat::after {
      transform: translate(-50%, -50%) rotate(-45deg);
    }

    .food-icon.is-fiber {
      clip-path: polygon(50% 0%, 98% 35%, 79% 92%, 21% 92%, 2% 35%);
    }

    .food-icon.is-carb {
      clip-path: polygon(50% 4%, 96% 88%, 4% 88%);
    }

    .food-icon.is-black {
      border-radius: 999px;
    }

    .food-icon::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      width: 8px;
      height: 8px;
      transform: translate(-50%, -50%);
      border-color: #111720;
      color: #111720;
      pointer-events: none;
    }

    .food-icon.is-protein::after {
      width: 10px;
      height: 7px;
      border-bottom: 2px solid currentColor;
      border-radius: 50%;
      transform: translate(-50%, -48%) rotate(-16deg);
    }

    .food-icon.is-fat::after {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: currentColor;
    }

    .food-icon.is-fiber::after {
      width: 10px;
      height: 12px;
      border-left: 2px solid currentColor;
      border-top: 2px solid currentColor;
      border-radius: 70% 0 0 0;
      transform: translate(-34%, -42%) rotate(24deg);
    }

    .food-icon.is-carb::after {
      width: 9px;
      height: 7px;
      border-left: 2px solid currentColor;
      border-bottom: 2px solid currentColor;
      transform: translate(-50%, -44%) rotate(-45deg);
    }

    .food-icon.is-black::after {
      width: 11px;
      height: 6px;
      border-top: 2px solid #e5e7eb;
      transform: translate(-50%, -30%) skewX(-18deg);
    }

    .rules-character-list li {
      --fighter-color: #94a3b8;
      --fighter-line: #e5e7eb;
      --fighter-accent: #f8fafc;
      display: grid;
      grid-template-columns: 58px minmax(0, 1fr);
      gap: 10px;
      align-items: start;
      padding: 10px;
      border-radius: 8px;
      background:
        linear-gradient(135deg, color-mix(in srgb, var(--fighter-color), transparent 78%), rgba(15, 23, 36, 0.62) 58%),
        radial-gradient(circle at 30px 30px, color-mix(in srgb, var(--fighter-accent), transparent 72%), transparent 62%);
      border: 1px solid color-mix(in srgb, var(--fighter-line), transparent 38%);
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fighter-color), transparent 78%);
    }

    .rules-character-avatar {
      width: 58px;
      height: 58px;
      border-radius: 999px;
      overflow: hidden;
      display: grid;
      place-items: center;
      background: color-mix(in srgb, var(--fighter-color), #111827 72%);
      border: 2px solid color-mix(in srgb, var(--fighter-line), transparent 16%);
      box-shadow: 0 0 18px color-mix(in srgb, var(--fighter-color), transparent 62%);
    }

    .rules-character-avatar img {
      width: 118%;
      height: 118%;
      object-fit: contain;
      transform: translateY(4%);
    }

    .rules-character-body {
      min-width: 0;
    }

    .rules-character-title {
      display: flex;
      flex-wrap: wrap;
      gap: 4px 8px;
      align-items: baseline;
      margin-bottom: 4px;
    }

    .rules-character-role {
      color: color-mix(in srgb, var(--ink), var(--fighter-accent) 34%);
      font-size: 0.82rem;
      font-weight: 800;
    }

    .rules-about-me {
      padding: 14px;
      border-radius: 8px;
      border: 1px solid rgba(96, 165, 250, 0.28);
      background:
        linear-gradient(135deg, rgba(96, 165, 250, 0.12), rgba(15, 23, 36, 0.68) 58%),
        radial-gradient(circle at 26px 22px, rgba(251, 191, 36, 0.18), transparent 46%);
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    }

    .rules-about-heading {
      display: grid;
      grid-template-columns: 74px minmax(0, 1fr);
      gap: 10px;
      align-items: center;
    }

    .rules-about-logo {
      width: 74px;
      aspect-ratio: 1;
      object-fit: contain;
      filter: drop-shadow(0 10px 24px rgba(14, 165, 233, 0.24));
    }

    .rules-about-copy {
      min-width: 0;
      display: grid;
      gap: 4px;
    }

    .rules-about-name {
      color: #dbeafe;
      font-size: 1rem;
      line-height: 1.2;
    }

    .rules-about-line {
      color: var(--ink);
      font-weight: 800;
    }

    .rules-about-quote {
      display: grid;
      gap: 4px;
      margin: 0;
      padding: 2px 0 2px 12px;
      border-left: 3px solid rgba(251, 191, 36, 0.66);
    }

    .rules-about-quote p {
      margin: 0;
      color: #e5e7eb;
      font-size: 0.96rem;
    }

    .rules-about-quote cite {
      color: var(--muted);
      font-size: 0.84rem;
      font-style: normal;
    }

    .rules-about-links {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 2px;
    }

    .rules-about-link {
      display: inline-grid;
      grid-template-columns: 22px auto;
      align-items: center;
      gap: 8px;
      min-height: 34px;
      max-width: 100%;
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid rgba(148, 163, 184, 0.28);
      background: rgba(15, 23, 42, 0.58);
      color: var(--ink);
      font-size: 0.86rem;
      font-weight: 900;
      line-height: 1.15;
      text-decoration: none;
    }

    .rules-about-link:hover,
    .rules-about-link:focus-visible {
      border-color: rgba(251, 191, 36, 0.62);
      background: rgba(30, 41, 59, 0.82);
      outline: none;
      box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.14);
    }

    .rules-about-icon {
      width: 22px;
      height: 22px;
      display: grid;
      place-items: center;
      padding: 3px;
      border-radius: 6px;
      background: #f8fafc;
      color: #0f172a;
      font-size: 0.68rem;
      font-weight: 1000;
      line-height: 1;
      object-fit: contain;
    }

    @media (max-width: 520px) {
      .rules-about-heading {
        grid-template-columns: 58px minmax(0, 1fr);
      }

      .rules-about-logo {
        width: 58px;
      }

      .rules-about-link {
        flex: 1 1 100%;
      }
    }

    @media (min-width: 901px) and (max-height: 760px) {
      .overlay.intro-details {
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
      }

      .overlay.intro-details .dialog {
        width: min(700px, 100%);
        max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
        padding: 12px;
        gap: 8px;
      }

      .overlay.intro-details .portrait-select {
        gap: 8px;
      }

      .overlay.intro-details .fighter-portrait {
        width: min(170px, 34vw);
        margin-bottom: 6px;
      }

      .overlay.intro-details .portrait-controls {
        padding: 0 44px;
      }

      .overlay.intro-details .portrait-arrow {
        width: 38px;
        height: 38px;
        min-height: 38px;
        font-size: 1.25rem;
        top: calc(50dvh - 162px);
      }

      .overlay.intro-details .portrait-controls .portrait-arrow:first-child {
        left: calc(50% - 337px);
      }

      .overlay.intro-details .portrait-controls .portrait-arrow:last-child {
        right: calc(50% - 337px);
      }

      .overlay.intro-details .portrait-card-controls .portrait-arrow,
      .overlay.intro-details .portrait-label-controls .portrait-arrow {
        position: static;
        top: auto;
        left: auto;
        right: auto;
        transform: none;
      }

      .overlay.intro-details .portrait-copy {
        gap: 3px;
      }

      .overlay.intro-details .portrait-copy > strong {
        font-size: 1rem;
      }

      .overlay.intro-details .portrait-copy span,
      .overlay.intro-details .portrait-copy small,
      .overlay.intro-details .portrait-story {
        font-size: 0.78rem;
        line-height: 1.32;
      }

      .overlay.intro-details .portrait-story {
        gap: 4px;
        margin-top: 4px;
      }

      .overlay.intro-details .portrait-moves {
        gap: 4px;
      }

      .overlay.intro-details .portrait-moves span {
        padding: 3px 6px;
        font-size: 0.72rem;
      }

      .intro-close-button {
        min-height: 38px;
      }
    }

    @media (max-width: 900px) {
      html,
      body {
        height: 100%;
        overflow: hidden;
      }

      body {
        height: 100dvh;
        min-height: 100dvh;
        padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
        place-items: stretch;
        overflow: hidden;
      }

      .app {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 4px;
        width: 100%;
        height: calc(100dvh - max(6px, env(safe-area-inset-top)) - max(6px, env(safe-area-inset-bottom)));
        min-height: 0;
        overflow: hidden;
      }

      .stage {
        min-height: 0;
        grid-template-rows: auto minmax(0, 1fr);
        gap: 4px;
        overflow: hidden;
      }

      .topbar {
        grid-template-columns: 1fr;
        min-height: 0;
        gap: 4px;
        padding: 6px;
      }

      .report-panel,
      .match-metrics {
        display: none;
      }

      .report-panel,
      .metrics {
        border-radius: 7px;
      }

      .report-panel {
        padding: 7px 8px;
      }

      h1 {
        font-size: clamp(1rem, 4.2vw, 1.28rem);
        line-height: 1;
      }

      .status {
        margin-top: 3px;
        font-size: 0.72rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .metrics {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        padding: 0;
        background: transparent;
        border: 0;
      }

      .player-status-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        padding: 0;
        background: transparent;
        border: 0;
      }

      .metric {
        min-width: 0;
        padding: 4px 3px;
      }

      .player-metric {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 1px;
        text-align: center;
      }

      .health-readout {
        gap: 2px;
      }

      .health-bar {
        height: 5px;
      }

      .player-speed {
        font-size: clamp(0.72rem, 3.1vw, 0.95rem);
      }

      .metric span {
        font-size: 0.56rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .metric strong {
        display: block;
        font-size: clamp(0.72rem, 3.1vw, 0.95rem);
        line-height: 1.05;
      }

      .side {
        min-height: 0;
        padding: 4px;
        border-radius: 8px;
        background: rgba(32, 38, 51, 0.72);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 12px 42px rgba(0, 0, 0, 0.26);
        backdrop-filter: blur(10px);
        display: grid;
        grid-template-rows: auto auto auto;
        gap: 3px;
        overflow: visible;
        position: relative;
        z-index: 40;
      }

      .side .section {
        margin-top: 0;
        padding: 3px;
        border: 0;
        border-radius: 7px;
        background: rgba(15, 23, 36, 0.22);
        box-shadow: none;
      }

      .side .section:nth-of-type(5) {
        display: none;
      }

      .canvas-wrap {
        min-height: 0;
        height: 100%;
      }

      canvas {
        min-height: 0;
        height: 100%;
      }

      .side .section:nth-of-type(1) {
        order: 1;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(42px, 0.62fr);
        gap: 4px;
        align-items: end;
      }

      .side .section:nth-of-type(1) h2,
      .side .section:nth-of-type(2) h2 {
        display: none;
      }

      .side .section:nth-of-type(1) .field {
        gap: 2px;
      }

      .side .section:nth-of-type(1) .field + .field {
        margin-top: 0;
      }

      .side .section:nth-of-type(1) label {
        font-size: 0.58rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .side .section:nth-of-type(1) input,
      .side .section:nth-of-type(1) select,
      .side .section:nth-of-type(1) button {
        min-height: 32px;
        padding: 4px 5px;
        font-size: 0.78rem;
      }

      #resetBestTimeButton {
        font-size: 0;
        padding: 0;
      }

      #resetBestTimeButton::before {
        content: "Reset";
        font-size: 0.66rem;
      }

      .side .settings-section {
        display: grid;
        grid-template-columns: 1fr;
        justify-items: end;
        align-items: start;
        overflow: visible;
        position: relative;
        z-index: var(--z-settings-tools);
      }

      .side .section.settings-section {
        grid-template-columns: 1fr;
      }

      .side .settings-section .settings-actions {
        display: grid;
        grid-template-columns: repeat(4, minmax(34px, 1fr));
        gap: 4px;
        justify-self: stretch;
        width: 100%;
        max-width: 100%;
        align-items: stretch;
      }

      .side .settings-section .surrender-button,
      .side .settings-section .rules-toggle,
      .side .settings-section .gm-toggle,
      .side .settings-section .replay-toggle,
      .side .settings-section .settings-toggle {
        width: 100%;
        min-width: 0;
        min-height: 34px;
        padding: 0;
        display: inline-grid;
        place-items: center;
      }

      .side .settings-section.open {
        z-index: var(--z-settings-open);
      }

      .side .settings-section .settings-toggle {
        min-height: 34px;
        padding: 0;
      }

      .side .settings-section .settings-actions button {
        min-height: 34px;
        padding: 0;
        font-size: 0;
      }

      .side .settings-section .settings-action-icon {
        display: block;
      }

      .side .settings-section .gm-letter {
        display: block;
        font-size: 1.08rem;
      }

      .side .settings-section .settings-action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
      }

      .side .settings-section .settings-content {
        position: fixed;
        inset: 0;
        z-index: var(--z-settings-modal);
        display: grid;
        place-items: center;
        width: auto;
        max-height: none;
        overflow: hidden;
        padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
        border-radius: 0;
        background: rgba(7, 10, 16, 0.78);
        border: 0;
        box-shadow: none;
        transform: none;
      }

      .side .settings-section .settings-content[hidden] {
        display: none;
      }

      .side .settings-section .settings-dialog {
        width: min(760px, 100%);
        max-height: min(86dvh, 760px);
      }

      .side .settings-section .settings-modal-body {
        padding: 16px;
      }

      .side .settings-section .settings-panel-header {
        margin: 0;
      }

      .side .settings-section .settings-quick-row {
        position: static;
        margin: 0;
        padding: 0;
        background: transparent;
      }

      .side .settings-section .gm-settings {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .side .settings-section .character-picks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }

      .side .settings-section .keybind-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
      }

      .side .settings-section .settings-direction-bindings {
        padding: 6px 8px;
      }

      .side .settings-section .settings-dir-pad {
        width: min(100px, 31vw);
      }

      .side .settings-section .field {
        gap: 5px;
      }

      .side .settings-section .field + .field {
        margin-top: 0;
      }

      .side .settings-section label {
        font-size: 0.72rem;
      }

      .side .settings-section input,
      .side .settings-section select,
      .side .settings-section button.secondary {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 0.82rem;
      }

      .side .settings-section .settings-toggle-control {
        min-height: 33px;
        height: 33px;
        padding: 6px 8px;
      }

      .side .settings-section .settings-toggle-control input {
        width: 18px;
        height: 18px;
        min-height: 18px;
        padding: 0;
      }

      .side .settings-section #resetBestTimeButton {
        font-size: 0.78rem;
        padding: 6px 8px;
      }

      .side .settings-section #resetBestTimeButton::before {
        content: none;
      }

      .side .section:nth-of-type(2) {
        order: 2;
      }

      .resource-board {
        grid-template-columns: 1fr 1fr;
        gap: 4px;
      }

      .character-stage {
        top: 6px;
        left: 6px;
        right: 6px;
        gap: 6px;
      }

      .fighter-card {
        grid-template-columns: 42px;
        gap: 0;
        padding: 5px;
      }

      .attack-callout {
        max-width: min(170px, 42vw);
        padding: 5px 8px;
        font-size: 0.68rem;
      }

      .fighter-module {
        width: 42px;
      }

      .dialog {
        max-height: min(88dvh, calc(100% - 12px));
        padding: 14px;
      }

      .fighter-portrait {
        width: min(150px, 46vw);
        margin-bottom: 8px;
      }

      .resource-panel {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 3px;
        min-width: 0;
        padding: 4px;
      }

      .resource-title {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        grid-column: 1 / -1;
        padding-bottom: 4px;
        font-size: 0.68rem;
        gap: 4px;
      }

      .resource-owner {
        white-space: nowrap;
      }

      .resource-counters {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        gap: 4px;
      }

      .resource-chip {
        grid-template-columns: 13px minmax(0, 1fr);
        grid-template-rows: 19px;
        min-width: 0;
        min-height: 19px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        gap: 3px;
        color: color-mix(in srgb, var(--resource-chip-line), var(--resource-chip-color) 22%);
        font-size: 0.66rem;
        box-shadow: none;
      }

      .resource-chip-track {
        grid-column: 2;
        grid-row: 1;
        align-self: stretch;
        width: 100%;
        height: 100%;
        border-radius: 6px;
        border: 1px solid var(--resource-chip-line);
        background:
          linear-gradient(90deg, color-mix(in srgb, var(--resource-chip-color), transparent 72%), rgba(21, 27, 37, 0.78)),
          var(--resource-chip-color);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
      }

      .resource-chip-track::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background:
          repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent calc(16.666% - 1px),
            rgba(15, 23, 36, 0.66) calc(16.666% - 1px),
            rgba(15, 23, 36, 0.66) 16.666%
          );
        pointer-events: none;
      }

      .resource-chip[data-resource="bomb"] .resource-chip-track::after {
        background:
          repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent calc(33.333% - 1px),
            rgba(15, 23, 36, 0.66) calc(33.333% - 1px),
            rgba(15, 23, 36, 0.66) 33.333%
          );
      }

      .resource-chip-fill {
        background: linear-gradient(90deg, var(--resource-chip-color), var(--resource-chip-line));
        opacity: 0.48;
      }

      .resource-chip-value {
        grid-column: 2;
        grid-row: 1;
        z-index: 1;
        place-self: center;
        min-width: 0;
        color: color-mix(in srgb, var(--resource-chip-line), var(--resource-chip-color) 22%);
        line-height: 1;
        text-align: center;
        text-shadow: 0 0 10px color-mix(in srgb, var(--resource-chip-color), transparent 56%);
      }

      .resource-icon {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
        justify-self: center;
        width: 12px;
        height: 12px;
      }

      .resource-row {
        position: relative;
        display: grid;
        grid-template-columns: 1fr;
        place-items: center;
        min-height: 19px;
        border-radius: 6px;
        border: 1px solid var(--food-line);
        background: var(--food-color);
        color: #111720;
        font-size: 0.76rem;
        font-weight: 900;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
        overflow: hidden;
      }

      .resource-row > span:first-child {
        display: none;
      }

      .resource-track {
        position: absolute;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: inherit;
        opacity: 0.46;
      }

      .resource-row [data-count] {
        position: relative;
        z-index: 1;
        display: block;
        line-height: 1;
      }

      .side .section:nth-of-type(3) {
        order: 3;
        padding: 2px 3px;
      }

      .side .section:nth-of-type(3) h2 {
        display: none;
      }

      .control-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
      }

      .control-card {
        width: 100%;
        gap: 2px;
        font-size: 0.68rem;
      }

      .action-panel {
        min-height: 108px;
      }

      .attack-actions {
        width: 108px;
        height: 108px;
      }

      .attack-actions .attack-button,
      .attack-actions .attack-button.secondary {
        width: 34px;
        height: 34px;
        font-size: 0.6rem;
      }

      .joystick {
        width: clamp(82px, 21dvh, 112px);
        min-width: 0;
        border: 2px solid rgba(243, 245, 247, 0.42);
        opacity: 0.8;
      }

      .stick {
        width: clamp(30px, 7.5dvh, 42px);
        min-width: 0;
        border: 2px solid rgba(255, 255, 255, 0.58);
      }

      .overlay {
        padding: 10px;
      }

      .dialog {
        padding: 14px;
      }

      .overlay.intro-details {
        padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
      }

      .overlay.intro-details .dialog {
        width: 100%;
        height: 100%;
        max-height: 100%;
        padding: 12px;
        gap: 8px;
      }

      .dialog h2 {
        font-size: 1.18rem;
      }

      .dialog p {
        margin-bottom: 10px;
        font-size: 0.82rem;
        line-height: 1.25;
      }

      .dialog-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
      }

      .dialog-actions button {
        min-height: 36px;
        padding: 7px 5px;
        font-size: clamp(0.68rem, 2.9vw, 0.82rem);
      }

      .overlay.is-session-modal {
        align-items: start;
      }

      .overlay.is-session-modal .dialog {
        width: min(100%, 420px);
        height: min(100%, calc(100% - 12px));
        max-height: calc(100% - 12px);
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 8px;
        align-content: stretch;
        overflow: hidden;
      }

      .overlay.logo-transition.is-session-modal .dialog {
        display: block;
        height: auto;
        max-height: calc(100% - 12px);
        overflow: visible;
      }

      .overlay.logo-transition.is-session-modal {
        align-items: center;
      }

      .overlay.logo-transition.is-session-modal .logo-transition-card {
        gap: 10px;
      }

      .overlay.logo-transition.is-session-modal .logo-countdown {
        font-size: clamp(2.1rem, min(8vw, 10dvh), 4.2rem);
      }

      .overlay.logo-transition.is-session-modal .logo-transition-message {
        font-size: clamp(1rem, 3.6vw, 1.32rem);
      }

      .overlay.is-session-modal .dialog:has(.intro-avatar-gate) {
        height: auto;
        grid-template-rows: auto auto;
        align-content: start;
      }

      .overlay.is-session-modal #winnerPortrait {
        min-height: 0;
        overflow: hidden;
      }

      .overlay.logo-transition.is-session-modal #winnerPortrait {
        min-height: 0;
        overflow: visible;
      }

      .overlay.is-session-modal #winnerPortrait:has(.intro-avatar-gate),
      .overlay.is-session-modal #winnerPortrait:has(.portrait-pair) {
        margin-bottom: 0;
        display: grid;
        grid-template-rows: minmax(0, 1fr);
        gap: 0;
      }

      .overlay.is-session-modal .intro-avatar-gate,
      .overlay.is-session-modal .portrait-pair {
        min-height: 0;
        gap: 8px;
        align-items: start;
        margin-bottom: 0;
      }

      .overlay.is-session-modal .result-pair {
        margin-bottom: 14px;
      }

      .overlay.is-session-modal .dialog:has(.result-pair) h2 {
        margin-bottom: 2px;
        font-size: 1.08rem;
        line-height: 1.12;
      }

      .overlay.is-session-modal .dialog:has(.result-pair) p {
        margin-bottom: 8px;
        font-size: 0.76rem;
        line-height: 1.18;
      }

      .overlay.is-session-modal .intro-avatar-button {
        min-height: 0;
        gap: 4px;
      }

      .overlay.is-session-modal .intro-avatar-button .fighter-portrait,
      .overlay.is-session-modal .portrait-pair .fighter-portrait {
        width: min(100%, 22dvh);
        justify-self: center;
      }

      .overlay.is-session-modal .result-entry {
        gap: 5px;
        min-width: 0;
      }

      .overlay.is-session-modal .result-quote {
        min-height: 2.78em;
        padding: 6px 7px;
        font-size: 0.72rem;
        line-height: 1.2;
      }

      .overlay.is-session-modal .intro-avatar-label-controls {
        margin-top: 2px;
      }

      .overlay.is-session-modal .intro-avatar-label {
        font-size: 0.66rem;
      }

      .overlay.is-session-modal .intro-avatar-motto {
        font-size: 0.62rem;
        line-height: 1.22;
      }

      .overlay.is-session-modal .intro-avatar-logo {
        width: clamp(28px, 7vw, 38px);
      }

      .tutorial-visual {
        min-height: 0;
      }

      .tutorial-visual.is-capture {
        --tutorial-control-size: min(128px, 34vw);
        grid-template-columns: minmax(0, 1fr) var(--tutorial-control-size);
        grid-template-rows: var(--tutorial-control-size);
        grid-auto-rows: var(--tutorial-control-size);
        width: 100%;
        height: var(--tutorial-control-size);
        max-height: none;
        gap: 8px;
      }

      .tutorial-visual.is-capture.is-move {
        grid-template-columns: var(--tutorial-control-size) minmax(0, 1fr);
        grid-template-rows: var(--tutorial-control-size);
      }

      .tutorial-capture-stage {
        width: 100%;
        max-width: 560px;
        max-height: none;
        justify-self: center;
      }

      .tutorial-capture-stage img {
        max-height: calc(100dvh - 250px);
      }

      .tutorial-ui-snapshot {
        width: min(100%, 420px);
        justify-self: center;
      }

      .tutorial-ui-snapshot.is-joystick,
      .tutorial-ui-snapshot.is-skills {
        width: 100%;
        max-width: var(--tutorial-control-size);
      }

      .tutorial-visual.is-move .tutorial-capture-stage {
        order: 1;
      }

      .tutorial-visual.is-small .tutorial-capture-stage {
        order: 0;
      }

      .tutorial-snapshot-frame {
        padding: 8px;
      }

      .tutorial-ui-snapshot .resource-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .tutorial-ui-snapshot .resource-panel {
        padding: 7px;
      }

      .tutorial-ui-snapshot .resource-title {
        grid-template-columns: 1fr;
        gap: 5px;
        font-size: 0.68rem;
      }

      .tutorial-ui-snapshot .resource-chip {
        font-size: 0.62rem;
      }

      .tutorial-ui-snapshot .resource-row {
        grid-template-columns: 34px minmax(0, 1fr) 18px;
        gap: 4px;
        font-size: 0.66rem;
      }

      .tutorial-visual.is-resource-guide {
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
      }

      .tutorial-resource-guide {
        gap: 8px;
      }

      .tutorial-resource-guide-panel {
        padding: 10px 12px;
      }

      .tutorial-resource-guide-panel span {
        font-size: 0.84rem;
      }

      .tutorial-copy {
        padding: 10px 12px;
        line-height: 1.32;
      }

      .overlay.tutorial-open #winnerPortrait {
        width: 100%;
        height: 100%;
        min-height: 0;
      }

      .tutorial-card {
        --tutorial-mobile-actions-height: 36px;
        --tutorial-mobile-actions-gap: 6px;
        grid-template-rows: auto auto auto minmax(0, 1fr);
        width: 100%;
        height: 100%;
        position: relative;
        padding-bottom: calc(var(--tutorial-mobile-actions-height) + var(--tutorial-mobile-actions-gap) + 2px);
      }

      .tutorial-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--tutorial-mobile-actions-gap);
        position: absolute;
        left: 50%;
        right: auto;
        bottom: 0;
        z-index: 6;
        width: min(620px, 100%);
        height: var(--tutorial-mobile-actions-height);
        transform: translateX(-50%);
      }

      .tutorial-resource-flow {
        grid-template-columns: 1fr;
      }

      .tutorial-actions button {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: var(--tutorial-mobile-actions-height);
        padding-inline: 8px;
        white-space: normal;
      }

      button {
        min-height: 36px;
        padding: 7px 12px;
      }

      .intro-avatar-button {
        width: 100%;
      }

      .intro-avatar-label,
      .portrait-option-label {
        font-size: 0.68rem;
      }

      .intro-avatar-motto {
        font-size: 0.64rem;
        line-height: 1.22;
      }

      .intro-avatar-logo {
        width: clamp(28px, 7vw, 40px);
      }

      .overlay.intro-details .portrait-pair {
        gap: 14px;
      }

      .overlay.intro-details .portrait-option .fighter-portrait {
        transform: scale(0.99);
      }

      .overlay.intro-details .fighter-portrait {
        width: 100%;
        aspect-ratio: 0.78;
        margin-bottom: 5px;
      }

      .overlay.intro-details .fighter-portrait .fighter-avatar-image,
      .overlay.intro-details .fighter-portrait .fighter-avatar {
        width: 100%;
        height: 100%;
      }

      .overlay.intro-details .portrait-label-controls {
        grid-template-columns: 24px minmax(0, max-content) 24px;
        gap: 3px;
      }

      .overlay.intro-details .portrait-controls {
        padding: 0 39px;
      }

      .overlay.intro-details .portrait-arrow {
        width: 24px;
        height: 24px;
        min-height: 24px;
        border-radius: 5px;
        font-size: 0.96rem;
        top: 49px;
      }

      .overlay.intro-details .portrait-copy {
        gap: 3px;
      }

      .overlay.intro-details .portrait-copy > strong {
        font-size: 0.98rem;
      }

      .overlay.intro-details .portrait-copy span,
      .overlay.intro-details .portrait-copy small,
      .overlay.intro-details .portrait-story {
        font-size: 0.72rem;
        line-height: 1.32;
      }

      .overlay.intro-details .portrait-story {
        gap: 4px;
        margin-top: 4px;
      }

      .overlay.intro-details .portrait-moves {
        gap: 4px;
      }

      .overlay.intro-details .portrait-moves span {
        padding: 2px 5px;
        font-size: 0.66rem;
      }

      .intro-close-button {
        min-height: 34px;
        min-width: 96px;
        padding: 6px 10px;
      }

      .portrait-lightbox {
        gap: 8px;
        padding:
          calc(max(8px, env(safe-area-inset-top)) + 44px)
          max(8px, env(safe-area-inset-right))
          calc(max(8px, env(safe-area-inset-bottom)) + 50px)
          max(8px, env(safe-area-inset-left));
      }

      .portrait-lightbox-figure {
        width: 100%;
      }

      .portrait-lightbox-caption {
        font-size: 0.92rem;
      }
    }

    @media (max-width: 620px) {
      .tutorial-visual.is-capture,
      .tutorial-visual.is-capture.is-move {
        --tutorial-control-size: min(148px, 38vw);
        align-content: center;
        gap: 8px;
      }

      .tutorial-visual.is-capture {
        grid-template-columns: minmax(0, 1fr) var(--tutorial-control-size);
        grid-template-rows: var(--tutorial-control-size);
        grid-auto-rows: var(--tutorial-control-size);
        height: var(--tutorial-control-size);
      }

      .tutorial-visual.is-capture.is-move {
        grid-template-columns: var(--tutorial-control-size) minmax(0, 1fr);
        grid-template-rows: var(--tutorial-control-size);
        grid-auto-rows: var(--tutorial-control-size);
      }

      .tutorial-visual.is-capture .tutorial-capture-stage,
      .tutorial-visual.is-move .tutorial-capture-stage,
      .tutorial-visual.is-small .tutorial-capture-stage {
        order: initial;
      }

      .tutorial-visual.is-capture .tutorial-ui-snapshot {
        order: initial;
      }

      .tutorial-capture-stage {
        height: var(--tutorial-control-size);
      }

      .tutorial-capture-stage img {
        max-height: 100%;
      }

      .tutorial-ui-snapshot.is-joystick,
      .tutorial-ui-snapshot.is-skills {
        width: 100%;
        max-width: var(--tutorial-control-size);
        height: var(--tutorial-control-size);
      }

      .tutorial-ui-snapshot.is-joystick .tutorial-snapshot-frame,
      .tutorial-ui-snapshot.is-skills .tutorial-snapshot-frame {
        padding: 0;
      }

      .tutorial-ui-snapshot.is-skills .attack-actions {
        transform: translateY(-3px);
      }

      .tutorial-ui-snapshot .joystick-zone,
      .tutorial-ui-snapshot .attack-actions,
      .tutorial-ui-snapshot .joystick {
        width: 88px;
      }

      .tutorial-ui-snapshot .attack-actions {
        height: 88px;
      }

      .tutorial-ui-snapshot .attack-actions .attack-button,
      .tutorial-ui-snapshot .attack-actions .attack-button.secondary {
        width: 30px;
        height: 30px;
        min-height: 30px;
        font-size: 0.56rem;
      }

      .tutorial-resource-guide-panel {
        padding: 8px 10px;
      }

      .tutorial-resource-guide-panel strong {
        font-size: 0.86rem;
      }

      .tutorial-resource-guide-panel span {
        font-size: 0.74rem;
        line-height: 1.28;
      }

      .tutorial-food-detail-list {
        gap: 4px;
      }

      .tutorial-food-detail-list li {
        gap: 6px;
      }

      .tutorial-food-detail-list span {
        font-size: 0.74rem;
        line-height: 1.28;
      }

      .tutorial-copy {
        gap: 5px;
        padding: 8px 10px;
        font-size: 0.82rem;
      }

      .tutorial-copy > strong {
        font-size: 0.98rem;
      }

      .tutorial-lead,
      .tutorial-line,
      .tutorial-line span,
      .tutorial-line small {
        font-size: 0.74rem;
        line-height: 1.28;
      }

      .tutorial-line {
        gap: 1px;
        padding-left: 14px;
      }

      .tutorial-line::before {
        width: 5px;
        height: 5px;
      }

      .tutorial-line b {
        font-size: 0.76rem;
      }

      .tutorial-note {
        font-size: 0.72rem;
        line-height: 1.28;
        padding-top: 5px;
      }

      .tutorial-actions {
        gap: 6px;
      }
    }

    @media (max-width: 900px) and (max-height: 720px) {
      .topbar {
        padding: 6px;
      }

      .status {
        display: none;
      }

      .metrics {
        grid-template-columns: minmax(0, 1fr);
      }

      .metric:nth-child(n + 5) {
        display: none;
      }

      .joystick {
        width: clamp(76px, 19dvh, 104px);
      }

      .stick {
        width: clamp(32px, 8dvh, 46px);
      }

      .overlay.intro-details .fighter-portrait {
        width: 100%;
        aspect-ratio: 0.78;
      }

      .overlay.intro-details .fighter-portrait .fighter-avatar-image,
      .overlay.intro-details .fighter-portrait .fighter-avatar {
        width: 100%;
        height: 100%;
      }

      .overlay.intro-details .portrait-copy span,
      .overlay.intro-details .portrait-copy small,
      .overlay.intro-details .portrait-story {
        font-size: 0.68rem;
        line-height: 1.24;
      }
    }
