/* ==========================================================================
   Material Design 3 (M3) Design System — 下関ファイターズ Web UI
   シードカラー: 関門海峡ディープオーシャン (#006494) + 黄金ウニアクセント (#F5BE48)
   ========================================================================== */

:root {
  /* M3 Typography */
  --md-ref-typeface-brand: "Plus Jakarta Sans", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --md-ref-typeface-plain: "Noto Sans JP", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --md-ref-typeface-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* M3 Shape Scale */
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* M3 Motion (Emphasized) */
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-duration-short: 150ms;
  --md-sys-motion-duration-medium: 250ms;
}

/* Material 3 Dark Theme Tokens (純黒を避けたトーナル・サーフェス階層) */
:root[data-theme="dark"] {
  color-scheme: dark;

  --md-sys-color-primary: #8accff;
  --md-sys-color-on-primary: #003351;
  --md-sys-color-primary-container: #004b73;
  --md-sys-color-on-primary-container: #c9e6ff;

  --md-sys-color-secondary: #b7c9d9;
  --md-sys-color-on-secondary: #22323f;
  --md-sys-color-secondary-container: #384956;
  --md-sys-color-on-secondary-container: #d3e5f5;

  --md-sys-color-tertiary: #f5be48;
  --md-sys-color-on-tertiary: #402d00;
  --md-sys-color-tertiary-container: #5c4300;
  --md-sys-color-on-tertiary-container: #ffdf9e;

  --md-sys-color-error: #ffb4ab;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;

  --md-sys-color-surface: #0f1419;
  --md-sys-color-surface-dim: #0f1419;
  --md-sys-color-surface-container-lowest: #0a0f14;
  --md-sys-color-surface-container-low: #171c22;
  --md-sys-color-surface-container: #1b2026;
  --md-sys-color-surface-container-high: #252b31;
  --md-sys-color-surface-container-highest: #30363c;

  --md-sys-color-on-surface: #dfe3e8;
  --md-sys-color-on-surface-variant: #c1c7ce;
  --md-sys-color-outline: #8b9198;
  --md-sys-color-outline-variant: #41474d;
  --md-sys-color-scrim: rgba(0, 0, 0, 0.64);

  /* Player semantic badges (harmonized to M3 dark) */
  --p1-container: #5c1927;
  --p1-on-container: #ffd9de;
  --p2-container: #004775;
  --p2-on-container: #cce5ff;

  --md-sys-elevation-1: 0 1px 3px 1px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.36);
  --md-sys-elevation-2: 0 2px 6px 2px rgba(0, 0, 0, 0.32), 0 1px 2px rgba(0, 0, 0, 0.4);
  --md-sys-elevation-3: 0 6px 18px 4px rgba(0, 0, 0, 0.42), 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Material 3 Light Theme Tokens */
:root[data-theme="light"] {
  color-scheme: light;

  --md-sys-color-primary: #006494;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #c9e6ff;
  --md-sys-color-on-primary-container: #001e31;

  --md-sys-color-secondary: #50606f;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #d3e5f5;
  --md-sys-color-on-secondary-container: #0c1d29;

  --md-sys-color-tertiary: #795900;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #ffdf9e;
  --md-sys-color-on-tertiary-container: #261900;

  --md-sys-color-error: #ba1a1a;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;

  --md-sys-color-surface: #f7f9ff;
  --md-sys-color-surface-dim: #d7dae0;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f1f4fa;
  --md-sys-color-surface-container: #ebeef4;
  --md-sys-color-surface-container-high: #e5e8ee;
  --md-sys-color-surface-container-highest: #dfe3e8;

  --md-sys-color-on-surface: #171c22;
  --md-sys-color-on-surface-variant: #41474d;
  --md-sys-color-outline: #72787e;
  --md-sys-color-outline-variant: #c1c7ce;
  --md-sys-color-scrim: rgba(15, 20, 25, 0.45);

  --p1-container: #ffd9de;
  --p1-on-container: #400011;
  --p2-container: #cce5ff;
  --p2-on-container: #001e36;

  --md-sys-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.08), 0 1px 3px 1px rgba(0, 0, 0, 0.06);
  --md-sys-elevation-2: 0 2px 6px 2px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.1);
  --md-sys-elevation-3: 0 8px 24px 4px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-plain);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(12px, 2vw, 24px);
}

/* App Shell */
.app-shell {
  width: min(1160px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   M3 Top App Bar
   ========================================================================== */
.top-app-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 20px;
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-1);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: grid;
  place-items: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-heading-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-heading-row h1 {
  margin: 0;
  font-family: var(--md-ref-typeface-brand);
  font-size: clamp(18px, 2vw, 22px); /* M3 Title Large */
  line-height: 1.27;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--md-sys-color-on-surface);
}

.m3-assist-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--md-sys-shape-corner-small);
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  font-family: var(--md-ref-typeface-brand);
  font-size: 11px; /* M3 Label Small */
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-subtitle {
  margin: 0;
  font-size: 12px; /* M3 Body Small */
  color: var(--md-sys-color-on-surface-variant);
}

.app-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   M3 Buttons (40dp height, Full Pill Shape, State Layers, Focus Rings)
   ========================================================================== */
.m3-btn,
.m3-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-ref-typeface-plain);
  font-size: 13px; /* M3 Label Large */
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  transition:
    background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
    color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
    box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.m3-btn {
  padding: 0 18px;
}

.m3-icon-btn {
  width: 40px;
  padding: 0;
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
}

/* M3 State Layer overlay */
.m3-btn::after,
.m3-icon-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.m3-btn:hover::after,
.m3-icon-btn:hover::after {
  opacity: 0.08;
}

.m3-btn:active::after,
.m3-icon-btn:active::after {
  opacity: 0.14;
}

.m3-btn:focus-visible,
.m3-icon-btn:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.m3-icon {
  flex-shrink: 0;
}

/* Filled Button (Primary CTA) */
.m3-btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.m3-btn-filled:hover {
  box-shadow: var(--md-sys-elevation-1);
}

/* Filled Tonal Button (Toggleable / Secondary action) */
.m3-btn-tonal {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3-btn-tonal.is-active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* Outlined Button */
.m3-btn-outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

/* ==========================================================================
   Main Stage Card (ゲーム画面を引き立てるミニマルなM3コンテナ)
   ========================================================================== */
.stage-card {
  padding: 12px;
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 22px;
  box-shadow: var(--md-sys-elevation-2);
}

.screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000000;
  border-radius: 14px;
  overflow: hidden;
}

.screen-wrap:fullscreen {
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000000;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  cursor: pointer;
}

.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.18) 0px,
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(circle at center, transparent 62%, rgba(0, 0, 0, 0.32) 100%);
}

.screen-wrap.crt-on .crt-overlay {
  opacity: 1;
}

/* ==========================================================================
   M3 Bento Control Cards (1P / 2P キーガイド)
   ========================================================================== */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 820px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
}

.control-card {
  padding: 16px 18px;
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-ref-typeface-brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.player-pill.p1 {
  background-color: var(--p1-container);
  color: var(--p1-on-container);
}

.player-pill.p2 {
  background-color: var(--p2-container);
  color: var(--p2-on-container);
}

.control-card-hint {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.key-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--md-sys-shape-corner-small);
  background-color: var(--md-sys-color-surface-container-low);
}

.key-item.is-accent {
  background-color: var(--md-sys-color-surface-container-high);
}

.key-item.is-super {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}

.key-item.is-super .key-desc {
  color: var(--md-sys-color-on-tertiary-container);
  font-weight: 600;
}

.keys {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.key-desc {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  font-family: var(--md-ref-typeface-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-bottom-width: 2px;
  border-radius: 6px;
}

/* System Hint Bar */
.system-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 10px 18px;
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.system-bar-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
}

code {
  font-family: var(--md-ref-typeface-mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-primary);
}

/* ==========================================================================
   Material 3 Dialog (28dp corner radius, Surface Container High, 24dp padding)
   ========================================================================== */
.m3-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: min(88vh, 840px);
  padding: 0;
  border: none;
  border-radius: var(--md-sys-shape-corner-extra-large); /* 28dp */
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-3);
  overflow: hidden;
  opacity: 1;
  transform: scale(1);
  transition:
    opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

@starting-style {
  .m3-dialog[open] {
    opacity: 0;
    transform: scale(0.95);
  }
}

.m3-dialog::backdrop {
  background-color: var(--md-sys-color-scrim);
  backdrop-filter: blur(4px);
}

.m3-dialog-surface {
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 840px);
}

.m3-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 16px;
}

.m3-dialog-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.m3-dialog-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: grid;
  place-items: center;
}

.m3-dialog-header h2 {
  margin: 0;
  font-family: var(--md-ref-typeface-brand);
  font-size: 22px; /* M3 Headline Small */
  line-height: 1.3;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.m3-dialog-supporting {
  margin: 4px 0 0;
  font-size: 13px; /* M3 Body Medium */
  color: var(--md-sys-color-on-surface-variant);
}

.m3-divider {
  height: 1px;
  background-color: var(--md-sys-color-outline-variant);
  flex-shrink: 0;
}

.m3-dialog-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dialog-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  margin: 0;
  font-family: var(--md-ref-typeface-brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
}

.system-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.rule-tile {
  padding: 14px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.rule-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 6px;
}

.rule-tile p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant);
}

/* Fighter Move Cards inside Dialog */
.moves-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.move-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.move-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.move-card-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.move-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.move-card-seafood {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}

.move-card-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.move-card-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--md-sys-color-on-surface-variant);
}

.move-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.move-list li {
  padding: 8px 10px;
  border-radius: var(--md-sys-shape-corner-small);
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-size: 12px;
  line-height: 1.45;
  color: var(--md-sys-color-on-surface-variant);
}

.move-list li.super {
  background-color: var(--md-sys-color-tertiary-container);
  border-color: transparent;
  color: var(--md-sys-color-on-tertiary-container);
}

.move-list-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.move-list strong {
  color: var(--md-sys-color-on-surface);
  font-size: 12px;
}

.move-list li.super strong {
  color: var(--md-sys-color-on-tertiary-container);
}

.move-cmd {
  font-family: var(--md-ref-typeface-mono);
  font-size: 10px;
  opacity: 0.85;
}

.m3-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
}

/* ==========================================================================
   M3 Touch Gamepad (ゲーム画面上への半透明オーバーレイ ＆ 縦持ち自動下配置)
   ========================================================================== */
.stage-viewport {
  position: relative;
  width: 100%;
}

.stage-viewport:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000000;
}

.stage-viewport:fullscreen .screen-wrap {
  border-radius: 0;
  max-height: 100vh;
}

/* 横画面・PC・タブレット・フルスクリーン：ゲーム画面の左右下へ半透明オーバーレイ！ */
.touch-gamepad {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 12;
  padding: 12px 16px 14px;
  pointer-events: none;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.pad-pause-pill {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: rgba(12, 18, 36, 0.65);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.72;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 80ms ease, opacity 100ms ease;
}

.pad-pause-pill:active,
.pad-pause-pill.is-pressed {
  transform: scale(0.9);
  opacity: 1;
}

.touch-gamepad .pad-left {
  grid-column: 1;
  pointer-events: auto;
  opacity: 0.34;
  transition: opacity 150ms ease;
}

.touch-gamepad .pad-right {
  grid-column: 3;
  pointer-events: auto;
  opacity: 0.56;
  transition: opacity 150ms ease;
}

.touch-gamepad .pad-left:active,
.touch-gamepad .pad-left:has(.is-active) {
  opacity: 0.78;
}

.touch-gamepad .pad-right:active,
.touch-gamepad .pad-right:has(.is-pressed) {
  opacity: 0.94;
}

/* サムアーク（親指の扇状軌道）超クリア・シースルー＆コンパクト設計（画面を極力隠さない！） */
.arc-cluster {
  position: relative;
  width: 226px;
  height: 196px;
  transform: scale(0.88);
  transform-origin: bottom right;
  pointer-events: none;
}

.arc-ico-slot {
  display: grid;
  place-items: center;
  pointer-events: none;
}

.arc-btn {
  position: absolute;
  appearance: none;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #ffffff;
  font-family: var(--md-ref-typeface-plain);
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform 65ms ease, filter 75ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.arc-btn:active,
.arc-btn.is-pressed {
  transform: scale(0.9);
  filter: brightness(1.32);
}

.arc-ico {
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.85));
}

.arc-lbl {
  position: absolute;
  bottom: 4px;
  font-size: 8.5px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.98), 0 0 5px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  pointer-events: none;
}

/* 六角形ヘキサゴン・シースルーメタリック（背景がしっかり透ける！） */
.arc-hex {
  border: 0;
  clip-path: polygon(50% 2%, 95% 26%, 95% 74%, 50% 98%, 5% 74%, 5% 26%);
  background: linear-gradient(155deg, rgba(36, 48, 76, 0.42) 0%, rgba(10, 15, 28, 0.48) 100%);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.42));
}

.arc-hex::before {
  content: '';
  position: absolute;
  inset: 2px;
  clip-path: polygon(50% 2%, 95% 26%, 95% 74%, 50% 98%, 5% 74%, 5% 26%);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.01) 42%, rgba(0, 0, 0, 0.14) 100%);
  pointer-events: none;
}

.arc-hex::after {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 2%, 95% 26%, 95% 74%, 50% 98%, 5% 74%, 5% 26%, 50% 2%, 50% 6%, 9% 28%, 9% 72%, 50% 94%, 91% 72%, 91% 28%, 50% 6%);
  background: linear-gradient(155deg, rgba(235, 245, 255, 0.78), rgba(140, 180, 235, 0.35), rgba(255, 255, 255, 0.65));
  pointer-events: none;
}

/* 円形シースルーエンブレム（背景を薄く透かしてドット絵を見やすく！） */
.arc-emblem {
  border-radius: 50%;
  background: radial-gradient(circle at 32% 24%, rgba(26, 36, 58, 0.44) 0%, rgba(8, 12, 24, 0.50) 75%, rgba(4, 6, 14, 0.58) 100%);
  border: 1.5px solid rgba(220, 234, 255, 0.55);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.08);
}

.arc-emblem .arc-ico {
  transform: translateY(-3px);
}

/* ① 特大メイン攻撃ボタン */
.arc-atk {
  right: 6px;
  bottom: 0;
  width: 82px;
  height: 82px;
  background: linear-gradient(155deg, rgba(38, 66, 118, 0.50) 0%, rgba(12, 22, 46, 0.56) 100%);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.48));
}

.arc-atk .arc-ico {
  transform: translateY(-4px);
}

.arc-atk .arc-lbl {
  bottom: 8px;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: #dff0ff;
}

/* ② ガード（蒼銀リング） */
.arc-guard {
  right: 98px;
  bottom: 4px;
  width: 54px;
  height: 54px;
  border-color: rgba(112, 224, 255, 0.68);
}

/* ③ 必殺技1（エメラルドリング） */
.arc-sp1 {
  right: 152px;
  bottom: 44px;
  width: 56px;
  height: 56px;
  border-color: rgba(102, 255, 186, 0.72);
}

/* ④ 必殺技2（紅蓮リング） */
.arc-sp2 {
  right: 120px;
  bottom: 102px;
  width: 56px;
  height: 56px;
  border-color: rgba(255, 134, 118, 0.75);
}

/* ⑤ 超必殺技（普段は極薄ステルス・MAX時だけ黄金覚醒！） */
.arc-super {
  right: 60px;
  bottom: 130px;
  width: 58px;
  height: 58px;
  border-color: rgba(255, 210, 96, 0.36);
  opacity: 0.52;
}

.arc-super.is-ready {
  opacity: 1;
  background: radial-gradient(circle at 32% 24%, rgba(135, 82, 12, 0.82) 0%, rgba(44, 22, 6, 0.86) 100%);
  border: 2px solid #ffe47a;
  box-shadow: 0 0 20px rgba(255, 200, 48, 0.92), inset 0 0 12px rgba(255, 190, 40, 0.45);
  animation: super-pulse 0.85s ease-in-out infinite alternate;
}

.arc-super.is-ready .arc-lbl {
  color: #fff2a8;
}

@keyframes super-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

/* ⑥ 投げ（六角・アメジスト銀縁） */
.arc-throw {
  right: 4px;
  bottom: 88px;
  width: 50px;
  height: 50px;
}

.arc-throw::after {
  background: linear-gradient(155deg, rgba(232, 198, 255, 0.82), rgba(148, 86, 232, 0.45), rgba(232, 198, 255, 0.72));
}

.arc-throw .arc-ico { transform: translateY(-4px); }
.arc-throw .arc-lbl { bottom: 6px; font-size: 8px; }

/* ⑦ ジャンプ（六角・スカイ銀縁） */
.arc-jump {
  right: 2px;
  bottom: 142px;
  width: 50px;
  height: 50px;
}

.arc-jump::after {
  background: linear-gradient(155deg, rgba(190, 238, 255, 0.84), rgba(56, 168, 255, 0.45), rgba(190, 238, 255, 0.74));
}

.arc-jump .arc-ico { transform: translateY(-4px); }
.arc-jump .arc-lbl { bottom: 6px; font-size: 8px; }

body.touchpad-visible .touch-gamepad {
  display: grid;
}

/* ステルス・ぷにコン（ラベル無し・目立ちすぎない上品な透過フロストガラス） */
.punicon-zone {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
  cursor: pointer;
}

.punicon-base {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.06) 0%, rgba(10, 14, 24, 0.24) 72%, rgba(255, 255, 255, 0.08) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.30);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  transition: transform 140ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 120ms ease, background-color 120ms ease;
  pointer-events: none;
}

.punicon-zone.is-active .punicon-base {
  border-color: rgba(255, 255, 255, 0.62);
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.10) 0%, rgba(10, 14, 24, 0.34) 100%);
}

.punicon-ring {
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.punicon-knob {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55) 0%, rgba(215, 228, 245, 0.28) 60%, rgba(140, 162, 190, 0.22) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 100ms ease;
  will-change: transform;
}

.punicon-zone.is-active .punicon-knob {
  transition: none;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.85) 0%, rgba(190, 226, 255, 0.48) 65%, rgba(110, 175, 245, 0.34) 100%);
  border-color: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.35);
}

/* 極小の方向ドット（操作時のみほのかに光る） */
.punicon-arrow {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
  transition: background-color 70ms ease, transform 70ms ease, box-shadow 70ms ease;
}

.punicon-arrow.arr-up { top: 7px; left: 50%; transform: translateX(-50%); }
.punicon-arrow.arr-down { bottom: 7px; left: 50%; transform: translateX(-50%); }
.punicon-arrow.arr-left { left: 7px; top: 50%; transform: translateY(-50%); }
.punicon-arrow.arr-right { right: 7px; top: 50%; transform: translateY(-50%); }

.punicon-arrow.is-pressed {
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.95);
}

.pad-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pad-meta-btn {
  appearance: none;
  min-width: 84px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-ref-typeface-plain);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
}

.pad-meta-btn:active,
.pad-meta-btn.is-pressed {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.pad-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  gap: 8px;
}

.pad-btn {
  appearance: none;
  height: 46px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-ref-typeface-plain);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  transition: transform 70ms ease, filter 70ms ease;
}

.pad-btn:active,
.pad-btn.is-pressed {
  transform: scale(0.92);
  filter: brightness(1.18);
}

.pad-light {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}

.pad-heavy {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.pad-special {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: transparent;
}

.pad-super {
  width: 100%;
  height: 38px;
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
}

.pad-super.is-ready {
  background-color: var(--md-sys-color-tertiary);
  color: var(--md-sys-color-on-tertiary);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(245, 190, 72, 0.45);
}

/* スマホ・タブレット向け自動最適化 */
@media (hover: none) and (pointer: coarse), (max-width: 900px) {
  body:not(.touchpad-hidden) .touch-gamepad {
    display: grid;
  }
}

/* スマホ横持ち時はヘッダーを薄くして画面いっぱい＋半透明ぷにコンオーバーレイ！ */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  body {
    padding: 4px;
  }
  .top-app-bar {
    padding: 6px 10px;
    border-radius: 12px;
  }
  .brand-subtitle,
  .m3-assist-chip,
  .controls-grid,
  .system-bar {
    display: none;
  }
  .stage-card {
    padding: 4px;
    border-radius: 12px;
  }
  .touch-gamepad {
    padding: 6px 10px 8px;
  }
  .punicon-zone {
    width: 112px;
    height: 112px;
  }
  .punicon-base {
    width: 96px;
    height: 96px;
  }
  .punicon-knob {
    width: 40px;
    height: 40px;
  }
  .arc-cluster {
    transform: scale(0.84);
    transform-origin: bottom right;
  }
}

/* スマホ縦持ち時だけは16:9画面を隠さないよう自動で下配置に切替 */
@media (max-width: 640px) and (orientation: portrait) {
  body {
    padding: 8px;
  }
  .app-shell {
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .top-app-bar {
    border-radius: var(--md-sys-shape-corner-large);
    padding: 10px 12px;
    gap: 8px;
  }
  .app-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .brand-subtitle,
  .m3-assist-chip {
    display: none;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
  }
  .m3-btn {
    height: 34px;
    padding: 0 10px;
    font-size: 11.5px;
  }
  .stage-card {
    padding: 8px;
    border-radius: 16px;
    max-width: 100%;
  }
  .touch-gamepad {
    position: relative;
    margin-top: 10px;
    padding: 12px 10px 10px;
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    pointer-events: auto;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  .touch-gamepad .pad-left,
  .touch-gamepad .pad-right {
    opacity: 1;
  }
  .touch-gamepad .pad-left { grid-column: 1; }
  .touch-gamepad .pad-right {
    grid-column: 2;
    justify-self: end;
  }
  .pad-pause-pill {
    top: 8px;
    left: 8px;
    right: auto;
    width: 30px;
    height: 30px;
  }
  .punicon-zone {
    width: 116px;
    height: 116px;
  }
  .punicon-base {
    width: 100px;
    height: 100px;
  }
  .punicon-knob {
    width: 42px;
    height: 42px;
  }
  .arc-cluster {
    width: 204px;
    height: 178px;
    transform: scale(0.92);
    transform-origin: bottom right;
  }
  .controls-grid,
  .system-bar {
    display: none;
  }
}

/* ==========================================================================
   同一Wi-Fi 2P対戦モーダル（LAN Netplay UI）
   ========================================================================== */
.lan-body {
  display: grid;
  gap: 14px;
}

.lan-status-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-size: 13px;
}

.lan-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #8b9198;
  flex-shrink: 0;
}

.lan-dot.is-waiting {
  background: #f5be48;
  box-shadow: 0 0 8px rgba(245, 190, 72, 0.7);
}

.lan-dot.is-connected {
  background: #3ee88b;
  box-shadow: 0 0 10px rgba(62, 232, 139, 0.8);
}

.lan-dot.is-error {
  background: #ff5c6c;
}

.lan-room-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.lan-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface-variant);
}

.lan-input {
  flex: 1 1 140px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-mono);
  font-size: 13px;
}

.lan-share-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.lan-share-info {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.lan-share-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}

.lan-url-code {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-family: var(--md-ref-typeface-mono);
  font-size: 12px;
  word-break: break-all;
  color: var(--md-sys-color-on-surface);
}

.lan-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lan-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--md-sys-color-on-surface-variant);
}

.lan-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: #ffffff;
  color: #161d24;
  font-size: 10px;
  font-weight: 700;
}

.lan-qr-box img {
  display: block;
  border-radius: 4px;
}

@media (max-width: 560px) {
  .lan-share-card {
    grid-template-columns: 1fr;
  }
  .lan-qr-box {
    justify-self: center;
  }
}

/* ==========================================================================
   一般公開版：ゲーム画面オンリー・フルフィット没入レイアウト
   ========================================================================== */
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #040711;
}

body {
  display: grid;
  place-items: center;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  padding: 0;
  gap: 0;
  display: grid;
  place-items: center;
}

.stage-card {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: grid;
  place-items: center;
}

.stage-viewport {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  max-width: 100vw;
  max-height: 100dvh;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 0 48px rgba(0, 0, 0, 0.75);
}

.screen-wrap {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
}

/* 画面の隅にさりげなく浮く極小ミニユーティリティ（普段は極薄） */
.mini-hud-controls {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.34;
  transition: opacity 0.2s ease;
}

.mini-hud-controls:hover,
.mini-hud-controls:focus-within {
  opacity: 0.96;
}

.mini-hud-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(8, 12, 24, 0.62);
  color: rgba(235, 244, 255, 0.92);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.mini-hud-btn:hover {
  background: rgba(24, 38, 74, 0.88);
  border-color: rgba(139, 238, 255, 0.75);
}

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

.mini-hud-btn.is-active {
  border-color: rgba(139, 238, 255, 0.62);
  color: #8beeff;
}

.mini-hud-btn.is-muted {
  opacity: 0.55;
  color: #93a3c0;
}

/* タッチ操作時のポーズボタンも安全領域に綺麗に配置 */
.pad-pause-pill {
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
}

/* 一般公開版：隠しオリジナル枠（COMING SOON）カード */
.move-card.is-secret {
  background: linear-gradient(145deg, #070a14, #101629);
  border: 1px dashed rgba(139, 238, 255, 0.32);
  position: relative;
  overflow: hidden;
}
.move-card.is-secret .move-card-name {
  color: #93a7cc;
  letter-spacing: 0.14em;
}
.move-card.is-secret .move-card-tag {
  background: rgba(255, 207, 64, 0.14);
  color: #ffcf40;
  border: 1px solid rgba(255, 207, 64, 0.35);
}
.move-card.is-secret .secret-silhouette-box {
  margin-top: 8px;
  padding: 18px 14px;
  border-radius: 12px;
  background: #04060d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  color: #7c90b8;
  font-size: 12.5px;
  line-height: 1.65;
}
.move-card.is-secret .secret-q {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #0b1020;
  border: 1.5px solid rgba(255, 207, 64, 0.45);
  color: #ffcf40;
  font-weight: 900;
  font-size: 22px;
  margin-bottom: 8px;
}
