  /* ============ Self-hosted fonts (OFL, see data/fonts/OFL.txt) ============ */
  @font-face {
    font-family: 'Display Digits';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../../data/fonts/Inter-Medium.woff2') format('woff2');
    unicode-range: U+0030-0039;
  }
  @font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../../data/fonts/CormorantGaramond-Medium.woff2') format('woff2');
  }
  @font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../../data/fonts/CormorantGaramond-SemiBold.woff2') format('woff2');
  }
  @font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../../data/fonts/Inter-Regular.woff2') format('woff2');
  }
  @font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../../data/fonts/Inter-Medium.woff2') format('woff2');
  }
  @font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../../data/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  }

  /* ============ Design tokens ============ */
  :root {
    --guild-ally: #5cc87a;
    --guild-allied: #59c9e8;
    --guild-hostile: #f06a45;
    color-scheme: dark;
    --bg: #0f1220;
    --surface: #1a1d33;
    --surface-elev: #232748;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #e7e8f5;
    --text-dim: #a1a4c3;
    --text-mute: #8a8db5; /* WCAG AA: surface/surface-elev 上で 4.5:1 以上（旧 #6e719b は 3.5:1） */
    --accent: #efb861;       /* 金の光 */
    --accent-dim: #a97a2d;
    --ok: #7cd0a1;
    --warn: #d97757;
    --err: #e05a5a;

    /* biomes */
    --biome-plain: #6d7a4b;
    --biome-forest: #3c5e34;
    --biome-stone: #676a72;
    --biome-iron: #4a4c56;
    --biome-gem: #7856a1;
    --biome-river: #3a689c;
    --biome-mountain: #4a3f38;
    --biome-bridge: #8b6b3f;

    /* type */
    --font-display: 'Display Digits', 'Cormorant Garamond', 'Noto Serif JP', Georgia, serif;
    --font-body: 'Inter', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
  }

  :root:lang(zh-Hans) {
    --font-display: 'Display Digits', 'Cormorant Garamond', 'Songti SC', 'Noto Serif CJK SC', 'Noto Serif SC', Georgia, serif;
    --font-body: 'Inter', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', 'Noto Sans SC', system-ui, sans-serif;
  }
  :root:lang(ko) {
    --font-display: 'Display Digits', 'Cormorant Garamond', 'Batang', 'Noto Serif CJK KR', 'Noto Serif KR', Georgia, serif;
    --font-body: 'Inter', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans CJK KR', 'Noto Sans KR', system-ui, sans-serif;
  }
  :root:lang(en) {
    --font-display: 'Display Digits', 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Inter', system-ui, sans-serif;
  }

  .language-select {
    min-width: 9rem;
    padding: 6px 8px;
    color: var(--text);
    background: var(--surface-elev);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font: inherit;
  }
  .title-language-label { display: grid; gap: 4px; margin: 12px 0; color: var(--text-dim); }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; overflow: hidden; }
  body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-variant-numeric: lining-nums;
  }
  body[data-theme="light"] { color-scheme: light; }

  /* 開発用DOMはテスト参照のため残し、明示的なデバッグ時だけ表示する。 */
  /* :not() で詳細度を上げる。後方の .ctrl-group / .hud の display 指定に負けないため。 */
  body:not(.debug-mode) .ctrl-group-dev,
  body:not(.debug-mode) #btn-reset,
  body:not(.debug-mode) #run-tests-link,
  body:not(.debug-mode) .hud { display: none; }
  /* スキルの内部ID（skill_code 等）はプレイヤーに見せない */
  body:not(.debug-mode) .skill-raw-details { display: none; }

  /* ============ Layout ============ */
  .app {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
  }

  header {
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: baseline;
    gap: 12px;
  }
  .header-emblem { width: 28px; height: 28px; object-fit: contain; }
  header .title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.02em;
  }
  header .subtitle {
    font-size: 11px;
    color: var(--text-mute);
    letter-spacing: 0.15em;
    text-transform: uppercase;
  }
  .header-notices-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-elev);
    color: var(--text);
    cursor: pointer;
  }
  .header-notices-btn:hover { border-color: var(--accent); color: var(--accent); }
  @media (max-width: 640px) {
    .header-notices-label { display: none; }
    .header-notices-btn { padding: 6px 8px; flex-shrink: 0; }
  }

  main {
    position: relative;
    overflow: hidden;
    background: #0a0c18 url('../../data/map_images/background_vignette.png') center / cover no-repeat;
    touch-action: none;
  }

  canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

  /* ============ Title screen ============ */
  .title-screen {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1d33 0%, #0a0c18 100%);
    transition: opacity 0.3s ease-out;
  }
  .title-screen.closing { opacity: 0; pointer-events: none; }
  .title-screen-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(48px, 7vw, 96px);
    padding: 32px;
    transform: scale(clamp(1, 0.88 + 0.012vw, 1.18));
  }
  .title-screen-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    text-align: left;
  }
  .title-screen-emblem { width: 96px; height: 96px; padding: 10px; border-radius: 20px; background: rgba(255,255,255,.035); border: 1px solid var(--line); box-shadow: 0 10px 28px rgba(0,0,0,.28); }
  .title-screen-emblem img { width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
  .title-screen-logo {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.04em;
  }
  .title-screen-tagline {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-dim);
    letter-spacing: 0.1em;
  }
  .title-screen-start-btn {
    margin-top: 16px;
    padding: 12px 40px;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    cursor: pointer;
  }
  .title-screen-start-btn:hover { background: #f5c878; }
  .legal-link-row {
    display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
    gap: 3px; color: var(--text-muted); font-size: 11px; line-height: 1.7;
  }
  .legal-link-row a { color: var(--text-muted); text-decoration: none; }
  .legal-link-row a:hover, .legal-link-row a:focus-visible { color: var(--gold); text-decoration: underline; }
  .title-legal-links { position: absolute; left: 16px; right: 16px; bottom: max(10px, env(safe-area-inset-bottom)); }
  .settings-legal-links { padding: 10px 8px 2px; }

  /* ---- ログイン/新規登録モーダル ---- */
  .auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 24, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
    backdrop-filter: blur(8px);
  }
  .auth-modal.open { display: flex; }
  .auth-modal-inner {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 32px 28px 24px;
  }
  .auth-modal-inner h2 {
    font-family: var(--font-display);
    color: var(--accent);
    margin: 0 0 16px;
    font-size: 22px;
  }
  .auth-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
  }
  .auth-modal-close:hover { color: var(--text); }
  .auth-modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-dim);
  }
  .auth-modal-field input {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 9px 12px;
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
  }
  .auth-modal-submit {
    width: 100%;
    padding: 11px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 4px;
  }
  .auth-modal-submit:hover { background: #f5c878; }
  .auth-modal-error {
    background: rgba(255, 100, 100, 0.12);
    border-left: 3px solid #ff6464;
    color: #ffb0b0;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 4px;
    margin-bottom: 14px;
  }
  /* パスワード再設定の案内（エラーではない通知。.auth-modal-error と同じ形・色だけ中立） */
  .auth-modal-notice {
    background: rgba(120, 200, 140, 0.12);
    border-left: 3px solid #78c88c;
    color: #b8e4c4;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 4px;
    margin-bottom: 14px;
  }
  .auth-modal-submit:disabled { opacity: 0.55; cursor: not-allowed; }
  .google-auth-button { width:100%; margin-top:12px; min-height:42px; display:flex; align-items:center; justify-content:center; gap:12px; border:1px solid #dadce0; border-radius:4px; background:#fff; color:#3c4043; font:500 14px Arial,sans-serif; cursor:pointer; }
  .google-auth-button:hover { background:#f8faff; box-shadow:0 1px 2px rgba(60,64,67,.2); }
  .google-auth-button svg { width:18px; height:18px; flex:none; }
  .auth-modal-verify p {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 10px;
  }
  .auth-modal-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
  }
  .auth-modal-toggle a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
  .auth-modal-toggle a:hover, .auth-modal-toggle a:focus-visible { color: #ffe0a0; text-decoration: underline; }
  /* 「確認メールを再送」はボタンだが、下の「新規登録」などと同じリンクの見た目にする（既定の灰色ボタンになっていた） */
  .auth-modal-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer; }
  .auth-modal-link:hover, .auth-modal-link:focus-visible { color: #ffe0a0; }

  /* ---- タイトル画面: カード登場アニメーション ---- */
  .title-screen-right {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 240px;
    height: 340px;
    flex: none;
  }
  .title-card-stage {
    position: relative;
    width: 220px;
    height: 320px;
    /* カードが枠外から飛来する演出のため意図的にクリップしない */
    overflow: visible;
  }
  .title-card-anim {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 0 2px rgba(230, 190, 120, 0.35);
    opacity: 0;
    transform-origin: 50% 50%;
    --sx: 0px;
    --sy: -320px;
    --srot: 120deg;
    --erot: 480deg;
  }
  .title-card-anim.playing {
    animation: title-card-cycle 3.6s ease-in-out 1 both;
  }
  @keyframes title-card-cycle {
    0%   { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(0.25) rotate(var(--srot)); }
    10%  { opacity: 1; }
    25%  { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    75%  { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(0, 0) scale(1.05) rotate(var(--erot)); }
  }
  @media (max-width: 700px) {
    .title-screen-inner {
      flex-direction: column;
      gap: 24px;
    }
    .title-screen-left { align-items: center; text-align: center; }
    .title-screen-right { width: 170px; height: 246px; }
    .title-card-stage { width: 150px; height: 218px; }
  }
  @media (max-width: 420px) {
    .title-screen-right { display: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .title-card-anim.playing { animation: none; opacity: 1; transform: none; }
  }

  /* ============ HUD ============ */
  .hud {
    position: absolute;
    inset: auto 12px 12px auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    background: rgba(15, 18, 32, 0.72);
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    backdrop-filter: blur(6px);
    pointer-events: none;
    min-width: 180px;
  }
  .hud .row { display: flex; justify-content: space-between; gap: 12px; }
  .hud .label { color: var(--text-mute); }
  .hud .val { color: var(--text); }
  .hud .val.hit { color: var(--accent); }

  .controls {
    position: absolute;
    inset: 12px auto auto 12px;
    display: flex;
    gap: 10px;
    flex-direction: column;
    max-height: none;
    overflow-y: visible;
  }
  .ctrl-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    background: rgba(15, 18, 32, 0.55);
    border: 1px solid var(--line);
    border-radius: 10px;
    backdrop-filter: blur(6px);
  }
  .ctrl-btn {
    background: rgba(15, 18, 32, 0.82);
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 5px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    backdrop-filter: blur(6px);
  }
  .icon-svg { display: inline-flex; align-items: center; justify-content: center; }
  .icon-img { display: inline-flex; align-items: center; justify-content: center; }
  .icon-img img { display: block; border-radius: 4px; object-fit: contain; }
  .ctrl-btn .icon-svg { color: var(--text); }
  .ctrl-btn:hover .icon-svg { color: var(--accent); }
  .ctrl-btn:hover { background: var(--surface-elev); }
  .ctrl-btn:active { transform: scale(0.97); }
  .ctrl-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .ctrl-btn-nav { position: relative; }
  .icon-badge-corner {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent);
    color: #1a1a1a;
    font-family: var(--font-mono);
    font-size: 9px;
    line-height: 1;
    padding: 2px 4px;
    min-width: 12px;
    text-align: center;
    border-radius: 8px;
    font-weight: 700;
    pointer-events: none;
  }
  .icon-badge-inline {
    background: var(--accent);
    color: #1a1a1a;
    font-family: var(--font-mono);
    font-size: 9px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 8px;
    font-weight: 700;
    white-space: nowrap;
  }
  .ctrl-btn-dev {
    border-style: dashed;
    opacity: 0.75;
    font-size: 10px;
  }
  .ctrl-btn.active {
    background: rgba(239, 184, 97, 0.16);
    border-color: var(--accent);
  }
  .ctrl-btn.active .icon-svg { color: var(--accent); }
  .zoom-row { display: flex; gap: 6px; }
  .zoom-row .ctrl-btn { min-width: 44px; }
  /* PC幅: 枠の幅が＋−の2個分なので、アイコンも2列に並べて隙間を埋める（2026-11-06 実機確認）。 */
  @media (min-width: 641px) {
    .ctrl-group { display: grid; grid-template-columns: repeat(2, 40px); }
    .zoom-row { grid-column: 1 / -1; gap: 4px; }
    .zoom-row .ctrl-btn { min-width: 40px; }
  }

  /* ============ Feedback (ripple/x/toast) ============ */
  .ripple {
    position: absolute;
    pointer-events: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: rgba(239, 184, 97, 0.15);
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
    animation: rippleAnim 0.3s ease-out forwards;
  }
  @keyframes rippleAnim {
    to { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
  }
  .invalid-x {
    position: absolute;
    pointer-events: none;
    transform: translate(-50%, -50%);
    color: var(--err);
    font-size: 24px;
    font-weight: bold;
    opacity: 1;
    animation: xAnim 0.4s ease-out forwards;
  }
  @keyframes xAnim {
    to { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
  }

  .toast {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 18, 32, 0.94);
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    /* Toasts are appended to #stage and must remain visible above every modal. */
    z-index: 400;
    animation: toastIn 0.2s ease-out;
  }
  .toast-bottom { bottom: 20px; }
  /* 上部の資源バー（top:12px・高さ約38px）に重ならないよう、その下に出す */
  .toast-top { top: 60px; }
  .toast.toast-emergency { border-color: var(--err); box-shadow: 0 0 0 1px var(--err), 0 8px 24px rgba(0, 0, 0, 0.4); }
  .toast-emergency-icon { display: inline-flex; color: var(--err); flex: 0 0 auto; }
  @keyframes toastIn {
    from { transform: translate(-50%, 10px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
  }
  .toast .msg { flex: 1; }
  .toast .zoom-in {
    background: var(--accent);
    color: #1a1300;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
  }

  footer {
    padding: 8px 16px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-mute);
    display: flex;
    justify-content: space-between;
  }
  footer a {
    color: var(--accent);
    text-decoration: none;
  }
  footer a:hover { text-decoration: underline; }

  /* ============ Panel: 選択情報 ============ */
  .selection-panel {
    position: absolute;
    top: 68px;
    right: 12px;
    background: rgba(15, 18, 32, 0.86);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 12px 14px;
    min-width: 200px;
    width: min(450px, calc(100% - 148px));
    font-family: var(--font-body);
    font-size: 12px;
    backdrop-filter: blur(6px);
  }
  .selection-panel .title {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }
  .selection-panel .row { display: flex; justify-content: space-between; padding: 3px 0; }
  .selection-panel .lbl { color: var(--text-mute); }
  .selection-panel .val { color: var(--text); font-family: var(--font-mono); font-size: 11px; }
  .selection-panel .hint { margin-top: 8px; font-size: 10px; color: var(--text-mute); font-style: italic; }

  /* ============ Path result panel ============ */
  .path-panel {
    position: absolute;
    left: 12px;
    bottom: 20px;
    background: rgba(15, 18, 32, 0.86);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    max-width: 260px;
    backdrop-filter: blur(6px);
    z-index: 15;
  }
  .path-panel .head {
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .path-panel .close-btn {
    background: none;
    border: 1px solid var(--line);
    color: var(--text-dim);
    padding: 1px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    font-family: var(--font-mono);
  }
  .path-panel .row { display: flex; justify-content: space-between; padding: 2px 0; }
  .path-panel .lbl { color: var(--text-mute); }
  .path-panel .val { color: var(--text); }
  .path-panel .val.ok { color: var(--ok); }
  .path-panel .val.err { color: var(--err); }

  /* ============ Card catalog modal ============ */
  .catalog-btn {
    background: rgba(15, 18, 32, 0.82);
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 12px;
    cursor: pointer;
    min-height: 44px;
    backdrop-filter: blur(6px);
  }
  .catalog-btn:hover { background: var(--surface-elev); }
  .catalog-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .catalog-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 24, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(8px);
  }
  .catalog-modal.open { display: flex; }
  
  .card-detail-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 24, 0.92);
    align-items: center;
    justify-content: center;
    z-index: 110;
    padding: 20px;
    backdrop-filter: blur(10px);
  }
  .card-detail-modal.open { display: flex !important; }
  .card-detail-inner {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .card-detail-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .card-detail-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
  }
  .card-detail-close {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
  }
  .card-detail-close:hover { border-color: var(--accent); }
  .card-detail-body {
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    color-scheme: dark;
    scrollbar-color: var(--line-strong) var(--surface);
  }
  @media (max-width: 640px) {
    .card-detail-body { grid-template-columns: 1fr; }
    /* 1列表示では貼り付けると本文に重なる */
    .card-detail-body .card-detail-illust { position: static; }
  }
  .card-detail-illust {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    align-self: start;
    /* 右カラム（個体・スキル）をスクロールしても画像を残し、左カラムの下が空いて見えないようにする */
    position: sticky;
    top: 0;
  }
  .card-detail-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .card-detail-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .card-detail-meta .rarity-tag {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.1em;
  }
  .card-detail-name {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text);
    margin: 0;
  }
  .card-detail-affinity { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
  .card-detail-section h3 {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
  }
  .card-detail-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .card-detail-stat {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 6px 4px;
    text-align: center;
  }
  .card-detail-stat .label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
  }
  .card-detail-stat .value {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
    margin-top: 2px;
  }
  .card-detail-stat.highlight { border-color: var(--accent); background: rgba(160, 130, 60, 0.15); }
  .card-detail-skills {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .card-detail-skill {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
  }
  .card-detail-skill-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
  }
  .card-detail-skill-name {
    font-weight: 500;
    color: var(--text);
    font-size: 13px;
  }
  .card-detail-skill-kind {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 1px 6px;
    border-radius: 3px;
  }
  .card-detail-skill-info {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
  }
  .card-detail-skill-info b {
    color: var(--text);
    font-weight: 500;
  }
  .card-detail-description {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    font-style: italic;
  }
  
  .tower-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 10px 0;
  }
  .tower-card {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
  }
  .tower-card:hover { transform: translateY(-2px); border-color: var(--accent); }
  .tower-card.locked {
    opacity: 0.62;
    cursor: not-allowed;
  }
  .tower-card.locked:hover {
    transform: none;
    border-color: var(--line);
  }
  .tower-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .tower-card .tower-num {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
  }
  .tower-card .tower-boss-name {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text);
    margin: 4px 0 8px 0;
    line-height: 1.3;
  }
  .tower-card .tower-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
  }
  .tower-card .tower-progress .floor {
    font-family: var(--font-mono);
    color: var(--accent);
    font-weight: 500;
  }
  .tower-card .tower-progress-bar {
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
  }
  .tower-card .tower-progress-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
  }
  .tower-card.cleared { border-color: var(--accent); }
  .tower-card.cleared::after {
    content: '踏破';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 10px;
    color: var(--accent);
    letter-spacing: 0.1em;
  }
  
  .tower-detail-back {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 12px;
  }
  .tower-detail-back:hover { border-color: var(--accent); }
  
  .tower-floors {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr)); /* 50階を10×5で割り切る */
    gap: 6px;
    padding: 10px 0;
  }
  .tower-floor {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 10px 4px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    font-family: var(--font-mono);
    font-size: 11px;
  }
  .tower-floor:hover:not(.locked) { transform: translateY(-1px); border-color: var(--accent); }
  .tower-floor.locked {
    opacity: 0.4;
    cursor: not-allowed;
  }
  .tower-floor.cleared {
    background: rgba(160, 130, 60, 0.15);
    border-color: rgba(160, 130, 60, 0.5);
  }
  .tower-floor.current {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(160, 130, 60, 0.3);
  }
  .tower-floor .floor-num {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
  }
  .tower-floor .floor-label {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .tower-floor .floor-raid {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .tower-boss-preview {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
  }
  .tower-boss-preview .boss-illust {
    width: 100px;
    aspect-ratio: 200 / 320;
    background: var(--surface);
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
  }
  .tower-boss-preview .boss-illust img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  .tower-boss-preview .boss-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .tower-boss-preview .boss-info .locked-msg {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 6px;
    line-height: 1.5;
  }
  
  /* ========================================================================
     デッキ編成UI
     ======================================================================== */
  .deck-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
  }
  .deck-entry {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    transition: border-color 0.1s;
  }
  .deck-entry.active { border-color: var(--accent); }
  .deck-entry-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
  }
  .deck-entry-name {
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--text);
    background: transparent;
    border: 1px dashed transparent;
    padding: 2px 6px;
    border-radius: 4px;
    flex: 1;
    min-width: 100px;
  }
  .deck-entry-name:focus, .deck-entry-name:hover {
    border-color: var(--line);
    outline: none;
  }
  .deck-entry-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }
  .deck-entry-actions button {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
  }
  .deck-entry-actions button:hover { border-color: var(--accent); }
  .deck-entry-actions button.danger:hover { border-color: #d15050; color: #ff8080; }
  .deck-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .deck-slot {
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 6px;
    padding: 8px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.1s;
    position: relative;
  }
  .deck-slot:hover { border-color: var(--accent); border-style: solid; }
  .deck-slot.filled { border-style: solid; }
  .deck-slot .slot-placeholder {
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono);
  }
  .deck-slot .slot-card-name {
    font-size: 12px;
    color: var(--text);
    line-height: 1.3;
    margin: 4px 0;
  }
  .deck-slot .slot-card-rarity {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    padding: 1px 5px;
    border-radius: 3px;
  }
  .deck-slot .slot-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
  }
  .deck-slot .slot-remove:hover { color: #ff8080; }
  .deck-entry-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  .deck-entry-info .deck-cost.over { color: #ff8080; font-weight: 500; }
  .deck-new-btn {
    background: var(--surface-elev);
    border: 1px dashed var(--line);
    color: var(--text);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    transition: border-color 0.1s;
  }
  .deck-new-btn:hover { border-color: var(--accent); border-style: solid; }
  
  /* デッキスロット選択モードでのカタログ表示 */
  .deck-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
  }
  .deck-picker-header button {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
  }
  
  /* ========================================================================
     設定画面
     ======================================================================== */
  .settings-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
  }
  .settings-section:last-child { border-bottom: none; }
  .settings-section h3 {
    font-size: 13px;
    color: var(--text);
    margin: 0 0 10px 0;
    font-family: var(--font-display);
  }
  .settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    gap: 12px;
  }
  .settings-item-label {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
  }
  .settings-item-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
  }
  .settings-btn {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .settings-btn:hover { border-color: var(--accent); }

  .title-notices-btn {
    position: relative;
    margin-top: 10px;
    padding: 8px 14px;
    border: 1px solid rgba(216, 184, 92, .55);
    border-radius: 6px;
    background: rgba(15, 18, 32, .76);
    color: var(--text);
    cursor: pointer;
  }
  .title-notices-btn:hover { border-color: var(--accent); color: var(--accent); }
  .title-notices-btn .icon-badge-inline { margin-left: 6px; }

  .notices-inner { max-width: 760px; }
  .notices-codes-section,
  .notices-items-section { margin-bottom: 22px; }
  .notices-codes-section > h3,
  .notices-items-section > h3 { margin: 0 0 10px; color: var(--accent); }
  .notices-code-list { display: grid; gap: 8px; margin-bottom: 12px; }
  .notices-code-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, .025);
  }
  .notices-code-row.redeemed { opacity: .68; }
  .notices-code-main,
  .notices-code-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .notices-code-main code {
    padding: 3px 7px;
    border-radius: 4px;
    background: rgba(0, 0, 0, .28);
    color: var(--accent);
    font-size: 14px;
    letter-spacing: .06em;
  }
  .notice-type-label,
  .notice-category-label,
  .notice-pinned,
  .notices-redeemed {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid var(--line);
  }
  .notices-redeemed { color: #89d39d; border-color: #4b8d5d; }
  .gift-code-form { width: 100%; }
  .gift-code-form > label { display: block; margin-bottom: 5px; font-size: 12px; color: var(--text-muted); }
  .gift-code-input-row { display: flex; gap: 7px; }
  .gift-code-input-row input { flex: 1; min-width: 0; }
  .gift-code-result { min-height: 18px; margin-top: 6px; font-size: 12px; }
  .gift-code-error { color: #ff9191; }
  .settings-gift-code-item { display: block; }
  .settings-gift-code-item .settings-item-label { margin-bottom: 8px; }
  .notices-login-required { color: var(--text-muted); }
  .notices-list { display: grid; gap: 10px; }
  .notice-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-left: 4px solid #71819d;
    border-radius: 7px;
    background: rgba(255, 255, 255, .025);
  }
  .notice-card header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
  .notice-card header time { margin-left: auto; color: var(--text-muted); font-size: 11px; }
  .notice-card h3 { margin: 8px 0 6px; font-size: 16px; }
  .notice-body { line-height: 1.65; overflow-wrap: anywhere; }
  .notice-body a { color: #78baff; }
  .notice-category-maintenance { border-left-color: #de805f; }
  .notice-category-event { border-left-color: #7e73d8; }
  .notice-category-gift { border-left-color: #d8b85c; }
  .notice-category-important { border-left-color: #e2535d; }
  .notice-important-focus { box-shadow: 0 0 0 2px rgba(226, 83, 93, .55); }

  @media (max-width: 600px) {
    .notices-code-row { align-items: flex-start; flex-direction: column; }
    .notices-code-meta { width: 100%; }
    .notices-copy-code { margin-left: auto; }
  }

  .admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0;
  }
  .admin-form-grid label { display: grid; gap: 3px; font-size: 11px; color: var(--text-muted); }
  .admin-form-grid input:not([type="checkbox"]),
  .admin-form-grid select,
  .admin-form-grid textarea { width: 100%; box-sizing: border-box; }
  .admin-form-wide { grid-column: 1 / -1; }
  .admin-form-actions { display: flex; justify-content: flex-end; gap: 6px; margin: 8px 0; }
  .admin-notice-item,
  .admin-gift-row,
  .admin-gift-default { padding: 8px; border-bottom: 1px solid var(--line); }
  .admin-gift-default { display: grid; gap: 6px; }
  .admin-gift-default textarea { width: 100%; box-sizing: border-box; }
  .admin-gift-sim-warning { color: #f2b35f; min-height: 16px; font-size: 12px; }
  .admin-gift-note { color: #f2b35f; font-size: 12px; margin: 6px 0; }
  .admin-table-scroll { overflow: auto; }
  .admin-table-scroll table { width: 100%; min-width: 620px; font-size: 12px; }
  .admin-gift-section h4 { margin-top: 20px; color: var(--accent); }

  @media (max-width: 600px) {
    .admin-form-grid { grid-template-columns: 1fr; }
    .admin-form-wide { grid-column: auto; }
  }
  .settings-volume { width: min(180px, 42vw); accent-color: var(--accent); }
  .settings-sound-test { align-items: flex-start; }
  .settings-sound-test-panel {
    display: flex;
    flex: 0 1 280px;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }
  .settings-sound-test-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px; border-radius: 4px; }
  .settings-sound-test-row.is-previewing { background: rgba(241, 196, 15, .12); }
  .settings-sound-test-scene { min-width: 0; font-size: 12px; }
  .settings-sound-test-actions { display: flex; flex-shrink: 0; gap: 4px; }
  .settings-sound-test-actions .settings-btn { padding-inline: 9px; }
  .settings-sound-test-actions .settings-btn[aria-pressed="true"] {
    color: #1a1a1a;
    background: var(--accent);
    border-color: var(--accent);
  }
  @media (max-width: 480px) {
    .settings-sound-test { flex-direction: column; }
    .settings-sound-test-panel { flex-basis: auto; width: 100%; }
  }
  .settings-btn.danger { color: #ff8080; }
  .settings-btn.danger:hover { border-color: #d15050; background: rgba(200, 60, 60, 0.1); }
  button:disabled, .settings-btn:disabled { opacity: .45; cursor: not-allowed; }
  
  /* ========================================================================
     戦闘ログモーダル
     ======================================================================== */
  .battle-log-turn {
    padding: 6px 10px;
    margin-bottom: 4px;
    background: var(--surface-elev);
    border-radius: 4px;
    border-left: 3px solid var(--accent);
  }
  .battle-log-turn-header {
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 4px;
  }
  .battle-log-turn-events {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 12px;
  }
  .battle-log-result {
    padding: 12px;
    background: var(--surface-elev);
    border-radius: 6px;
    margin-bottom: 12px;
    text-align: center;
    font-family: var(--font-display);
  }
  .battle-log-result.win { border: 1px solid var(--accent); }
  .battle-log-result.lose { border: 1px solid #d15050; color: #ff8080; }
  
  /* ========================================================================
     チュートリアル
     ======================================================================== */
  .tutorial-step {
    padding: 8px 0;
  }
  .tutorial-step h3 {
    font-family: var(--font-body);
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--text);
    margin: 0 0 12px 0;
  }
  .tutorial-step p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 8px 0;
  }
  .tutorial-step ul {
    padding-left: 20px;
    margin: 12px 0;
  }
  .tutorial-step li {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 4px;
  }
  .tutorial-step b {
    color: var(--accent);
    font-weight: 500;
  }
  .tutorial-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 0 0;
    border-top: 1px solid var(--line);
    margin-top: 20px;
  }
  .tutorial-nav button {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
  }
  .tutorial-nav button:hover:not(:disabled) { border-color: var(--accent); }
  .tutorial-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
  .tutorial-nav button.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 500; }
  .tutorial-nav button.primary:hover { opacity: 0.9; }
  
  /* ========================================================================
     統計ダッシュボード
     ======================================================================== */
  .stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
  }
  .stats-card {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
  }
  .stats-card .stats-label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 6px;
  }
  .stats-card .stats-value {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--text);
    font-weight: 500;
  }
  .stats-card .stats-value .unit {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: normal;
    margin-left: 4px;
  }
  .stats-card .stats-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
  }
  .stats-card.highlight { border-color: var(--accent); }
  .stats-progress-bar {
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
  }
  .stats-progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
  }
  
  .stats-section-title {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text);
    margin: 16px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }
  
  .rarity-distribution {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin: 10px 0;
  }
  .rarity-cell {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 4px;
    text-align: center;
  }
  .rarity-cell .rarity-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    padding: 1px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 4px;
  }
  .rarity-cell .rarity-owned {
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--text);
  }
  .rarity-cell .rarity-total {
    font-size: 10px;
    color: var(--text-muted);
  }
  
  /* バトル履歴リスト */
  .battle-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .battle-history-item {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 12px;
    display: grid;
    grid-template-columns: 60px 1fr 90px;
    gap: 10px;
    align-items: center;
    font-size: 11px;
  }
  .battle-history-item.win { border-left: 3px solid var(--accent); }
  .battle-history-item.lose { border-left: 3px solid #d15050; }
  .battle-history-item .bh-outcome {
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.1em;
  }
  .battle-history-item.win .bh-outcome { color: var(--accent); }
  .battle-history-item.lose .bh-outcome { color: #ff8080; }
  .battle-history-item .bh-detail { color: var(--text-secondary); line-height: 1.5; }
  .battle-history-item .bh-detail b { color: var(--text); }
  .battle-history-item .bh-time { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; text-align: right; }
  
  /* デッキプレビュー（統計値表示） */
  .deck-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--surface);
    border-radius: 4px;
    font-size: 11px;
  }
  .deck-preview-item {
    text-align: center;
  }
  .deck-preview-item .label {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .deck-preview-item .value {
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
    font-family: var(--font-display);
    margin-top: 2px;
  }
  
  /* ========================================================================
     デイリークエスト
     ======================================================================== */
  .quest-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
  }
  .quest-item {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 14px;
    align-items: center;
  }
  .quest-item.done {
    border-color: var(--accent);
    background: rgba(160, 130, 60, 0.08);
  }
  .quest-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }
  .quest-name {
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .quest-desc {
    font-size: 11px;
    color: var(--text-muted);
  }
  .quest-done-badge {
    background: var(--accent);
    color: #1a1a1a;
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em;
  }
  .quest-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .quest-progress-bar {
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
  }
  .quest-progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
  }
  .quest-progress-text {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
  }
  .quest-item.done .quest-progress-text {
    color: var(--accent);
    font-weight: 500;
  }
  
  /* ========================================================================
     実績
     ======================================================================== */
  .achievement-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    margin: 10px 0;
  }
  .title-selector-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
    padding: 10px 12px;
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
  }
  .title-selector-row select {
    min-width: 180px;
  }
  .player-title {
    margin-right: 4px;
    font-weight: 700;
  }
  .title-rainbow {
    color: transparent;
    background: linear-gradient(90deg, #ff6688, #ffc75f, #7ee787, #62b6ff, #c084fc, #ff6688);
    background-size: 300% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    animation: title-rainbow-flow 8s linear infinite;
  }
  @keyframes title-rainbow-flow {
    to { background-position: 300% 0; }
  }
  @media (prefers-reduced-motion: reduce) {
    .title-rainbow { animation: none; background-position: 50% 0; }
  }
  .achievement-item {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 10px;
    align-items: center;
    transition: opacity 0.15s;
  }
  .achievement-item.locked {
    opacity: 0.72;
  }
  .achievement-item.unlocked {
    border-color: var(--accent);
    background: rgba(160, 130, 60, 0.06);
  }
  .achievement-icon {
    font-size: 22px;
    text-align: center;
  }
  .achievement-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }
  .achievement-name {
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .achievement-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .achievement-category {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.05em;
  }
  .achievement-item.unlocked .achievement-category {
    color: var(--accent);
  }
  .catalog-inner {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .catalog-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .catalog-head h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.02em;
  }
  .catalog-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-mute);
    margin-left: 8px;
  }
  .catalog-close {
    background: none;
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 12px;
    min-width: 44px;
    min-height: 44px;
  }
  .catalog-filters {
    padding: 10px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12px;
  }
  .catalog-filters .filter-label {
    color: var(--text-mute);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-right: 4px;
  }
  .filter-chip {
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    min-height: 32px;
  }
  .filter-chip.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--bg); /* WCAG AA: 白文字は 3.8:1 だったため暗色文字（4.9:1） */
  }
  .catalog-search {
    flex: 1;
    min-width: 160px;
    background: var(--surface-elev);
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 12px;
  }
  .catalog-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  /* Modal bodies are vertical by default. Only the card catalog has repeated
     card tiles as direct children and therefore opts into the auto-fill grid. */
  #catalog-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .card-item {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .card-item:hover { transform: translateY(-1px); border-color: var(--accent); }
  .card-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .card-item .card-image {
    width: 100%;
    aspect-ratio: 200 / 320;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
  }
  .card-item .card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }
  .card-item .card-image .card-image-fallback {
    color: var(--text-muted, #888);
    font-size: 10px;
    font-family: var(--font-mono);
    text-align: center;
  }
  .card-item .rarity {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    padding: 1px 6px;
    border-radius: 3px;
    align-self: flex-start;
  }
  .card-item .rarity.C { background: #4a5c40; color: #cde3c0; }
  .card-item .rarity.UC { background: #4a5c60; color: #c0d8e3; }
  .card-item .rarity.R { background: #4a5080; color: #c8ceff; }
  .card-item .rarity.SR { background: #6a4a80; color: #e0c8ff; }
  .card-item .rarity.SSR { background: #864455; color: #ffc8d8; }
  .card-item .rarity.UR { background: #8f5c19; color: #ffe4b8; }
  .card-item .rarity.LR { background: #a1341e; color: #ffd2c6; } /* SSR/UR/LR は WCAG AA（4.5:1）に合わせて調整 */
  .rarity {
    position: relative;
    padding-left: 14px !important;
  }
  .rarity::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: currentColor;
  }
  .rarity.C::before { }
  .rarity.UC::before { border-radius: 2px; }
  .rarity.R::before { clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); }
  .rarity.SR::before { clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
  .rarity.SSR::before { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
  .rarity.UR::before { clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%); }
  .rarity.LR::before { clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%); }
  .card-item .name {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text);
    line-height: 1.2;
    margin-top: 2px;
  }
  .card-item .faction {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-mute);
  }
  .card-item .stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    margin-top: 4px;
    font-family: var(--font-mono);
    font-size: 9px;
  }
  .card-item .stats span {
    background: rgba(255, 255, 255, 0.03);
    padding: 2px 3px;
    border-radius: 2px;
    color: var(--text-dim);
    text-align: center;
  }
  .card-item .stats span b { color: var(--text); font-weight: 500; }
  .catalog-loading, .catalog-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-mute);
    font-family: var(--font-mono);
    font-size: 12px;
  }

  /* ============ Resource bar ============ */
  .resource-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 18, 32, 0.86);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    backdrop-filter: blur(6px);
    z-index: 5;
  }
  .resource-bar .res-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text);
    white-space: nowrap;
  }

  /* モーダル内のネイティブ入力をダークUIの共通トークンへ揃える。 */
  :is(.catalog-modal, .card-detail-modal, .battle-modal) :is(
    select, textarea, input[type="text"], input[type="number"],
    input[type="email"], input[type="password"], input[type="search"]
  ) {
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-elev);
    color: var(--text);
    font: inherit;
  }
  :is(.catalog-modal, .card-detail-modal, .battle-modal, .selection-panel) button:not([class]) {
    min-height: 32px;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-elev);
    color: var(--text);
    font: inherit;
    cursor: pointer;
  }
  :is(.catalog-modal, .card-detail-modal, .battle-modal) :is(input, select, textarea, button):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .guild-create-form { display: grid; gap: 10px; }
  .guild-create-form .unit-field { display: grid; gap: 5px; font-size: 12px; }
  .guild-create-form .settings-btn { justify-self: start; }
  .guild-public-section { width: 100%; }
  .guild-diplomacy { margin-bottom: 12px; }
  .guild-diplomacy h4 { margin: 10px 0 4px; }
  .guild-diplomacy-row { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid var(--line); }
  .guild-diplomacy-empty { color:var(--text-dim); font-size:12px; }
  .guild-relation-badge { margin-left:6px; padding:2px 6px; border-radius:10px; font-size:11px; }
  .guild-relation-badge.allied { color:var(--guild-allied); border:1px solid var(--guild-allied); }
  .guild-relation-badge.hostile { color:var(--guild-hostile); border:1px solid var(--guild-hostile); }
  .guild-relation-badge.own { color:var(--guild-ally); border:1px solid var(--guild-ally); }

  .chat-layout { display: flex; flex-direction: column; gap: 12px; min-height: 260px; }
  .chat-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .chat-tabs .settings-btn { min-height: 32px; padding: 6px 12px; }
  .chat-panel { display: flex; flex-direction: column; min-height: 0; }
  .chat-messages { min-height: 150px; max-height: 320px; overflow-y: auto; }
  .chat-composer { display: flex; gap: 8px; margin-top: 12px; }
  .chat-composer input { flex: 1; min-width: 0; }

  .battle-result-inner { max-width: 620px; }
  .battle-result-content { display: grid; gap: 14px; }
  .battle-result-banner {
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
  }
  .battle-result-banner.win { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
  .battle-result-banner.lose { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }
  .battle-result-banner.draw { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
  .battle-result-title { font-family: var(--font-body); font-size: 21px; }
  .battle-result-rewards { display: flex; gap: 8px; flex-wrap: wrap; }
  .battle-result-chip { padding: 5px 9px; border: 1px solid var(--accent-dim); border-radius: 999px; color: var(--accent); }
  .battle-result-meta { color: var(--text-dim); }
  .battle-result-actions { display: flex; justify-content: flex-end; gap: 8px; }
  .battle-result-remaining { color: var(--text-mute); font-size: 12px; text-align: right; }
  .resource-bar .res-icon {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 2px;
  }
  .resource-bar .res-icon.gold { background: #d4a437; }
  .resource-bar .res-icon.wood { background: #6b4a2a; }
  .resource-bar .res-icon.stone { background: #8a8a8a; }
  .resource-bar .res-icon.iron { background: #4a4a4a; }
  .resource-bar .res-icon.gem { background: #b87dd6; }

  /* ============ Battle modal ============ */
  .battle-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 24, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(8px);
  }
  .battle-modal.open { display: flex; }
  .battle-inner {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 92vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
  }
  .battle-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .battle-head h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 500;
  }
  .battle-arena {
    padding: 16px 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: start;
  }
  .battle-side {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .battle-side.attacker { border-right: 1px dashed var(--line); padding-right: 8px; }
  .battle-side h3 {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 4px;
  }
  .battle-vs {
    font-family: var(--font-display);
    font-size: 32px;
    color: var(--accent);
    align-self: center;
    padding-top: 24px;
  }
  .battle-card {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    font-family: var(--font-mono);
  }
  .battle-card.dead { opacity: 0.4; text-decoration: line-through; }
  .battle-card .bc-name {
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--text);
    margin-bottom: 3px;
  }
  .battle-card .bc-stats { color: var(--text-mute); }
  .battle-card .bc-count {
    display: flex;
    justify-content: space-between;
    margin-top: 3px;
    align-items: baseline;
  }
  .battle-card .bc-count b {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--accent);
  }
  .battle-log {
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    max-height: 200px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    background: rgba(10, 12, 24, 0.4);
  }
  .battle-log .log-line { padding: 1px 0; }
  .battle-log .log-line.attack { color: var(--text); }
  .battle-log .log-line.counter { color: var(--warn); }
  .battle-log .log-line.death { color: var(--err); }
  .battle-log .log-line.phase {
    color: var(--accent);
    font-weight: 600;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--line);
  }
  .battle-log .log-line.result {
    font-size: 13px;
    font-family: var(--font-display);
    padding: 6px 0;
    border-top: 1px solid var(--line);
    margin-top: 6px;
  }
  .battle-log .log-line.result.win { color: var(--ok); }
  .battle-log .log-line.result.lose { color: var(--err); }
  .battle-log .log-line.result.draw { color: var(--warn); }
  
  /* Battle setup */
  .battle-setup {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    max-height: 60vh;
  }
  .battle-setup .setup-row { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 10px; align-items: center; }
  .battle-setup .setup-row select { min-width: 0; max-width: 100%; }
  .battle-setup label { font-family: var(--font-mono); font-size: 10px; color: var(--text-mute); text-transform: uppercase; }
  .battle-setup select {
    background: var(--surface-elev);
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 10px;
  }
  .battle-setup .card-slot {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px;
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
  }
  .battle-setup .card-slot .slot-info { color: var(--text-dim); }
  .battle-setup .card-slot input {
    width: 60px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
  }
  .battle-btn {
    background: var(--accent);
    color: #1a1300;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    min-height: 40px;
  }
  .battle-btn:disabled { background: var(--surface-elev); color: var(--text-mute); cursor: not-allowed; }

  /* ========================================================================
     お気に入り機能・在庫バッジ・カタログ拡張
     ======================================================================== */
  .card-fav-btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .card-fav-btn:hover { border-color: var(--accent); color: var(--accent); }
  .card-fav-btn.active {
    color: #ffb400;
    border-color: #ffb400;
    background: rgba(255, 180, 0, 0.1);
  }
  
  .card-item .card-image {
    position: relative;
  }
  .card-fav-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    color: #ffb400;
    font-size: 14px;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    z-index: 2;
  }
  .card-owned-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(160, 130, 60, 0.9);
    color: #1a1a1a;
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 500;
    letter-spacing: 0.02em;
    z-index: 2;
  }
  .card-unowned-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(80, 80, 100, 0.8);
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 8px;
    letter-spacing: 0.02em;
    z-index: 2;
  }
  /* 未所持は画像だけ薄くする（文字まで薄くすると WCAG AA のコントラストを割るため） */
  .card-item.unowned .card-image {
    opacity: 0.72;
  }
  .card-item.unowned:hover .card-image {
    opacity: 1;
  }
  .card-item.never-owned .card-image,
  .card-item.never-owned .rarity,
  .card-item.never-owned .name,
  .card-item.never-owned .faction,
  .card-item.never-owned .stats {
    filter: brightness(0.32) grayscale(0.9) contrast(0.8);
  }
  .card-item.never-owned .name,
  .card-item.never-owned .faction,
  .card-item.never-owned .stats {
    opacity: 0.45;
  }
  .card-item.never-owned .card-unowned-badge {
    filter: none;
    opacity: 1;
  }
  
  /* ソートセレクタ */
  .catalog-sort {
    background: var(--surface-elev);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
  }
  .catalog-sort:hover { border-color: var(--accent); }
  .catalog-sort:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
  
  /* ========================================================================
     ライトテーマ切替（Settings画面から）
     data-theme="light" を body に付与すると発動
     ======================================================================== */
  body[data-theme="light"] {
    --bg: #f5f4ec;
    --surface: #ffffff;
    --surface-elev: #eeece0;
    --text: #1a1a1a;
    --text-secondary: #333;
    --text-muted: #6a6a6a;
    --line: rgba(0, 0, 0, 0.12);
    --line-strong: rgba(0, 0, 0, 0.24);
    --accent: #8a6a20;
  }
  body[data-theme="light"] canvas { background: #e8e5d6; }
  body[data-theme="light"] .card-fav-btn.active { background: rgba(255, 180, 0, 0.2); }

  /* ========================================================================
     ヘルプ・キーバインド表示
     ======================================================================== */
  .help-keys-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
  }
  .help-key-item {
    display: grid;
    /* minmax(max-content, 40%) は常に上限の40%で確定し1文字キーも233px幅になった。
       列は固定幅にして行間で説明文の位置を揃え、キーは中身の幅で左寄せする */
    grid-template-columns: 10em minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 5px 0;
  }
  .help-key {
    background: var(--surface-elev);
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    text-align: center;
    letter-spacing: 0.05em;
    min-width: 30px;
    display: inline-block;
    justify-self: start;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .help-key-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
  }

  /* ========================================================================
     プレイヤー情報カード（統計画面上部）
     ======================================================================== */
  .player-info-card {
    background: linear-gradient(135deg, var(--surface-elev) 0%, rgba(160, 130, 60, 0.08) 100%);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
  }
  @media (max-width: 640px) {
    .player-info-card { grid-template-columns: 1fr; }
  }
  .player-info-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 140px;
  }
  .player-avatar {
    width: 52px;
    height: 52px;
    background: var(--accent);
    color: #1a1a1a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 500;
    flex-shrink: 0;
  }
  .player-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }
  .player-name {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--text);
    line-height: 1.2;
  }
  .player-id {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .player-info-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  @media (max-width: 500px) {
    .player-info-stats { grid-template-columns: repeat(2, 1fr); }
  }
  .pi-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }
  .pi-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .pi-stat-value {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--text);
    font-weight: 500;
  }
  .pi-stat-max {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: normal;
  }

  /* ========================================================================
     城レベルアップパネル
     ======================================================================== */
  .castle-upgrade-panel {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
  }
  @media (max-width: 500px) {
    .castle-upgrade-panel { grid-template-columns: 1fr; }
  }
  .castle-upgrade-panel.maxed {
    background: linear-gradient(135deg, rgba(160, 130, 60, 0.15) 0%, var(--surface-elev) 100%);
    border-color: var(--accent);
    display: block;
  }
  .castle-upgrade-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }
  .castle-upgrade-label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.15em;
    text-transform: uppercase;
  }
  .castle-upgrade-next {
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--text);
  }
  .castle-upgrade-effects {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 2px;
  }
  .castle-upgrade-effects b {
    color: var(--accent);
    font-weight: 500;
  }
  .castle-upgrade-costs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
  }
  .castle-upgrade-costs .uc-cost b {
    color: var(--text);
    font-weight: 500;
    font-family: var(--font-mono);
  }
  .castle-upgrade-costs .uc-cost.insufficient b {
    color: #ff8080;
  }
  .castle-upgrade-btn {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: not-allowed;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.05em;
    white-space: nowrap;
    min-width: 120px;
    transition: all 0.15s;
  }
  .castle-upgrade-btn.ready {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(160, 130, 60, 0.3);
  }
  .castle-upgrade-btn.ready:hover {
    opacity: 0.9;
    transform: translateY(-1px);
  }
  .castle-upgrade-btn.disabled:hover {
    background: var(--surface-elev);
  }
  
  /* プレイヤー名変更ボタン */
  .player-name-edit-btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    margin-left: 6px;
    vertical-align: middle;
    padding: 0;
    transition: all 0.15s;
  }
  .player-name-edit-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  /* ========================================================================
     リソース詳細モーダル
     ======================================================================== */
  .resource-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }
  .resource-detail-table thead th {
    text-align: left;
    padding: 8px 10px;
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
  }
  .resource-detail-table thead th:nth-child(3),
  .resource-detail-table thead th:nth-child(4) {
    text-align: right;
  }
  .resource-detail-table tbody td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
  }
  .rd-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
  }
  .rd-progress-bar {
    height: 5px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
  }
  .rd-progress-fill {
    height: 100%;
    transition: width 0.3s;
  }
  .rd-progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .rd-progress-text b {
    color: var(--text);
    font-weight: 500;
  }
  .rd-full-badge {
    background: var(--accent);
    color: #1a1a1a;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    margin-left: auto;
  }
  
  /* ========================================================================
     ヘッダー資源バーの拡張（プレイヤー名・クリック可能な資源アイテム）
     ======================================================================== */
  .res-item-clickable {
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    transition: all 0.15s;
  }
  .res-item-clickable:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line);
  }
  .res-item-player {
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: inherit;
    transition: all 0.15s;
  }
  .res-item-player:hover {
    background: rgba(160, 130, 60, 0.12);
    border-color: var(--accent);
  }
  .res-player-name {
    color: var(--text-muted);
    font-size: 11px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  @media (max-width: 640px) {
    .res-player-name { display: none; }
  }

  /* ========================================================================
     タワー戦のデッキ選択ダイアログ
     ======================================================================== */
  .deck-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .deck-picker-item {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.15s;
    width: 100%;
  }
  .deck-picker-item:hover {
    border-color: var(--accent);
    background: rgba(160, 130, 60, 0.08);
    transform: translateX(2px);
  }
  .deck-picker-item.deck-picker-auto {
    border-style: dashed;
    margin-top: 4px;
  }
  .dpi-name {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text);
  }
  .dpi-cards {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
  }
  .dpi-stats {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-top: 2px;
  }

  /* ========================================================================
     カード比較機能
     ======================================================================== */
  .compare-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(160, 130, 60, 0.12);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 8px 14px;
    margin: 8px 16px 0;
    font-size: 12px;
    color: var(--text-secondary);
  }
  .compare-banner b { color: var(--accent); }
  .compare-banner button {
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
  }
  .compare-banner button:hover { border-color: var(--accent); color: var(--accent); }
  
  .compare-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: start;
    margin-bottom: 16px;
  }
  .compare-col-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
  }
  .compare-vs {
    align-self: center;
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--text-muted);
    padding: 0 4px;
  }
  .compare-card-name {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--text);
    line-height: 1.3;
  }
  .compare-card-sub {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
  }
  .compare-card-skills {
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 2px;
  }
  
  .compare-stats {
    border-top: 1px solid var(--line);
    padding-top: 8px;
  }
  .compare-row {
    display: grid;
    grid-template-columns: 1fr 70px 1fr;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    align-items: center;
  }
  .compare-row-total {
    border-bottom: none;
    border-top: 2px solid var(--line-strong);
    margin-top: 2px;
    font-weight: 500;
  }
  .compare-label {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
  }
  .compare-val {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
  }
  .compare-val:first-child { text-align: right; }
  .compare-val:last-child { text-align: left; }
  .compare-val.high {
    color: var(--accent);
    font-weight: 600;
  }
  
  .compare-summary {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--surface-elev);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
  }
  .compare-summary b { color: var(--text); }

  /* ========================================================================
     土地占有・攻撃システム（選択パネル内セクション）
     ======================================================================== */
  #sel-territory { margin-top: 8px; }
  .terr-info {
    background: var(--surface-elev);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 8px;
  }
  .terr-info b { color: var(--text); }
  .terr-info.terr-owned {
    border-color: var(--accent);
    background: rgba(160, 130, 60, 0.10);
    color: var(--text);
  }
  .terr-info.terr-castle {
    border-color: var(--accent);
    background: rgba(160, 130, 60, 0.15);
    color: var(--accent);
    font-family: var(--font-display);
    margin-bottom: 0;
  }
  .tile-action-row {
    display: flex;
    gap: 6px;
  }
  .tile-action-btn {
    flex: 1;
    background: var(--surface-elev);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 7px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.15s;
    min-height: 34px;
  }
  .tile-action-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
  .tile-action-btn.primary {
    background: var(--accent);
    color: #1a1a1a;
    border-color: var(--accent);
    font-weight: 500;
  }
  .tile-action-btn.primary:hover:not(:disabled) { opacity: 0.9; color: #1a1a1a; }
  .tile-action-btn.danger { border-color: rgba(255, 128, 128, 0.5); color: #ff8080; width: 100%; }
  .tile-action-btn.danger:hover { border-color: #ff8080; background: rgba(255, 128, 128, 0.08); }
  .tile-action-btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .terr-cap-note {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 6px;
    letter-spacing: 0.03em;
  }
  #selection-panel .terr-cap-note { width: 100%; overflow-wrap: anywhere; }
  
  /* 城レベルアップのゲート未達注記 */
  .castle-upgrade-gate-note {
    margin-top: 8px;
    font-size: 11px;
    color: #ffb464;
    line-height: 1.5;
  }

  /* ========================================================================
     ミニマップ（左下、クリックで移動、Mで表示切替）
     ======================================================================== */
  #minimap {
    position: absolute;
    left: 12px;
    bottom: 12px;
    width: 160px;
    height: 160px;
    background: rgba(15, 18, 32, 0.86);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    cursor: pointer;
    z-index: 5;
    image-rendering: pixelated;
  }
  #minimap:hover { border-color: var(--accent); }
  @media (max-width: 640px) {
    #minimap { width: 110px; height: 110px; left: 8px; bottom: 8px; }
  }
  body[data-theme="light"] #minimap { background: rgba(240, 240, 246, 0.88); }
  
  /* 土地攻撃クールダウンの表示 */
  .terr-cooldown {
    background: rgba(255, 180, 100, 0.10);
    border: 1px solid rgba(255, 180, 100, 0.4);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 11px;
    color: #ffb464;
    margin-bottom: 8px;
    line-height: 1.5;
  }

  /* 前線拠点（選択パネル内セクション） */
  .terr-info.terr-outpost {
    border-color: rgba(90, 200, 210, 0.7);
    background: rgba(70, 160, 170, 0.10);
    color: var(--text);
  }

  /* ============ Box inventory / opening ============ */
  .box-panel { max-width: 960px; }
  .box-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-elev);
    color: var(--text-muted);
    font-size: 12px;
  }
  .box-summary b { color: var(--accent); }
  .box-starter-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 211, 107, 0.5);
    border-radius: 8px;
    background: rgba(255, 211, 107, 0.10);
  }
  .box-starter-banner b {
    display: block;
    color: var(--text);
    margin-bottom: 2px;
  }
  .box-starter-banner span {
    color: var(--text-muted);
    font-size: 12px;
  }
  .box-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }
  @media (min-width: 760px) { .box-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  .box-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-elev);
    padding: 12px;
    text-align: center;
  }
  .shop-box-grid .box-card { text-align: left; }
  .shop-box-grid .box-icon { margin-inline: auto; }
  .shop-box-grid .shop-product-actions { justify-content: center; }
  .box-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .box-icon img { width: 100%; height: 100%; object-fit: contain; }
  .box-icon-fallback { display: none; font-size: 34px; line-height: 1; }
  .box-name {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
  }
  .box-count, .box-pity {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
  }
  .box-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
  }
  .box-actions .settings-btn {
    padding: 6px 10px;
    min-width: 58px;
  }
  .box-actions .settings-btn:disabled,
  .box-starter-banner .settings-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }
  /* 開封結果・演出欄は宝箱一覧の上に移ったため、空のときは高さと余白を取らない（約130pxの空白が出ていた） */
  .box-animation:empty, .box-results:empty { display: none; }
  .box-animation {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 14px 0 8px;
  }
  .box-opening {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text);
    animation: boxShake 0.5s ease-in-out, boxOpen 0.5s ease-in-out 0.5s;
  }
  .box-opening span { font-size: 48px; line-height: 1; }
  .box-opening img { width: 64px; height: 64px; object-fit: contain; }
  .box-opening .box-icon-fallback { display: none; font-size: 48px; }
  .box-opening.reveal-ssr,
  .box-opening.reveal-ur {
    color: #ffd36b;
    text-shadow: 0 0 16px rgba(255, 211, 107, 0.8);
  }
  .box-opening { position: relative; perspective: 700px; }
  .box-reveal-flash {
    position: absolute;
    z-index: -1;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
  }
  .reveal-ur .box-reveal-flash {
    background: repeating-conic-gradient(from 0deg, rgba(255, 221, 92, 0.9) 0 8deg, transparent 8deg 18deg);
    animation: boxGoldFlash 0.6s ease-out 0.45s;
  }
  .reveal-lr .box-reveal-flash {
    background: conic-gradient(#ff5470, #ffd45a, #55e88b, #55b8ff, #9d65ff, #ff5470);
    animation: boxRainbowFlash 0.9s ease-out 0.45s;
  }
  .box-opening.reveal-lr,
  .box-result-item.reveal-lr {
    border-color: transparent;
    background: linear-gradient(var(--surface), var(--surface)) padding-box,
      conic-gradient(#ff5470, #ffd45a, #55e88b, #55b8ff, #9d65ff, #ff5470) border-box;
    text-shadow: 0 0 14px rgba(157, 101, 255, 0.75);
  }
  .box-reveal-label { font-family: var(--font-mono); letter-spacing: 0.12em; }
  .box-results {
    display: grid;
    gap: 8px;
  }
  .box-result-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
    animation: boxRewardFade 0.3s ease-out both;
  }
  .box-result-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 8px;
  }
  .box-reward-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .box-reward-card {
    min-width: 130px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    background: var(--surface-elev);
  }
  .box-reward-rarity {
    font-size: 11px;
    color: var(--accent);
    font-family: var(--font-mono);
  }
  .box-reward-name {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    margin-top: 2px;
  }
  .box-reward-glow {
    border-color: #ffd36b;
    box-shadow: 0 0 18px rgba(255, 211, 107, 0.42);
    animation: boxRewardFade 0.3s ease-out both, boxGlow 1.2s ease-in-out infinite alternate;
  }
  .box-reward-flip {
    transform-style: preserve-3d;
    backface-visibility: hidden;
    animation: boxCardFlip 0.4s ease-out both, boxRewardFade 0.3s ease-out both;
  }
  .box-reward-card.reveal-ur { border-color: #ffd36b; }
  .box-reward-card.reveal-lr {
    border-color: transparent;
    background: linear-gradient(var(--surface-elev), var(--surface-elev)) padding-box,
      conic-gradient(#ff5470, #ffd45a, #55e88b, #55b8ff, #9d65ff, #ff5470) border-box;
    animation: boxCardFlip 0.4s ease-out both, boxRainbowBorder 2s linear infinite;
  }
  .box-resource-reward {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
  }
  @keyframes boxShake {
    0%, 100% { transform: rotate(0deg) scale(1); }
    20% { transform: rotate(-8deg) scale(1.04); }
    40% { transform: rotate(8deg) scale(1.04); }
    60% { transform: rotate(-6deg) scale(1.06); }
    80% { transform: rotate(6deg) scale(1.06); }
  }
  @keyframes boxOpen {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.18); filter: brightness(1.8); }
  }
  @keyframes boxGoldFlash {
    0% { opacity: 0; transform: scale(0.2); }
    35% { opacity: 1; }
    100% { opacity: 0; transform: scale(1.5) rotate(20deg); }
  }
  @keyframes boxRainbowFlash {
    0% { opacity: 0; transform: scale(0.2) rotate(0deg); filter: hue-rotate(0deg); }
    35% { opacity: 0.95; }
    100% { opacity: 0; transform: scale(1.6) rotate(240deg); filter: hue-rotate(360deg); }
  }
  @keyframes boxCardFlip {
    from { opacity: 0; transform: perspective(700px) rotateY(180deg); }
    to { opacity: 1; transform: perspective(700px) rotateY(0deg); }
  }
  @keyframes boxRainbowBorder {
    to { filter: hue-rotate(360deg); }
  }
  @media (prefers-reduced-motion: reduce) {
    .box-opening,
    .box-reveal-flash,
    .box-result-item,
    .box-reward-glow,
    .box-reward-flip,
    .box-reward-card.reveal-lr {
      animation: none !important;
      transform: none !important;
    }
  }
  @keyframes boxRewardFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes boxGlow {
    from { box-shadow: 0 0 12px rgba(255, 211, 107, 0.38); }
    to { box-shadow: 0 0 26px rgba(255, 211, 107, 0.76); }
  }

  .login-bonus-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-elev);
    padding: 18px;
    text-align: center;
  }
  .login-bonus-day {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 13px;
    margin-bottom: 6px;
  }
  .login-bonus-streak {
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 14px;
  }
  .login-bonus-rewards {
    display: grid;
    gap: 8px;
  }
  .login-bonus-reward {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    padding: 10px;
  }

  .shop-panel { max-width: 1040px; }
  .shop-mock-notice {
    border: 1px solid rgba(255, 180, 100, 0.45);
    border-radius: 6px;
    background: rgba(255, 180, 100, 0.10);
    color: #ffb464;
    padding: 9px 12px;
    font-size: 12px;
    margin-bottom: 12px;
  }
  .shop-tabs {
    display: inline-flex;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
    background: var(--surface-elev);
    margin-bottom: 12px;
  }
  .shop-tabs button {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 14px;
    cursor: pointer;
    font-family: inherit;
  }
  .shop-tabs button.active {
    background: var(--accent);
    color: #1a1a1a;
  }
  .shop-pack, .shop-product {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-elev);
    padding: 12px;
    margin-bottom: 10px;
  }
  .shop-pack {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .shop-pack b, .shop-product b { color: var(--text); }
  .shop-pack span, .shop-product span {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 3px;
  }
  .shop-product.locked { opacity: 0.75; }
  .shop-product-main {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
  }
  .shop-product-icon {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
  }
  .shop-product-icon img { width: 100%; height: 100%; object-fit: contain; }
  .shop-product-icon .box-icon-fallback { display: none; font-size: 24px; }
  .shop-product-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
  }
  .shop-point-rate {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 8px;
  }
  .shop-rates {
    border-top: 1px solid var(--line);
    padding-top: 8px;
  }
  .shop-rates summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 12px;
  }
  .shop-rate-note {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
    margin: 8px 0;
  }
  .shop-rate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 8px 0;
  }
  .shop-rate-table th, .shop-rate-table td {
    border: 1px solid var(--line);
    padding: 6px 8px;
    text-align: left;
  }
  .shop-rate-card-list {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
    margin-top: 5px;
  }
  .exchange-summary {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-elev);
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .exchange-summary b { color: var(--accent); }
  .exchange-summary span {
    color: var(--text-muted);
    font-size: 12px;
    flex: 1 1 280px;
  }
  .exchange-rarity {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-elev);
    padding: 10px;
    margin-bottom: 8px;
  }
  .exchange-rarity summary {
    cursor: pointer;
    color: var(--text);
    font-weight: 600;
  }
  .exchange-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 10px;
  }
  .mock-payment-panel { max-width: 440px; }
  .billing-confirm-summary { flex-direction: column; gap: 4px; }
  .billing-history-row { flex-direction: column; gap: 2px; margin-bottom: 8px; }
  .mock-payment-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-elev);
    padding: 12px;
    margin-bottom: 12px;
    color: var(--text);
  }

/* ========================================================================
   ☰メニュー・現在地切替・戦闘ログフィード（ユーザー要望 2026-07-04）
   ======================================================================== */

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-elev, rgba(255,255,255,0.05));
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 8px;
  color: var(--text, #e8e8f0);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.menu-item:hover { border-color: var(--accent, #efb861); color: var(--accent, #efb861); }
.menu-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; font-size: 20px; text-align: center; flex-shrink: 0; }
.menu-icon .icon-svg { width: 22px; height: 22px; border-radius: 4px; background: #222d32; color: #d9b63b; }

.base-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface-elev, rgba(255,255,255,0.05));
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 8px;
}
.base-row.current { border-color: var(--accent, #efb861); }
.base-label { font-size: 13px; }
.base-actions { display: flex; gap: 6px; flex-shrink: 0; }
/* スマホ幅では「ここを現在地にする」が枠外へはみ出すため、ボタンを行の下へ折り返す */
.base-row { flex-wrap: wrap; }
.base-actions { flex-wrap: wrap; }

.battle-feed {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 8px;
  width: min(560px, 60vw);
  background: color-mix(in srgb, var(--surface, #14172a) 88%, transparent);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 10px;
  overflow: hidden;
  z-index: 40;
  backdrop-filter: blur(4px);
}
.battle-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim, #9aa0b8);
  cursor: pointer;
  user-select: none;
}
.battle-feed-toggle {
  background: none;
  border: none;
  color: var(--text-dim, #9aa0b8);
  font-size: 12px;
  cursor: pointer;
}
.battle-feed-list { max-height: 128px; overflow-y: auto; }
.battle-feed.collapsed .battle-feed-list { display: none; }
.battle-feed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 10px;
  background: none;
  border: none;
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  color: var(--text, #e8e8f0);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.battle-feed-item:hover { background: rgba(255,255,255,0.06); }
.bf-time { color: var(--text-dim, #9aa0b8); flex-shrink: 0; }
.bf-outcome { font-weight: 700; flex-shrink: 0; }
.bf-outcome.win { color: #6fd18a; }
.bf-outcome.lose { color: #ff8080; }
.bf-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.battle-feed-empty { padding: 8px 10px; font-size: 12px; color: var(--text-dim, #9aa0b8); }

@media (max-width: 640px) {
  .resource-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    max-width: calc(100% - 16px);
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 4px 6px;
    padding: 5px 6px;
    font-size: 10px;
  }

  .controls {
    top: 58px;
    max-height: calc(100% - 184px);
    width: 48px;
    gap: 4px;
  }
  .controls .ctrl-group { padding: 3px; gap: 3px; }
  .controls .ctrl-btn { min-width: 40px; width: 40px; min-height: 40px; padding: 5px; font-size: 0; }
  .controls .ctrl-btn .icon-svg, .controls .ctrl-btn .icon-img { font-size: initial; }
  .selection-panel .hint, footer .hint, .map-hint { display: none !important; }

  .resource-bar .res-item,
  .resource-bar .res-item-player,
  .resource-bar .res-item-clickable {
    min-height: 32px;
    flex: 0 1 auto;
    justify-content: center;
  }

  .resource-bar .res-item-player {
    padding-inline: 6px;
  }

  .resource-bar .res-item-clickable {
    padding-inline: 5px;
  }

  .selection-panel {
    top: 82px;
    left: 116px;
    right: 8px;
    width: auto;
    min-width: 0;
    max-height: calc(100% - 240px);
    overflow-y: auto;
    padding: 10px 12px;
    z-index: 30;
  }

  .path-panel {
    left: 8px;
    right: 8px;
    bottom: 124px;
    max-width: none;
  }

  .battle-feed {
    left: 126px;
    right: 8px;
    bottom: 8px;
    transform: none;
    width: auto;
    max-height: 150px;
  }

  .battle-feed-list {
    max-height: 112px;
  }
}

/* ========================================================================
   城内・拠点内画面
   ======================================================================== */
.base-interior-inner {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  width: min(920px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.base-interior-body {
  padding: 18px;
  overflow-y: auto;
}
.base-interior-art {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #10131f;
  margin-bottom: 12px;
}
.interior-art-svg,
.interior-art-img {
  display: block;
  width: 100%;
  height: auto;
}
.base-interior-summary {
  display: grid;
  grid-template-columns: minmax(80px, auto) 1fr minmax(120px, auto);
  gap: 8px;
  margin-bottom: 14px;
}
.base-interior-summary div {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  min-width: 0;
}
.base-interior-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.base-interior-summary b {
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.base-interior-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.base-facility-btn {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-elev);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
}
.base-facility-btn:hover {
  border-color: var(--accent);
  background: rgba(239, 184, 97, 0.08);
}
.base-facility-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.base-facility-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 22px;
}
.base-facility-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.base-facility-main b {
  font-size: 14px;
  color: var(--text);
}
.base-facility-main small {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
@media (max-width: 640px) {
  .base-interior-body { padding: 12px; }
  .base-interior-summary { grid-template-columns: 1fr; }
  .base-interior-grid { grid-template-columns: 1fr; }
}

/* ========================================================================
   ユニット一覧・ユニット設定
   ======================================================================== */
.unit-modal-inner {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  width: min(1040px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.unit-edit-inner { width: min(1120px, 96vw); }
.unit-modal-body {
  padding: 16px;
  overflow-y: auto;
  min-width: 0;
}
.unit-list-summary,
.unit-edit-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-elev);
  padding: 10px 12px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.unit-edit-summary {
  grid-template-columns: minmax(190px, 1fr) minmax(160px, auto) minmax(120px, auto);
}
.unit-list-summary b,
.unit-edit-summary b { color: var(--text); }
.unit-edit-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.unit-over { color: #ff8080 !important; }
.unit-synergy-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-elev);
  color: var(--text);
  font-size: 12px;
  padding: 9px 12px;
  margin: -2px 0 12px;
}
.unit-synergy-line { line-height: 1.5; }
.unit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.unit-row {
  display: grid;
  /* スロット列を中身の幅にして所属/状況/コストをスロットのすぐ右へ寄せる（1.2fr だとカード中央に浮いた） */
  grid-template-columns: max-content minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-elev);
  padding: 12px;
}
.unit-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.unit-row-name {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unit-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.unit-row-slots {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  gap: 8px;
}
.unit-thumb,
.unit-card-large {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
}
.unit-thumb {
  width: 54px;
  height: 74px;
  font-size: 11px;
}
.unit-thumb.filled,
.unit-card-large.filled { border-style: solid; }
/* カード個体（設計書2026-09-03 2.1節）: サムネイル右下のレベル表示 */
.unit-thumb,
.unit-card-large { position: relative; }
.unit-thumb-level {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  pointer-events: none;
}
.unit-thumb img,
.unit-card-large img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.unit-card-large {
  width: 132px;
  height: 190px;
  min-height: 190px;
  flex-shrink: 0;
  font-size: 14px;
}
.unit-row-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
  align-self: start;
}
.unit-row-meta span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
}
.unit-row-meta b {
  display: block;
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.unit-row-actions,
.unit-slot-actions,
.unit-prod-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.unit-new-btn {
  width: 100%;
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-elev);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
}
.unit-new-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.unit-reason,
.unit-note {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}
.unit-slot-editor {
  display: grid;
  gap: 12px;
}
.unit-slot-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-elev);
  padding: 12px;
  min-width: 0;
}
.unit-slot-info { min-width: 0; }
.unit-slot-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.unit-slot-title b {
  color: var(--text);
  font-size: 15px;
}
.unit-qty {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.unit-qty b { color: var(--accent); }
.unit-slot-level {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 11px;
}
.unit-picker-card[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.unit-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.unit-stats span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
}
.unit-production-controls,
.unit-producing {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  margin-bottom: 10px;
}
.unit-production-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.unit-target-input,
.unit-base-select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
}
.unit-target-input { width: 96px; }
.unit-cost-preview {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.unit-picker-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-elev);
  padding: 12px;
}
.unit-card-large .card-face-illustration, .unit-thumb .card-face-illustration { object-fit: cover; object-position: center; }
.filter-chip.primary { background: var(--accent); border-color: var(--accent); color: #17130b; font-weight: 700; }
.skill-raw-details { margin-top: 7px; color: var(--text-muted); font: 10px/1.5 var(--font-mono); }
.skill-raw-details summary { cursor: pointer; color: var(--text-dim); font-family: var(--font-body); }
#territory-unit-picker-body { display: block; width: 100%; box-sizing: border-box; }
#territory-unit-picker-body > p { width: 100%; }
.battle-slot-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.battle-slot-face { width: 34px; height: 51px; flex: 0 0 34px; }
.battle-slot-face .card-face-name, .battle-slot-face .card-face-stats,
.battle-slot-face .card-face-faction, .battle-slot-face .card-face-skill-icons,
.battle-slot-face .card-face-cost-badge { display: none; }
.battle-slot-name { min-width: 0; }
.battle-slot-rarity { font-weight: 700; }
.battle-slot-rarity.rarity-c { color: #b4bac8; }
.battle-slot-rarity.rarity-uc { color: #7ed58d; }
.battle-slot-rarity.rarity-r { color: #64a9ff; }
.battle-slot-rarity.rarity-sr { color: #c58aff; }
.battle-slot-rarity.rarity-ssr { color: #ff9ed2; }
.battle-slot-rarity.rarity-ur { color: #ffd35f; }
.battle-slot-rarity.rarity-lr { color: #7ee8c8; }
.card-item.unowned .card-image { opacity: .35; filter: grayscale(1); }
.card-item.unowned .name, .card-item.unowned .faction { opacity: 1; color: var(--text); }
.card-owned-badge { max-width: calc(100% - 12px); box-sizing: border-box; }
.tower-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tower-floor.locked { opacity: .7; color: var(--text-dim); }
.tower-deploy-btn, [data-tower-deploy] { background: var(--accent) !important; color: #17130b !important; border-color: var(--accent) !important; font-weight: 700; }
.key-chip, kbd:not(.help-key) { white-space: nowrap; }
.battle-slot-main { width: 100%; }
/* 共通 .card-face（後方で定義）の min-width/min-height:100% が width より優先されるため、詳細度を上げて 0 に戻す（未指定だと757pxまで広がった） */
.card-face.battle-slot-face { width: 64px; min-width: 0; min-height: 0; height: auto; aspect-ratio: 2 / 3; flex: 0 0 64px; overflow: hidden; }
.battle-slot-face > * { max-width: 100%; }
.battle-slot-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.tower-ranking-tabs { display:flex; gap:2px; padding:2px; width:max-content; background:var(--surface); border:1px solid var(--line); border-radius:6px; margin-bottom:10px; }
.tower-ranking-tabs .ranking-tab { border:0; margin:0; }
.tower-ranking-tabs .ranking-tab[aria-selected="true"] { background:var(--accent); color:#17130b; }
.tower-ranking-table { display:grid; gap:2px; font-size:12px; }
.tower-ranking-row { display:grid; grid-template-columns:3em minmax(8em,1fr) minmax(4em,.5fr) minmax(6em,.7fr); gap:8px; align-items:center; padding:6px 8px; border-radius:4px; background:var(--surface-elev); }
.tower-ranking-row .damage { text-align:right; font-variant-numeric:lining-nums tabular-nums; }
.tower-ranking-row.own-ranking-row { outline:1px solid var(--accent); background:rgba(239,184,97,.1); }
.tower-ranking-empty { color:var(--text-muted); font-size:12px; padding:8px 2px; }
.tower-ranking-own { margin-top:10px; padding-top:8px; border-top:1px solid var(--line); color:var(--text-dim); font-size:12px; }
.guild-emblem-list-slot { width:40px; height:40px; flex:0 0 40px; display:grid; place-items:center; overflow:hidden; }
.guild-emblem-list-slot .guild-emblem-empty { display:grid !important; place-items:center; width:40px; height:40px; padding:2px !important; font-size:9px; line-height:1.15; }
.quest-reward { font-size:11px !important; color:var(--text-muted) !important; }
.unit-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-size: 12px;
}
.unit-picker-head b { color: var(--text); }
.unit-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.unit-picker-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  min-width: 0;
}
.unit-picker-card:hover { border-color: var(--accent); }
.unit-picker-card b {
  font-size: 12px;
  overflow-wrap: anywhere;
}
.unit-picker-card span {
  color: var(--text-muted);
  font-size: 11px;
}
.settings-btn.danger { color: #ff9a9a; }

@media (max-width: 700px) {
  .unit-modal-inner,
  .unit-edit-inner {
    width: 96vw;
    max-height: 92vh;
  }
  .unit-modal-body { padding: 10px; }
  .unit-list-summary,
  .unit-edit-summary,
  .unit-row,
  .unit-slot-panel {
    grid-template-columns: 1fr;
  }
  .unit-row-actions { justify-content: flex-start; }
  .unit-row-slots { grid-template-columns: repeat(3, 48px); }
  .unit-thumb { width: 48px; height: 66px; }
  .unit-card-large {
    width: min(180px, 100%);
    min-height: 230px;
    justify-self: center;
  }
  .unit-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .unit-picker-head { flex-direction: column; gap: 4px; }
  .unit-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============ Card Face（カード面合成） ============ */
.card-face {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #232748 0%, #1a1d33 100%);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 100%;
}

.card-face-illustration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.card-face-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1d33 0%, #0f1220 100%);
  color: var(--text-mute);
  font-size: 11px;
  text-align: center;
  padding: 8px;
  z-index: 2;
}

.card-face-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.card-face-badge {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  width: 16.5%;
  aspect-ratio: 1 / 1;
}

.card-face-rarity-badge {
  top: 2.85%;
  left: 2.75%;
}

.card-face-rarity-badge img,
.card-face-cost-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card-face-rarity-badge span,
.card-face-cost-badge span {
  position: absolute;
  font-weight: 600;
  font-size: 15px;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  color: var(--accent);
}

.card-face-cost-badge {
  top: 2.85%;
  right: 2.75%;
}

.card-face-cost-badge span {
  color: #fff;
}

/* カード個体のレベルバッジ・EXPバー（設計書2026-09-03 2.1節）。
   既定はインライン。カード面の中では絶対配置に切り替える */
.card-level-badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1.2;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-family: var(--font-mono);
}

/* コストバッジ（top 2.85% / 右上）の直下に置いて重なりを避ける */
.card-face .card-level-badge {
  position: absolute;
  top: 21%;
  right: 2.75%;
  text-shadow: 1px 1px 2px #000;
  z-index: 11;
}

/* EXP 0%（<i> の幅が 0）でもバーの枠が見えるよう、トラックに境界線と明るい背景を置く */
.card-exp-bar {
  height: 4px;
  min-height: 4px;
  margin-top: 3px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-sizing: border-box;
  border-radius: 2px;
  overflow: hidden;
}

/* カード面ではスペックパネル（top 82%）の直上に重ねる */
.card-face .card-exp-bar {
  position: absolute;
  top: 78.5%;
  left: 7%;
  right: 7%;
  margin-top: 0;
  z-index: 9;
}

.card-exp-bar i {
  display: block;
  height: 100%;
  background: #6c6;
}

.card-face-badge.missing-part {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
}

.card-face-skill-icons {
  position: absolute;
  bottom: 41%; /* イラスト窓下端62%の内側（共通レイアウトテンプレート、実描画で確定） */
  left: 9%;      /* フレームの枠飾りを避けてイラスト窓の内側に */
  width: 11%;   /* カード幅相対（絶対配置なので%は.card-face基準） */
  display: flex;
  flex-direction: column-reverse; /* 窓の中を上方向へ積み上げ（1〜2個とも窓内に収まる） */
  gap: 2px;
  z-index: 8;
}

.card-face-skill-icon {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%; /* コイン風の控えめな丸台座 */
  overflow: hidden;
}

.card-face-skill-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
  display: block;
}

.card-face-faction {
  position: absolute;
  top: 61.5%;
  left: 15%;
  right: 15%;
  height: 5%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  text-shadow: 1px 1px 2px #000, -1px -1px 2px #000;
  line-height: 1.1;
  z-index: 8;
}

.card-face-name {
  position: absolute;
  top: 67.5%;  /* 名前プレート（共通レイアウトテンプレート、実描画で確定） */
  height: 10%;
  left: 12%;   /* プレート幅 x 12〜88% に一致 */
  right: 12%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--font-display);
  font-size: var(--name-fs, 12px);
  font-size: min(var(--name-fs, 12px), calc(72cqw / var(--name-len, 8)));
  font-weight: 600;
  color: var(--text);
  text-shadow: 1px 1px 2px #000, -1px -1px 2px #000;
  line-height: 1.2;
  z-index: 8;
}

.card-face-angel {
  --accent: #f2d982;
  --text-dim: #f7efd0;
}

.card-face-beast {
  --accent: #d9953e;
  --text-dim: #f0c27a;
}

.card-face-demon {
  --accent: #d95a52;
  --text-dim: #f0a09a;
}

.card-face-dragon {
  --accent: #e34e3e;
  --text-dim: #f4a08e;
}

.card-face-god {
  --accent: #e7c75d;
  --text-dim: #c9d8ff;
}

.card-face-machina {
  --accent: #65c8dd;
  --text-dim: #b6e6ef;
}

.card-face-primordial {
  --accent: #d4b9ff;
  --text-dim: #d9f4ff;
}

.card-face-spirit {
  --accent: #76c878;
  --text-dim: #bfe6bd;
}

.card-face-undead {
  --accent: #76d8d4;
  --text-dim: #c7f1ec;
}

/* フレームごとの名前プレート描画位置差の個別調整（実測 2026-07-05） */
.card-face-god .card-face-name { top: 64%; }
.card-face-spirit .card-face-name { top: 67%; }
.card-face-demon .card-face-name { top: 66.5%; }
.card-face-angel .card-face-name { top: 64.5%; }

.card-face-stats {
  position: absolute;
  top: 82%;    /* スペックパネル（共通レイアウトテンプレート、実描画で確定） */
  height: 13%;
  left: 7%;    /* パネル幅 x 7〜93% に一致 */
  right: 7%;
  overflow: hidden;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.6));
  padding: 2px 4px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-content: center;
  gap: 2px;
  z-index: 8;
  /* 明色フレーム（angel の大理石等）でも読めるよう黒ハロー縁取り */
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 0 1px rgba(0, 0, 0, 0.9);
}

.card-face-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--accent);
}

.card-face-stat-label {
  color: var(--text-dim); /* --text-mute では明色パネル上で不可視のため明度アップ */
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-face-stat b {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

/* Catalog variant（小） */
.card-face-catalog {
  width: 100%;
  max-width: 120px;
  --name-fs: 10px;
  font-size: 10px;
}

.card-face-catalog .card-face-stat {
  font-size: 8px;
}

.card-face-catalog .card-face-stat-label {
  font-size: 7px;
}

.card-face-catalog .card-face-faction {
  font-size: 8px;
}

.card-face-catalog .card-face-stat b {
  font-size: 10px;
}

.card-face-catalog .card-face-rarity-badge span,
.card-face-catalog .card-face-cost-badge span {
  font-size: 12px;
}

/* Detail variant（大） */
.card-face-detail {
  width: 100%;
  max-width: 280px;
  --name-fs: 16px;
  font-size: 13px;
}

.card-face-detail .card-face-stat {
  font-size: 11px;
}

.card-face-detail .card-face-stat-label {
  font-size: 9px;
}

.card-face-detail .card-face-stat b {
  font-size: 14px;
}

.card-face-detail .card-face-rarity-badge span,
.card-face-detail .card-face-cost-badge span {
  font-size: 24px;
}

/* Compare variant（中） */
.card-face-compare {
  width: 100%;
  max-width: 160px;
  --name-fs: 12px;
  font-size: 11px;
}

.card-face-compare .card-face-stat {
  font-size: 9px;
}

.card-face-compare .card-face-stat-label {
  font-size: 8px;
}

.card-face-compare .card-face-stat b {
  font-size: 11px;
}

.card-face-compare .card-face-rarity-badge span,
.card-face-compare .card-face-cost-badge span {
  font-size: 15px;
}

/* Empty state */
.card-face-empty {
  background: linear-gradient(135deg, #1a1d33 0%, #0f1220 100%);
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-face-empty .card-face-fallback {
  position: static;
  background: none;
  display: flex;
}

/* ---- お問い合わせ（M-15b、prototype-support.js） ----
   設定画面と同じトークン・同じ .settings-* クラスを再利用し、
   ここではリスト表示に必要な最小限のスタイルだけを足す。 */
.support-modal select,
.support-modal textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 12px;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  margin-bottom: 8px;
}
.support-modal textarea { resize: vertical; }
.support-error {
  background: rgba(255, 100, 100, 0.12);
  border-left: 3px solid #ff6464;
  color: #ffb0b0;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.support-ticket {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--surface-elev);
}
.support-ticket-head {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.support-ticket-status { color: var(--accent-dim); }
.support-ticket-date { margin-left: auto; }
.support-ticket-body {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0 0 8px;
}
.support-reply {
  border-left: 3px solid var(--accent-dim);
  padding-left: 10px;
  font-size: 13px;
  line-height: 1.6;
}
.support-reply p { margin: 4px 0 0; white-space: pre-wrap; }

/* 通常高の画面では全ボタンを表示し、短い画面だけスクロールを退避策にする。 */
@media (max-height: 799px) {
  .controls {
    max-height: calc(100% - 184px);
    overflow-y: auto;
  }
}
.billing-limit-band {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #d89b35;
  border-radius: 8px;
  background: rgba(216, 155, 53, 0.18);
  color: #ffe2a1;
  font-weight: 700;
}

.shop-quantity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.shop-quantity output {
  min-width: 2ch;
  text-align: center;
  font-weight: 700;
}

.billing-disabled {
  opacity: 0.55;
  filter: grayscale(1);
  cursor: not-allowed;
}

/* 規約文書ビューア（prototype-auth.js openLegalDocument）。同意モーダルより前面に出す */
.legal-doc-modal { z-index: 310; }
/* タイトル画面（.title-screen z-index:200）からも開くため、その前面に出す。ログイン（300）・規約（310）・確認（350）より下 */
#notices-modal { z-index: 250; }
.legal-doc-modal .catalog-inner { max-width: 760px; }
.legal-doc-body { font-size: 13px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.legal-doc-heading { font-weight: 700; margin-top: 12px; }
.legal-doc-h1 { font-size: 17px; }
.legal-doc-h2 { font-size: 15px; }

/* 主操作ボタン。settings-btn primary は16か所で使われていたが、スタイル定義が無く通常ボタンと同じ見た目だった */
.settings-btn.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
.settings-btn.primary:disabled { opacity: .45; }
.confirm-dialog-modal { z-index: 350; }
.confirm-dialog-inner { width: min(420px, calc(100vw - 32px)); }
.confirm-dialog-body { padding: 16px; }
.confirm-dialog-message { margin: 0 0 18px; line-height: 1.7; overflow-wrap: anywhere; }
.confirm-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-dialog-actions .settings-btn.primary.danger { background: #b93a3a; border-color: #e06060; color: #fff; }
.own-ranking-row { color: var(--accent); font-weight: 600; }

/* 2026-10-01 pass 2: native controls and remaining polish. Kept at EOF so it wins the cascade. */
.gold-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.styled-checkbox { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.styled-checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.terms-consent-modal .catalog-inner { max-width: 520px; }
.birthdate-selects { border: 0; margin: 0 0 12px; padding: 0; display: flex; gap: 8px; align-items: end; }
.birthdate-selects legend { width: 100%; margin-bottom: 8px; }
.birthdate-selects select,
.guild-plan-input { flex: 1 1 180px; min-width: 0; background: var(--surface-elev); color: var(--text); border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px; font: inherit; color-scheme: dark; }
.birthdate-selects select { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.visually-hidden-file { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.guild-file-label { cursor: pointer; }
.guild-file-name { color: var(--text-muted); font-size: 12px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legal-doc-body { white-space: normal; }
.legal-doc-spacer { height: .75em; }
.legal-doc-note { margin: 8px 0; padding: 8px 10px; border-left: 3px solid var(--line-strong); color: var(--text-muted); background: var(--surface-elev); }
.legal-doc-bullet { padding-left: 1.2em; position: relative; }
.legal-doc-bullet::before { content: '•'; position: absolute; left: .25em; color: var(--accent); }
.legal-doc-table-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--line); border-bottom: 0; }
.legal-doc-table-row:last-child { border-bottom: 1px solid var(--line); }
.legal-doc-table-row > span { padding: 6px 8px; border-right: 1px solid var(--line); }
.legal-doc-table-row > span:last-child { border-right: 0; }
.card-face.box-result-card-face { width: 96px; min-width: 0; min-height: 0; }
.box-reward-card { min-width: 112px; }
.dm-folder-tabs { display: flex; gap: 5px; margin-bottom: 10px; }
.dm-folder-tabs .settings-btn { padding: 4px 9px; font-size: 11px; opacity: .82; }
.shop-quantity .settings-btn { width: 38px; min-width: 38px; padding-inline: 0; }
.shop-product-main { align-items: center; }
.shop-product-main .box-icon.shop-product-icon { margin: 0; }
.outpost-action-compact { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outpost-set-base-btn { min-width: max-content; white-space: nowrap; }
.offline-rewards-footer { padding: 12px 20px 20px; display: flex; justify-content: flex-end; }
.body-latin { font-family: var(--font-body); }

@media (max-width: 640px) {
  /* PC向けキーヒントの footer は3行に折り返して地図を狭めるため隠す（body で footer{display:flex} より詳細度を上げる） */
  body footer { display: none; }
  .resource-bar {
    height: 42px;
    box-sizing: border-box;
    gap: 2px;
    padding: 4px;
    overflow-x: hidden;
    scrollbar-width: none;
  }
  .resource-bar::-webkit-scrollbar { display: none; width: 0; height: 0; }
  .resource-bar .res-item { min-height: 32px; gap: 2px; flex: 1 1 0; min-width: 0; font-size: 9px; }
  .resource-bar #res-season,
  .resource-bar #res-season-countdown,
  .resource-bar .res-cap { display: none; }
  .resource-bar .res-icon { flex: 0 0 auto; }
  .controls { top: 58px; width: 42px; }
  .controls .ctrl-group { width: 42px; box-sizing: border-box; }
  .controls .ctrl-btn { width: 34px; min-width: 34px; min-height: 36px; }
  .controls .zoom-row { gap: 2px; }
  .controls .zoom-row .ctrl-btn { width: 17px; min-width: 17px; padding: 0; font-size: 16px; color: var(--text); }
  /* 選択クリア（✕）も文字だけで描くボタン。上の font-size: 0 で消えていた（2026-10-01 実機確認） */
  .controls #btn-clear-path { font-size: 16px; color: var(--text); }
  .battle-feed { left: 126px; }
}

/* 小さなカード面（64px / 96px）: レア度バッジの文字が15px固定ではみ出し、能力値の行も収まらない。
   シミュレーターは名前の横にレア度を文字で出しているのでバッジを隠し、宝箱結果は能力値とスキルを省く */
.battle-slot-face .card-face-rarity-badge { display: none; }
.card-face.box-result-card-face .card-face-stats,
.card-face.box-result-card-face .card-face-skill-icons { display: none; }
.card-face.box-result-card-face .card-face-rarity-badge span,
.card-face.box-result-card-face .card-face-cost-badge span { font-size: 10px; }

/* 伏兵の送り先パネルはカードの4番目の子。1列目に入ると列幅を押し広げて所属列が横にずれたため全幅の行にする */
.unit-row > .garrison-picker { grid-column: 1 / -1; }

/* 滞在ユニット一覧の「退却」は .tile-action-btn の flex:1 で行幅いっぱいに伸びていた。ユニット名の右に詰めて置く */
.tile-action-row > .garrison-recall-btn { flex: 0 0 auto; margin-left: auto; }
/* 構造化戦闘ログ再生（仕様5.4 / 17.1） */
.battle-replay-inner { max-width: 760px; }
.battle-replay-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-height: 88px; }
.battle-replay-side-label { color: var(--text-muted); font-size: 12px; margin: 5px 0; }
.battle-replay-slot { position: relative; min-width: 0; padding: 10px; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; background: rgba(0,0,0,.2); transition: opacity .2s, transform .2s, box-shadow .2s; }
.battle-replay-slot.empty { visibility: hidden; }
.battle-replay-slot.dead { opacity: .35; }
.battle-replay-slot.active { box-shadow: 0 0 16px var(--accent); }
.battle-replay-slot.hit { animation: battle-replay-hit .22s ease-in-out; }
.battle-replay-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.battle-replay-count { font-weight: 700; margin-top: 5px; }
.battle-replay-bar { height: 5px; margin-top: 6px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.battle-replay-bar span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.battle-replay-delta { position: absolute; right: 8px; top: 28px; color: #ff8080; font-weight: 800; animation: battle-replay-float .45s ease-out both; }
.battle-replay-caption { min-height: 48px; margin: 12px 0; padding: 10px; text-align: center; background: rgba(0,0,0,.18); border-radius: 8px; }
.battle-replay-result { min-height: 28px; text-align: center; font-size: 20px; font-weight: 800; }
.battle-replay-result.win { color: var(--success); }
.battle-replay-result.lose { color: var(--danger); }
.battle-replay-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 14px; }
.battle-log-replay-action { margin: 10px 0; text-align: center; }
@keyframes battle-replay-hit { 50% { transform: translateX(5px); } }
@keyframes battle-replay-float { to { transform: translateY(-18px); opacity: 0; } }
@media (max-width: 560px) {
  .battle-replay-row { gap: 5px; }
  .battle-replay-slot { padding: 7px 5px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .battle-replay-slot, .battle-replay-bar span, .battle-replay-slot.hit, .battle-replay-delta { animation: none !important; transition: none !important; }
}
