/* ═══════════════════════════════════════════════════════════════════
   Ronin: The Last Fortress — Styles
   Ink wash (suibokuga) aesthetic · Sengoku clan warfare
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Tokens ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Core palette */
  --bg:            #111110;
  --bg-paper:      #1a1916;
  --surface:       #242320;
  --surface-raised:#2e2d29;
  --fg:            #e8dcc8;
  --fg-bright:     #f5efe3;
  --fg-dim:        #b8a990;
  --muted:         #7a7060;
  --border:        #3a3530;
  --border-light:  #4a4540;

  /* Legacy aliases (keep for existing game classes) */
  --bg-primary:    #1a1410;
  --bg-secondary:  #242320;
  --bg-card:       #2e2d29;
  --text-primary:  #e8dcc8;
  --text-secondary:#7a7060;
  --gold:          #D4A017;
  --gold-dim:      rgba(212,160,23,0.15);
  --gold-glow:     rgba(212,160,23,0.35);
  --red-accent:    #FF2E2E;
  --border-dim:    #3a3530;

  /* Accent — Oda gold */
  --accent:        #D4A017;
  --accent-hover:  #e8b42a;
  --accent-dim:    rgba(212,160,23,0.15);
  --accent-glow:   rgba(212,160,23,0.35);

  /* Clan colors */
  --takeda:  #FF2E2E;
  --hojo:    #3768A7;
  --uesugi:  #478F3D;
  --oda:     #D4A017;
  --shimazu: #7228A4;
  --clan-takeda:   #FF2E2E;
  --clan-hojo:     #3768A7;
  --clan-uesugi:   #478F3D;
  --clan-oda:      #D4A017;
  --clan-shimazu:  #7228A4;

  /* Typography */
  --font-display:  'Cinzel', 'Georgia', 'Times New Roman', serif;
  --font-body:     -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  /* Spacing */
  --sp-xs:   4px;
  --sp-sm:   8px;
  --sp-md:   16px;
  --sp-lg:   24px;
  --sp-xl:   40px;
  --sp-2xl:  64px;
  --sp-3xl:  96px;

  /* Radii */
  --r-sm:  4px;
  --r-md:  8px;
  --r-lg:  12px;

  /* Card dimensions */
  --card-w: 80px;
  --card-h: 112px;
  --card-radius: 6px;
  --card-gap: 8px;
}

html, body {
  width: 100%; height: 100dvh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}
#app {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* ── Ink Wash Background ───────────────────────────────────────── */
.ink-wash-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
}
.menu-bg-image {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: url('assets/ronin_bg.webp') center center / cover no-repeat;
  background-position: center 30%;
}

/* ── Animations ────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 15px var(--accent-dim); }
  50%      { box-shadow: 0 0 30px var(--accent-glow); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Screens ───────────────────────────────────────────────────── */
.screen {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

/* ── Main Menu ─────────────────────────────────────────────────── */
.menu-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  z-index: 2;
  padding: max(env(safe-area-inset-top), 16px) 1rem max(env(safe-area-inset-bottom), 32px);
  overflow-y: auto;
}
.menu-title-block {
  text-align: center;
  animation: slideUp 0.8s ease forwards;
  position: relative;
  z-index: 3;
  margin-top: 8vh;
}
.menu-title-block h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow), 0 2px 4px rgba(0,0,0,0.6);
  line-height: 1.1;
  margin-bottom: var(--sp-sm);
}
.brush-line {
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: var(--sp-lg) auto;
}
.menu-title-block .subtitle {
  font-family: var(--font-display);
  font-size: clamp(0.7rem, 2vw, 1rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}
.menu-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  animation: fadeIn 1s ease 0.3s forwards;
  opacity: 0;
}
.menu-actions .btn {
  min-width: 220px;
}
.menu-actions-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
}

/* Join room panel */
.join-room-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  animation: slideUp 0.3s ease forwards;
  margin-top: var(--sp-md);
}
.join-room-panel.visible {
  display: flex;
}
.join-label {
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--muted);
}
.room-code-input {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  width: 240px;
  padding: var(--sp-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg-bright);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
}
.room-code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-dim);
}
.room-code-input::placeholder {
  color: var(--muted);
  letter-spacing: 0.2em;
  font-size: 0.9rem;
}
.menu-footer {
  position: fixed;
  bottom: var(--sp-lg);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  opacity: 0.5;
  z-index: 2;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-xl);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
  background: transparent;
  color: var(--fg);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 20px var(--accent-dim);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--bg);
  border-color: var(--accent-hover);
  box-shadow: 0 0 30px var(--accent-glow);
}
.btn-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-small {
  padding: var(--sp-sm) var(--sp-md);
  font-size: 0.8rem;
}
.btn-local { margin-top: var(--sp-sm); opacity: 0.7; }
.btn-local:hover { opacity: 1; }

/* ── Messages ──────────────────────────────────────────────────── */
.msg {
  min-height: 1.5rem;
  color: var(--red-accent);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 0.5rem;
}

/* ── Lobby ─────────────────────────────────────────────────────── */
.screen-lobby {
  gap: 1.2rem;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(env(safe-area-inset-top), 16px) 1rem max(env(safe-area-inset-bottom), 16px);
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  overflow-y: auto;
}
.room-code-display { text-align: center; }
.room-code {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--gold);
  letter-spacing: 0.4em;
  padding: var(--sp-md) var(--sp-xl);
  border: 2px dashed var(--gold-dim);
  border-radius: var(--r-md);
  margin: var(--sp-sm) 0;
  background: var(--surface);
  user-select: all;
  -webkit-user-select: all;
  cursor: pointer;
}
.hint { font-size: 0.85rem; color: var(--muted); }
.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 320px;
}
.lobby-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-dim);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 0.9rem;
}
.lobby-player.host { border-color: var(--gold-dim); }
.player-icon { font-size: 1.3rem; }

/* ── Game Screen ───────────────────────────────────────────────── */
.screen-game {
  height: 100dvh;
  justify-content: flex-start;
  padding: 0;
  --bg: #f5f1e8;
  --bg-paper: #ede8dd;
  --bg-card: #fff9ee;
  --fg: #1a1916;
  --muted: #7a7568;
  --border: #c8c2b5;
  --border-light: #d8d2c5;
  --surface: #ede8dd;
  --surface-raised: #fff9ee;
  --bg-secondary: #e0dbd0;
  background: #f5f1e8;
  color: #1a1916;
}
.game-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  width: 100%;
  flex-shrink: 0;
  font-size: 0.9rem;
}
.info-item {
  color: var(--fg);
}
.game-board {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
}

/* ── Hands ─────────────────────────────────────────────────────── */
.opponent-hand {
  display: flex;
  justify-content: center;
  gap: var(--card-gap);
  padding: var(--sp-sm) 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.player-hand {
  display: flex;
  justify-content: center;
  gap: var(--card-gap);
  padding: 0.6rem 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.hand-active .card { cursor: pointer; }
.player-hand:not(.hand-active) .card {
  opacity: 0.5;
  cursor: default;
}
.player-hand:not(.hand-active) .card:hover {
  transform: none;
  box-shadow: none;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  width: 60px;
  height: 85px;
  border-radius: var(--r-sm);
  border: 1px solid var(--card-color, var(--border-light));
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.card-selected {
  transform: translateY(-8px);
  box-shadow: 0 6px 20px var(--gold-glow);
  border-color: var(--gold) !important;
}

.card-back {
  background: var(--bg-secondary);
  border-color: var(--border);
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--muted);
}
.card-back:hover { transform: none; box-shadow: none; }

.card-strength {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--card-color, var(--gold));
  line-height: 1;
}
.card-clan {
  font-size: 0.6rem;
  color: var(--card-color, var(--gold));
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.card-unit {
  font-size: 0.55rem;
  color: var(--muted);
  margin-top: 1px;
}
.card-strength-bottom {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.7rem;
  color: var(--card-color, var(--gold));
  opacity: 0.7;
}

/* ── Frontier Cards (smaller) ──────────────────────────────────── */
.frontier-card {
  width: 52px;
  height: 32px;
  border-radius: 3px;
  border: 1px solid var(--card-color, var(--border-light));
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.65rem;
  flex-shrink: 0;
  transition: box-shadow 0.3s ease;
}
.frontier-card.last-played {
  box-shadow: 0 0 8px 3px var(--card-color, var(--gold)),
              0 0 16px 6px color-mix(in srgb, var(--card-color, var(--gold)) 40%, transparent);
  animation: lastPlayedPulse 1.5s ease-in-out infinite;
  z-index: 1;
}
@keyframes lastPlayedPulse {
  0%, 100% { box-shadow: 0 0 8px 3px var(--card-color, var(--gold)), 0 0 16px 6px color-mix(in srgb, var(--card-color, var(--gold)) 40%, transparent); }
  50% { box-shadow: 0 0 12px 5px var(--card-color, var(--gold)), 0 0 24px 10px color-mix(in srgb, var(--card-color, var(--gold)) 30%, transparent); }
}
.fc-strength {
  font-weight: bold;
  font-size: 0.85rem;
  color: var(--card-color, var(--gold));
}
.fc-clan { font-size: 0.7rem; }

/* ── Frontiers ─────────────────────────────────────────────────── */
.frontiers {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0.5rem;
  flex: 1;
  align-items: center;
  overflow-x: auto;
}
.frontier {
  min-width: 60px;
  max-width: 80px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: 1px dashed var(--border-dim);
  border-radius: var(--r-sm);
  padding: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.frontier:hover { background: rgba(212,160,23,0.05); border-color: var(--gold-dim); }
.frontier-side {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 50px;
  align-items: center;
}
.frontier-label {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.frontier-resolved { opacity: 0.6; pointer-events: none; }
.frontier-won-you { border-color: var(--gold); border-style: solid; }
.frontier-won-opp { border-color: var(--red-accent); border-style: solid; opacity: 0.5; }

/* ── Result Screen ─────────────────────────────────────────────── */
.screen-result { gap: 1.5rem; }
.result-title {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--gold);
  letter-spacing: 0.15em;
}
.result-subtitle {
  font-size: 1.1rem;
  color: var(--muted);
}
.result-frontiers {
  display: flex;
  gap: 8px;
  margin: 1rem 0;
}
.result-frontier {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  background: var(--surface);
}
.result-you { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.result-opp { background: rgba(255,46,46,0.15); border-color: var(--red-accent); color: var(--red-accent); }
.result-none { border-style: dashed; color: var(--muted); }
.result-score {
  display: flex;
  gap: 2rem;
  font-size: 1.1rem;
  color: var(--fg);
}
.result-buttons { display: flex; gap: 1rem; }

/* ── First Turn Overlay ────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.first-turn-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-2xl) var(--sp-xl);
  text-align: center;
  max-width: 400px;
}
.first-turn-content h2 {
  font-family: var(--font-display);
  color: var(--gold);
  margin-bottom: var(--sp-lg);
}
.first-turn-content p {
  margin: var(--sp-sm) 0;
  color: var(--fg);
}
.first-turn-result {
  font-size: 1.2rem;
  color: var(--gold);
  margin-top: var(--sp-md) !important;
}

/* ── Connecting Overlay ─────────────────────────────────────────── */
.connecting-content {
  text-align: center;
  color: var(--gold);
}
.connecting-content .spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

/* ── Game Toast ─────────────────────────────────────────────────── */
.game-toast {
  position: fixed;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  color: var(--fg);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  transition: bottom 0.3s ease;
  z-index: 200;
}
.game-toast.toast-visible { bottom: var(--sp-xl); }

/* ── Reconnecting Overlay ────────────────────────────────────────── */
.reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.reconnect-content {
  text-align: center;
  color: #eee;
}
.reconnect-text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-top: var(--sp-md);
  letter-spacing: 0.1em;
}
.reconnect-sub {
  font-size: 0.9rem;
  color: #999;
  margin-top: var(--sp-xs);
}
.reconnect-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #444;
  border-top: 3px solid var(--gold);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Formation Reference Bar ───────────────────────────────────── */
.formation-ref {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-top: 64px;
}
.formation-ref-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.formation-ref-cards {
  display: flex;
  gap: 3px;
}
.mini-card {
  width: 28px;
  height: 36px;
  border-radius: 3px;
  border: 1.5px solid var(--card-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  flex-shrink: 0;
}
.mc-val {
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--card-color);
}
.mc-clan {
  font-size: 0.5rem;
  font-weight: 600;
  line-height: 1;
}
.formation-ref-text {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.formation-ref-name {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
}
.formation-ref-desc {
  color: var(--muted);
  font-size: 0.5rem;
}
.formation-ref-gt {
  display: flex;
  align-items: center;
  color: var(--gold);
  font-weight: 700;
  font-size: 1.2rem;
  opacity: 0.6;
  padding: 0 2px;
}

/* ── Large screens: scale cards up 50% ─────────────────────────── */
@media (min-width: 901px) {
  .card {
    width: 90px;
    height: 128px;
  }
  .card-strength { font-size: 2.4rem; }
  .card-clan { font-size: 0.9rem; margin-top: 3px; }
  .card-unit { font-size: 0.8rem; margin-top: 2px; }
  .card-strength-bottom { font-size: 1rem; bottom: 4px; right: 6px; }
  .player-hand { gap: 10px; padding: 0.8rem 1.5rem; }
  .opponent-hand { gap: 8px; padding: 0.6rem 1.5rem; }
  .frontier-card {
    width: 76px;
    height: 48px;
    font-size: 0.95rem;
    gap: 6px;
    border-radius: var(--r-sm);
  }
  .fc-strength { font-size: 1.2rem; }
  .fc-clan { font-size: 1rem; }
  .frontier {
    min-width: 80px;
    max-width: 110px;
    min-height: 220px;
  }
  .frontier-label { font-size: 1rem; }
  .game-info { font-size: 1.2rem; gap: 2rem; }
  .formation-ref { gap: 20px; padding: 12px 16px; margin-top: 64px; }
  .mini-card { width: 40px; height: 52px; border-radius: var(--r-sm); gap: 2px; }
  .mc-val { font-size: 1.05rem; }
  .mc-clan { font-size: 0.65rem; }
  .formation-ref-name { font-size: 0.85rem; }
  .formation-ref-desc { font-size: 0.65rem; }
  .formation-ref-gt { font-size: 1.6rem; }
}

/* ── Mobile responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .frontier {
    min-width: 32px;
    max-width: 40px;
    min-height: 120px;
  }
  .frontier-card {
    width: 36px;
    height: 24px;
    font-size: 0.55rem;
  }
  .fc-strength { font-size: 0.7rem; }
  .fc-clan { display: none; }
  .frontier-label { font-size: 0.65rem; }
  .card {
    width: 48px;
    height: 68px;
  }
  .card-strength { font-size: 1.2rem; }
  .card-clan { font-size: 0.5rem; }
  .card-unit { font-size: 0.45rem; }
  .game-info { font-size: 0.8rem; gap: 1rem; }
  .result-title { font-size: 2rem; }
  .result-frontier { width: 34px; height: 34px; font-size: 0.9rem; }
  .formation-ref { gap: 6px; padding: 4px 6px; margin-top: 6px; }
  .mini-card { width: 22px; height: 28px; border-radius: 2px; }
  .mc-val { font-size: 0.6rem; }
  .mc-clan { font-size: 0.35rem; }
  .formation-ref-name { font-size: 0.5rem; }
  .formation-ref-desc { display: none; }
}

@media (max-height: 500px) {
  .frontier { min-height: 100px; }
  .card { width: 50px; height: 70px; }
}

/* ── Card hover effect for local mode ─────────────────────────── */
.screen-game.local-mode .player-hand .card {
  cursor: pointer;
  opacity: 1;
}

/* ── Shogun Selection Screen ───────────────────────────────────── */
.screen-shogun-select {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(env(safe-area-inset-top), 16px) 1rem max(env(safe-area-inset-bottom), 16px);
  position: relative;
  z-index: 2;
  overflow-y: auto;
}
.shogun-select-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--gold);
  margin-bottom: var(--sp-lg);
  letter-spacing: 0.12em;
}
.shogun-cards {
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
}
.shogun-card {
  width: 240px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}
.shogun-card:hover {
  border-color: var(--shogun-color, var(--accent));
  box-shadow: 0 0 25px rgba(212,160,23,0.2);
  transform: translateY(-4px);
}
.shogun-card-selected {
  border-color: var(--shogun-color, var(--accent)) !important;
  box-shadow: 0 0 30px var(--shogun-color, var(--accent-glow)) !important;
}
.shogun-portrait {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--shogun-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shogun-initial {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
}
.shogun-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--fg);
  text-align: center;
}
.shogun-ability-line {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  justify-content: center;
}
.shogun-emoji { font-size: 1.2rem; }
.shogun-ability-name {
  font-size: 0.85rem;
  color: var(--shogun-color, var(--accent));
  font-weight: 600;
}
.shogun-desc {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.shogun-select-status {
  margin-top: var(--sp-md);
  font-size: 0.9rem;
  color: var(--muted);
}
.shogun-select-status + button {
  margin-top: var(--sp-md);
}
#btn-confirm-shogun:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── In-Game Shogun Display ─────────────────────────────────────── */
.opponent-hand-area {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0.4rem 0.5rem 0.4rem 0.5rem;
}
.opponent-hand { flex: 1; }
.shogun-display-opp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  width: 60px;
}
.shogun-status-small {
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 1;
}
.player-hand-area {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-sm);
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 0.4rem 0.5rem 0.4rem 0.5rem;
}
.player-hand { flex: 1; }
.shogun-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  width: 60px;
}
.shogun-portrait-small {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--shogun-color, var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--surface-raised);
  flex-shrink: 0;
}
.shogun-emoji-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 0.6rem;
  background: var(--surface);
  border-radius: 50%;
  padding: 1px;
}
.shogun-name-small {
  font-size: 0.45rem;
  color: var(--muted);
  text-align: center;
  line-height: 1;
}
.btn-ability {
  font-family: var(--font-body);
  font-size: 0.5rem;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.btn-ability:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-ability:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-ability-used {
  text-decoration: line-through;
}
.shogun-tooltip {
  position: fixed;
  background: var(--surface-raised);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 0.7rem;
  width: 200px;
  max-width: 90vw;
  z-index: 300;
  pointer-events: none;
  line-height: 1.3;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ── Ambush / Ability Banner ────────────────────────────────────── */
.ambush-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--gold, #D4A017);
  color: #111110;
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  z-index: 150;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}
.ambush-banner.visible {
  opacity: 1;
}

/* ── Ability Target Mode ───────────────────────────────────────── */
.frontier-ability-target {
  border: 2px solid var(--gold) !important;
  box-shadow: 0 0 15px var(--gold-glow);
  background: var(--gold-dim);
  animation: abilityPulse 1s ease-in-out infinite;
}
@keyframes abilityPulse {
  0%, 100% { box-shadow: 0 0 10px var(--gold-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow); }
}
.card-ambush-selected {
  border-color: var(--gold) !important;
  box-shadow: 0 0 15px var(--gold-glow);
  transform: translateY(-6px);
}

/* ── Veiled (face-down) Frontier Cards ──────────────────────────── */
.frontier-card-veiled {
  background: var(--bg-secondary);
  border-color: var(--border);
  opacity: 0.8;
}
.frontier-card-veiled .fc-strength {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Desktop: larger shogun display ─────────────────────────────── */
@media (min-width: 901px) {
  .shogun-display { width: 80px; }
  .shogun-display-opp { width: 80px; }
  .shogun-portrait-small { width: 48px; height: 48px; }
  .shogun-name-small { font-size: 0.6rem; }
  .btn-ability { font-size: 0.65rem; padding: 4px 8px; }
  .shogun-initial { font-size: 2.8rem; }
  .shogun-portrait { width: 100px; height: 100px; }
  .shogun-status-small { font-size: 0.75rem; }
}