:root {
  /* Warm Alabaster & Minimal Hairline Surfaces */
  --bg-alabaster: #F8F7F4;
  --surface-card: #FFFFFF;
  --surface-subtle: #F4F2EC;
  --surface-hover: #EFECE5;
  --border-hairline: #E5E2DC;
  --border-strong: #CFC9BD;

  /* Typography */
  --text-primary: #1E2028;
  --text-secondary: #5A5F6D;
  --text-dim: #8C919E;

  /* Brand & Stone Accents */
  --accent-primary: #2B6CB0;
  --accent-primary-hover: #245A94;
  --accent-gold: #D98E26;
  --accent-gold-bg: #FFF6EA;
  --cobalt-base: #4C8EDA;
  --cobalt-dark: #2D68AD;

  /* 4-Category Pastel Tokens */
  --cat-defense-bg: #EDF5FF;
  --cat-defense-accent: #2B6CB0;
  --cat-defense-border: rgba(43, 108, 176, 0.28);

  --cat-attack-bg: #FFF0F0;
  --cat-attack-accent: #D64545;
  --cat-attack-border: rgba(214, 69, 69, 0.28);

  --cat-move-bg: #F4EFFE;
  --cat-move-accent: #6E47C9;
  --cat-move-border: rgba(110, 71, 201, 0.28);

  --cat-chaos-bg: #FFF6EA;
  --cat-chaos-accent: #C96A1B;
  --cat-chaos-border: rgba(201, 106, 27, 0.28);

  /* Elevation & Radius */
  --shadow-card: 0 6px 24px rgba(30, 32, 40, 0.05);
  --shadow-float: 0 12px 32px rgba(30, 32, 40, 0.11);
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-alabaster);
  color: var(--text-primary);
  font-family: 'Pretendard Variable', 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1460px;
  margin: 0 auto;
  padding: 12px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom ultra-slim scrollbar for internal sidebars */
.left-panel::-webkit-scrollbar,
.log-list::-webkit-scrollbar,
.nickname-card::-webkit-scrollbar {
  width: 5px;
}

.left-panel::-webkit-scrollbar-track,
.log-list::-webkit-scrollbar-track {
  background: transparent;
}

.left-panel::-webkit-scrollbar-thumb,
.log-list::-webkit-scrollbar-thumb {
  background: rgba(30, 32, 40, 0.14);
  border-radius: 999px;
}

/* Top Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.brand-stones {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
}

.app-title {
  margin: 0;
  font-size: 1.16rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.app-subtitle {
  margin: 1px 0 0;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

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

.meta-badge {
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cat-defense-accent);
  background: var(--cat-defense-bg);
  border: 1px solid var(--cat-defense-border);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-primary);
  color: #FFFFFF;
  border-color: var(--accent-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-hairline);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--surface-subtle);
}

.btn-bgm {
  color: var(--cat-chaos-accent);
  border-color: var(--cat-chaos-border);
  background: var(--cat-chaos-bg);
}

.btn-bgm:hover:not(:disabled) {
  background: #FDEBD2;
  border-color: rgba(201, 106, 27, 0.45);
}

.btn-bgm.is-muted {
  color: var(--text-dim);
  border-color: var(--border-hairline);
  background: var(--surface-subtle);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.78rem;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.72rem;
}

.btn-cancel-item {
  background: var(--cat-attack-bg);
  border: 1.5px solid var(--cat-attack-accent);
  color: var(--cat-attack-accent);
  font-weight: 800;
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 8px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-cancel-item.btn-sm {
  padding: 5px 10px;
  font-size: 0.76rem;
}

.btn-cancel-item:hover:not(:disabled) {
  background: var(--cat-attack-accent);
  color: #FFFFFF;
  transform: translateY(-1px);
}

.btn-link {
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link:hover {
  color: var(--accent-primary);
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.3;
  border-radius: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}

.btn-primary kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  color: #FFFFFF;
}

/* Main 3-Column Layout (Left: Status/Timer/Settings | Center: Board | Right: Inventory + Log) */
.main-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 336px;
  gap: 14px;
  align-items: start;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Desktop 100vh zero-scroll lock */
@media (min-width: 1121px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    overflow: hidden;
    padding: 10px 18px 12px;
    gap: 10px;
  }

  .main-layout {
    flex: 1;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
  }

  .left-panel {
    height: 100%;
    overflow-y: auto;
    padding-right: 3px;
  }

  .board-stage {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .right-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .right-panel .held-card {
    flex: 0 0 auto;
    min-height: 0;
    max-height: 48%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .right-panel .log-card {
    flex: 1 1 auto;
    min-height: 180px;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .right-panel .log-card.is-collapsed {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
  }

  .right-panel .log-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .right-panel .chat-pane {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .right-panel .chat-message-list {
    max-height: none;
  }
}

/* Board Stage */
.board-stage {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
}

.board-viewport {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10px;
}

.board-frame {
  position: relative;
  margin-top: 0;
  width: min(100%, 620px);
  aspect-ratio: 1 / 1;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-card);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

@media (min-width: 1121px) {
  .board-viewport {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    padding: 14px 4px 4px;
    container-type: size;
  }

  .board-frame {
    width: min(100cqw, 100cqh, 660px);
    height: min(100cqw, 100cqh, 660px);
  }
}

.board-frame.is-my-turn {
  border-color: rgba(43, 108, 176, 0.72);
  box-shadow:
    var(--shadow-card),
    0 0 0 2px rgba(76, 142, 218, 0.24),
    0 0 24px rgba(76, 142, 218, 0.16);
  animation: myTurnFramePulse 1.8s ease-in-out infinite;
}

@keyframes myTurnFramePulse {
  0%, 100% {
    box-shadow:
      var(--shadow-card),
      0 0 0 2px rgba(76, 142, 218, 0.22),
      0 0 18px rgba(76, 142, 218, 0.14);
  }
  50% {
    box-shadow:
      var(--shadow-card),
      0 0 0 3px rgba(76, 142, 218, 0.48),
      0 0 28px rgba(76, 142, 218, 0.26);
  }
}

.my-turn-tab {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--cat-defense-bg);
  border: 1px solid var(--cat-defense-accent);
  box-shadow: 0 4px 12px rgba(30, 32, 40, 0.12);
  color: var(--cat-defense-accent);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  animation: myTurnTabPop 0.14s ease-out;
}

@keyframes myTurnTabPop {
  from {
    opacity: 0.72;
    transform: translate(-50%, -3px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.my-turn-tab-dot {
  width: 11px;
  height: 11px;
}

#omokCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  border: 1px solid #DFDBD0;
}

#omokCanvas.is-disabled {
  cursor: default;
}

/* Item Target Prompt Banner (right above board) */
.item-prompt-banner {
  width: min(100%, 650px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-card);
  border: 2px solid var(--cat-defense-border);
  border-left-width: 5px;
  box-shadow: 0 6px 20px rgba(30, 32, 40, 0.12);
  pointer-events: auto;
  animation: promptDrop 0.18s ease-out;
}

.item-prompt-banner.has-choices {
  box-shadow:
    0 8px 24px rgba(30, 32, 40, 0.15),
    0 0 0 2px rgba(99, 102, 241, 0.16);
}

.item-prompt-banner.item-prompt-cat-defense {
  border-color: var(--cat-defense-accent);
  background: #F4F9FF;
}

.item-prompt-banner.item-prompt-cat-attack {
  border-color: var(--cat-attack-accent);
  background: #FFF6F6;
}

.item-prompt-banner.item-prompt-cat-move {
  border-color: var(--cat-move-accent);
  background: #F8F4FF;
}

.item-prompt-banner.item-prompt-cat-chaos {
  border-color: var(--cat-chaos-accent);
  background: #FFF9EE;
}

@keyframes promptDrop {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item-prompt-icon {
  font-size: 1.45rem;
  line-height: 1;
  flex-shrink: 0;
}

.item-prompt-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.item-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  padding-top: 8px;
  border-top: 1px dashed rgba(30, 32, 40, 0.16);
}

.laser-dir-btn {
  appearance: none;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--cat-attack-accent);
  background: #FFFFFF;
  color: #B91C1C;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.10);
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.laser-dir-btn:hover,
.laser-dir-btn.is-active {
  background: #FEE2E2;
  border-color: #B91C1C;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(185, 28, 28, 0.18);
}

.item-option-btn {
  appearance: none;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--cat-defense-border);
  background: #FFFFFF;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.item-option-btn:hover {
  background: var(--cat-defense-bg);
  border-color: var(--cat-defense-accent);
  color: var(--cat-defense-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(43, 108, 176, 0.16);
}

.item-option-btn.is-primary {
  background: var(--cat-move-accent);
  border-color: var(--cat-move-accent);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(110, 71, 201, 0.24);
}

.item-option-btn.is-primary:hover {
  background: #5B35B5;
  border-color: #5B35B5;
  color: #FFFFFF;
}

.item-option-btn.is-undo {
  background: #FFF1F2;
  border-color: rgba(214, 69, 69, 0.45);
  color: #B91C1C;
}

.item-option-btn.is-undo:hover {
  background: #FFE4E6;
  border-color: #DC2626;
  color: #991B1B;
}

/* Board-Center Spotlight Choice Overlay (tricolor_cycle, steal_item) */
.item-choice-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(244, 242, 236, 0.44);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: inherit;
  pointer-events: auto;
}

.item-choice-card {
  width: min(100%, 400px);
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid var(--border-strong);
  border-top-width: 5px;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: 0 18px 42px rgba(24, 28, 38, 0.22);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: promptDrop 0.18s ease-out;
}

.item-choice-card.item-prompt-cat-defense {
  border-color: var(--cat-defense-accent);
}

.item-choice-card.item-prompt-cat-attack {
  border-color: var(--cat-attack-accent);
}

.item-choice-card.item-prompt-cat-move {
  border-color: var(--cat-move-accent);
}

.item-choice-card.item-prompt-cat-chaos {
  border-color: var(--cat-chaos-accent);
}

.item-choice-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.item-choice-icon {
  font-size: 1.7rem;
  line-height: 1;
  flex-shrink: 0;
}

.item-choice-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.item-choice-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-primary);
}

.item-choice-desc {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.item-choice-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-choice-btn {
  appearance: none;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background: #F8FAFC;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.12s ease, border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.item-choice-btn:hover {
  background: var(--cat-defense-bg);
  border-color: var(--cat-defense-accent);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(43, 108, 176, 0.16);
}

.item-choice-btn.is-primary {
  background: #FFF7ED;
  border-color: var(--cat-chaos-accent);
}

.item-choice-btn.is-primary:hover {
  background: #FFEDD5;
  border-color: #B45309;
  box-shadow: 0 5px 14px rgba(201, 106, 27, 0.2);
}

.tricolor-preview-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.tricolor-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid rgba(15, 23, 42, 0.4);
}

.tricolor-dot.is-black {
  background: #1F242D;
}

.tricolor-dot.is-white {
  background: #F9F9F6;
}

.tricolor-dot.is-blue {
  background: #4C8EDA;
}

/* Pre-game Stone Color Card Draw Overlay */
.card-draw-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(244, 242, 236, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: inherit;
}

.card-draw-overlay.hidden {
  display: none;
}

.card-draw-modal {
  width: min(100%, 540px);
  padding: 16px 18px 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.98);
  border: 1.5px solid #CBD5E1;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  animation: promptDrop 0.2s ease-out;
}

.card-draw-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
  font-size: 0.72rem;
  font-weight: 800;
}

.card-draw-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.card-draw-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.card-draw-roster {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.card-draw-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #F8FAFC;
  border: 1px solid var(--border-hairline);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.card-draw-chip.is-active-picker {
  background: #EFF6FF;
  border-color: #60A5FA;
  color: #1E3A8A;
}

.card-draw-chip.is-picked {
  background: #ECFDF5;
  border-color: #6EE7B7;
  color: #065F46;
}

.card-draw-chip.is-self {
  box-shadow: 0 0 0 1.5px rgba(59, 130, 246, 0.28);
}

.card-draw-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin: 4px 0;
}

.card-draw-cards.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 310px;
}

.draw-card {
  position: relative;
  height: 152px;
  padding: 0;
  border: none;
  background: transparent;
  perspective: 900px;
  cursor: pointer;
}

.card-draw-cards.has-traits .draw-card {
  height: 204px;
}

.draw-card:disabled {
  cursor: default;
}

.draw-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.56s cubic-bezier(0.22, 1, 0.36, 1);
}

.draw-card.is-selectable:hover .draw-card-inner {
  transform: translateY(-5px);
}

.draw-card.is-flipped .draw-card-inner {
  transform: rotateY(180deg);
}

.draw-card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px;
}

.draw-card-face.is-front {
  background: linear-gradient(155deg, #1E3A8A 0%, #2563EB 55%, #3B82F6 100%);
  border: 2px solid #93C5FD;
  color: #FFFFFF;
  box-shadow: 0 8px 18px rgba(30, 58, 138, 0.22);
}

.draw-card.is-claimed .draw-card-face.is-front {
  background: linear-gradient(155deg, #334155 0%, #475569 100%);
  border-color: #94A3B8;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
}

.draw-card.is-my-claim .draw-card-face.is-front {
  background: linear-gradient(155deg, #1D4ED8 0%, #2563EB 100%);
  border-color: #FDE047;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.45), 0 8px 18px rgba(37, 99, 235, 0.26);
}

.draw-card-num {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.draw-card-emblem {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
}

.draw-card-claim-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.68rem;
  font-weight: 800;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.draw-card-face.is-back {
  transform: rotateY(180deg);
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.draw-card-face.is-back.stone-color-1 {
  background: linear-gradient(180deg, #F8FAFC 0%, #E2E8F0 100%);
  border-color: #334155;
}

.draw-card-face.is-back.stone-color-2 {
  background: linear-gradient(180deg, #FFFFFF 0%, #F1F5F9 100%);
  border-color: #94A3B8;
}

.draw-card-face.is-back.stone-color-3 {
  background: linear-gradient(180deg, #EFF6FF 0%, #DBEAFE 100%);
  border-color: #3B82F6;
}

.draw-card.is-my-claim .draw-card-face.is-back {
  box-shadow: 0 0 0 2.5px #2563EB, 0 12px 24px rgba(37, 99, 235, 0.22);
}

.draw-card-stone-lg {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  flex-shrink: 0;
}

.draw-card-stone-lg.stone-black {
  background: radial-gradient(circle at 32% 30%, #64748B, #1E293B 55%, #0F172A 100%);
  border: 1.5px solid #0F172A;
}

.draw-card-stone-lg.stone-white {
  background: radial-gradient(circle at 32% 30%, #FFFFFF, #F1F5F9 65%, #CBD5E1 100%);
  border: 1.5px solid #94A3B8;
}

.draw-card-stone-lg.stone-blue {
  background: radial-gradient(circle at 32% 30%, #93C5FD, #3B82F6 55%, #1D4ED8 100%);
  border: 1.5px solid #1E40AF;
}

.draw-card-stone-name {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
}

.draw-card-order-sub {
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.draw-card-owner-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 800;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.draw-card-trait-box {
  width: 100%;
  margin-top: 2px;
  padding: 5px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.draw-card-trait-name {
  font-size: 0.72rem;
  font-weight: 800;
  color: #1E3A8A;
  line-height: 1.2;
}

.draw-card-trait-desc {
  font-size: 0.62rem;
  font-weight: 600;
  color: #475569;
  line-height: 1.26;
  word-break: keep-all;
}

.card-draw-cards.has-traits .draw-card-face.is-back {
  gap: 4px;
  padding: 8px 7px;
  justify-content: space-between;
}

.card-draw-cards.has-traits .draw-card-stone-lg {
  width: 34px;
  height: 34px;
}

.card-draw-cards.has-traits .draw-card-stone-name {
  font-size: 0.82rem;
}

.card-draw-cards.has-traits .draw-card-order-sub {
  font-size: 0.64rem;
}

.draw-card.is-my-claim .draw-card-owner-tag {
  background: #2563EB;
  color: #FFFFFF;
}

.card-draw-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-top: 2px;
}

.card-draw-hint {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.tricolor-arrow {
  color: var(--text-dim);
  font-weight: 800;
}

.item-choice-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid var(--border-hairline);
}

.item-tier-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  vertical-align: middle;
  border: 1px solid var(--border-hairline);
}

.item-tier-common {
  color: var(--text-secondary);
  background: var(--surface-subtle);
}

.item-tier-tactical {
  color: var(--cat-defense-accent);
  background: var(--cat-defense-bg);
  border-color: var(--cat-defense-border);
}

.item-tier-rare {
  color: var(--cat-attack-accent);
  background: var(--cat-attack-bg);
  border-color: var(--cat-attack-border);
}

.item-tier-mythic {
  color: #B83256;
  background: #FDF2F4;
  border-color: rgba(184, 50, 86, 0.45);
}

.item-map-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  color: #0F766E;
  background: #ECFEFF;
  border: 1px solid rgba(13, 148, 136, 0.35);
  white-space: nowrap;
}

.item-map-badge.map-lightning_plain {
  color: #A16207;
  background: #FEF9C3;
  border-color: rgba(202, 138, 4, 0.4);
}

.item-map-badge.map-gale_canyon {
  color: #0369A1;
  background: #E0F2FE;
  border-color: rgba(2, 132, 199, 0.35);
}

.item-map-badge.map-fog_forest {
  color: #047857;
  background: #ECFDF5;
  border-color: rgba(5, 150, 105, 0.35);
}

.item-map-badge.map-lava_zone {
  color: #C2410C;
  background: #FFEDD5;
  border-color: rgba(234, 88, 12, 0.4);
}

.item-map-badge.map-treasure_vault {
  color: #B45309;
  background: #FEF3C7;
  border-color: rgba(217, 119, 6, 0.42);
}

.codex-chip-map-badge {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 999px;
  background: #F1F5F9;
  color: #334155;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* 4-Category Pastel Badges */
.cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.3;
  vertical-align: middle;
  white-space: nowrap;
  flex-shrink: 0;
}

.cat-badge-defense {
  background: var(--cat-defense-bg);
  color: var(--cat-defense-accent);
  border: 1px solid var(--cat-defense-border);
}

.cat-badge-attack {
  background: var(--cat-attack-bg);
  color: var(--cat-attack-accent);
  border: 1px solid var(--cat-attack-border);
}

.cat-badge-move {
  background: var(--cat-move-bg);
  color: var(--cat-move-accent);
  border: 1px solid var(--cat-move-border);
}

.cat-badge-chaos {
  background: var(--cat-chaos-bg);
  color: var(--cat-chaos-accent);
  border: 1px solid var(--cat-chaos-border);
}

.item-prompt-text strong {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.item-prompt-text > span {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Result Banner */
.result-banner {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(92%, 440px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  animation: bannerPop 0.22s ease-out;
}

@keyframes bannerPop {
  from {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.result-banner-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.result-text-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.result-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text-primary);
}

.result-subtitle {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.result-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Panel Cards */
.panel-card {
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 12px 13px;
  box-shadow: var(--shadow-card);
}

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

.card-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hint-text {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Status Card + Phase Badge + 20s Slim Timer */
.status-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
}

.status-card.is-my-turn {
  border-color: var(--cat-defense-accent);
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFF 100%);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(43, 108, 176, 0.16);
}

.status-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
}

.phase-badge.phase-1 {
  background: var(--cat-defense-bg);
  color: var(--cat-defense-accent);
  border: 1px solid var(--cat-defense-border);
}

.phase-badge.phase-2 {
  background: var(--cat-chaos-bg);
  color: var(--cat-chaos-accent);
  border: 1px solid var(--cat-chaos-border);
}

.phase-badge.phase-3 {
  background: var(--cat-attack-bg);
  color: var(--cat-attack-accent);
  border: 1px solid var(--cat-attack-border);
}

.status-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.my-turn-status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--cat-defense-accent);
  color: #FFFFFF;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-turn-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.status-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-primary);
}

.status-sub {
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.move-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
}

/* 20s Slim Turn Timer */
.turn-timer-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 6px;
  border-top: 1px solid var(--border-hairline);
}

.turn-timer-box.is-inactive {
  opacity: 0.55;
}

.turn-timer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  font-weight: 700;
}

.turn-timer-label {
  color: var(--text-secondary);
}

.turn-timer-text {
  color: var(--cat-defense-accent);
  font-weight: 800;
}

.turn-timer-box.is-warn .turn-timer-text {
  color: var(--cat-chaos-accent);
}

.turn-timer-box.is-urgent .turn-timer-text {
  color: var(--cat-attack-accent);
}

.turn-timer-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #EDEAE2;
  overflow: hidden;
}

.turn-timer-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.1s linear, background-color 0.25s ease;
}

.turn-timer-fill.is-safe {
  background: var(--cobalt-base);
}

.turn-timer-fill.is-warn {
  background: #E28734;
}

.turn-timer-fill.is-urgent {
  background: #D64545;
  animation: timerUrgentPulse 0.6s ease-in-out infinite alternate;
}

.turn-timer-box.is-gold-bonus {
  border-top-color: rgba(212, 160, 23, 0.72);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.92) 0%, rgba(254, 243, 199, 0.45) 100%);
  border-radius: 8px;
  padding: 6px 8px 4px;
}

.turn-timer-box.is-gold-bonus:not(.is-warn):not(.is-urgent) .turn-timer-label,
.turn-timer-box.is-gold-bonus:not(.is-warn):not(.is-urgent) .turn-timer-text {
  color: #B45309;
}

.turn-timer-box.is-gold-bonus .turn-timer-track {
  background: #FEF3C7;
  border: 1px solid rgba(212, 160, 23, 0.55);
}

.turn-timer-fill.is-gold {
  background: linear-gradient(90deg, #D4A017 0%, #F6D365 55%, #F59E0B 100%);
}

@keyframes timerUrgentPulse {
  from {
    opacity: 0.78;
  }
  to {
    opacity: 1;
  }
}

/* Stone Badges (Black Charcoal / Pearl White / Pastel Cobalt / Amber Joker) */
.stone-dot,
.stone-badge {
  display: inline-block;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.stone-dot {
  width: 13px;
  height: 13px;
}

.stone-badge {
  width: 28px;
  height: 28px;
}

.stone-black {
  background: radial-gradient(circle at 34% 30%, #4E5362 0%, #262932 62%, #191B22 100%);
  box-shadow: 0 2px 5px rgba(30, 32, 40, 0.22);
  border: 1px solid #1E2028;
}

.stone-white {
  background: radial-gradient(circle at 32% 28%, #FFFFFF 0%, #F7F8FA 75%, #E6EAF0 100%);
  box-shadow: 0 2px 5px rgba(30, 32, 40, 0.12);
  border: 1px solid #CBD2D9;
}

.stone-blue {
  background: radial-gradient(circle at 32% 28%, #7DB3EF 0%, #4C8EDA 58%, #3470B8 100%);
  box-shadow: 0 2px 5px rgba(43, 108, 176, 0.24);
  border: 1px solid rgba(43, 108, 176, 0.45);
}

.stone-draw {
  background: conic-gradient(#262932 0deg 120deg, #FFFFFF 120deg 240deg, #4C8EDA 240deg 360deg);
  border: 1px solid #CBD2D9;
}

.stone-joker {
  background: radial-gradient(circle at 32% 28%, #FAD789 0%, #F5B041 58%, #D68910 100%);
  border: 1px solid #D68910;
  box-shadow: 0 0 0 2px rgba(245, 176, 65, 0.3);
}

/* Balance HUD */
.balance-hud {
  width: min(100%, 650px);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: var(--radius-md);
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-card);
}

.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  font-variant-numeric: tabular-nums;
}

.hud-badge-warn {
  color: var(--cat-chaos-accent);
  background: var(--cat-chaos-bg);
  border-color: var(--cat-chaos-border);
}

.hud-badge-danger {
  color: var(--cat-attack-accent);
  background: var(--cat-attack-bg);
  border-color: var(--cat-attack-border);
}

.hud-badge-locked {
  color: var(--cat-chaos-accent);
  background: var(--cat-chaos-bg);
  border-color: var(--cat-chaos-border);
}

.hud-badge-joker {
  color: #6D28D9;
  background: linear-gradient(135deg, #FDF2F8 0%, #EFF6FF 48%, #F5F3FF 100%);
  border-color: rgba(168, 85, 247, 0.48);
}

.hud-badge-mutant {
  color: var(--cat-move-accent);
  background: var(--cat-move-bg);
  border-color: var(--cat-move-border);
}

.hud-badge-reverse {
  color: var(--cat-defense-accent);
  background: var(--cat-defense-bg);
  border-color: var(--cat-defense-border);
}

.hud-badge-map {
  font-weight: 800;
  color: #334155;
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.hud-badge-map.map-lightning_plain {
  color: #1E40AF;
  background: #EFF6FF;
  border-color: #93C5FD;
}

.hud-badge-map.map-gale_canyon {
  color: #92400E;
  background: #FEF3C7;
  border-color: #FCD34D;
}

.hud-badge-map.map-fog_forest {
  color: #065F46;
  background: #ECFDF5;
  border-color: #6EE7B7;
}

.hud-badge-map.map-lava_zone {
  color: #991B1B;
  background: #FEF2F2;
  border-color: #FCA5A5;
}

.hud-badge-map.map-treasure_vault {
  color: #854D0E;
  background: #FEF9C3;
  border-color: #FDE047;
}

.hud-badge-map-timer {
  color: #475569;
  background: #F8FAFC;
  border-color: #CBD5E1;
}

.hud-badge-map-timer.is-forecast {
  color: #B45309;
  background: #FFFBEB;
  border-color: #FCD34D;
}

.hud-badge-map-timer.is-active-fog {
  color: #047857;
  background: #ECFDF5;
  border-color: #6EE7B7;
}

.hud-badge-pulse {
  animation: hudPulse 1.15s ease-in-out infinite;
}

@keyframes hudPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.25);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(214, 69, 69, 0);
  }
}

/* Vertical Scoreboard with Right-Side Chat Bubbles */
.scoreboard-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scoreboard-grid.grid-2p {
  gap: 6px;
}

.score-tile {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 5px 8px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.score-tile.is-active {
  background: var(--cat-defense-bg);
  border-color: var(--cat-defense-accent);
}

.score-tile.is-four-win {
  background: linear-gradient(135deg, #FEFCE8 0%, #FEF9C3 100%);
  border-color: #CA8A04;
  box-shadow: inset 0 0 0 1px rgba(202, 138, 4, 0.25);
}

.score-tile.is-four-win.is-active {
  background: linear-gradient(135deg, #F0F9FF 0%, #FEF9C3 100%);
  border-color: #D97706;
  box-shadow: inset 0 0 0 1.5px rgba(43, 108, 176, 0.35);
}

.score-tile.is-four-threat {
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
  border-color: #DC2626;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.28);
  animation: fourThreatCardPulse 1.3s ease-in-out infinite;
}

.score-tile.is-four-threat.is-active {
  border-color: #B91C1C;
  box-shadow: inset 0 0 0 1.5px rgba(220, 38, 38, 0.45);
}

.score-tile-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.score-tile-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  flex-wrap: nowrap;
}

.score-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.role-tag {
  font-size: 0.64rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}

.score-value {
  margin-top: 0;
  min-width: 16px;
  text-align: right;
  font-size: 1.04rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.score-value.is-negative {
  color: var(--cat-attack-accent);
}

.score-chat-bubble {
  position: relative;
  max-width: 155px;
  padding: 4px 9px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1.5px solid #93C5FD;
  color: #1E293B;
  font-size: 0.71rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
  flex-shrink: 1;
}

.score-chat-bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid #93C5FD;
}

.score-chat-bubble::after {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 5px solid #FFFFFF;
}

.score-chat-bubble.is-emote {
  background: #EFF6FF;
  border-color: #60A5FA;
  color: #1E3A8A;
}

.score-chat-bubble.is-emote::before {
  border-right-color: #60A5FA;
}

.score-chat-bubble.is-emote::after {
  border-right-color: #EFF6FF;
}

.score-chat-bubble.is-pop {
  animation: scoreBubblePop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.score-chat-bubble.hidden {
  display: none;
}

@keyframes scoreBubblePop {
  0% {
    opacity: 0;
    transform: translateX(-6px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Watch Controls */
.watch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Settings Panel */
details.settings-card > summary.settings-summary {
  list-style: none;
  cursor: pointer;
  margin-bottom: 0;
  user-select: none;
}

details.settings-card > summary.settings-summary::-webkit-details-marker {
  display: none;
}

details.settings-card[open] > summary.settings-summary {
  margin-bottom: 10px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setting-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.setting-select {
  width: 140px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}

.setting-select:focus {
  border-color: var(--accent-primary);
}

.setting-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 2px 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-desc {
  font-size: 0.71rem;
  color: var(--text-dim);
}

.toggle-input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #DCD8CE;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.toggle-input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s ease;
}

.toggle-input:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-input:checked::after {
  transform: translateX(18px);
}

/* Glassmorphism Global Item / Event Toast (Non-overlapping top header zone) */
.global-item-banner {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 540px);
  padding: 10px 40px 12px 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid var(--border-strong);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 60;
  pointer-events: auto;
  text-align: center;
  overflow: hidden;
  animation: globalBannerPop 0.24s ease-out;
}

.global-item-banner.is-overclocked {
  border: 2.5px solid #D4A017 !important;
  border-left: 8px solid #B45309 !important;
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%) !important;
  box-shadow: 0 10px 28px rgba(212, 160, 23, 0.36) !important;
}

.global-banner-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(30, 32, 40, 0.1);
}

.global-banner-gauge {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4C8EDA 0%, #6E47C9 55%, #D64545 100%);
  transform-origin: left center;
}

.global-banner-gauge.is-running {
  animation: bannerCountdown 8s linear forwards;
}

@keyframes bannerCountdown {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.banner-close-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.banner-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

@keyframes globalBannerPop {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.global-item-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.global-item-top .stone-badge {
  width: 18px;
  height: 18px;
}

.global-item-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.global-item-title {
  font-size: 0.96rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #0F172A;
}

.global-item-summary {
  margin: 3px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes globalBannerInlinePop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 1121px) {
  .top-bar {
    flex-wrap: nowrap;
    min-height: 64px;
    height: auto;
    padding: 6px 16px;
  }

  .global-item-banner {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: 560px;
    margin: 0 auto;
    padding: 6px 36px 8px 15px;
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid var(--border-strong);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
    z-index: 2;
    animation: globalBannerInlinePop 0.2s ease-out;
  }

  .global-item-top {
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .global-item-title {
    font-size: 0.89rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .global-item-summary {
    margin: 2px 0 0;
    font-size: 0.78rem;
  }
}

/* Personal Alert Banner (Forced target only - flow positioned above board) */
.personal-alert-banner {
  position: static;
  width: min(100%, 650px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  pointer-events: none;
  font-size: 0.8rem;
  font-weight: 700;
}

.personal-alert-banner.alert-forced {
  background: rgba(255, 240, 240, 0.94);
  border: 1.5px solid var(--cat-attack-accent);
  color: var(--cat-attack-accent);
  box-shadow: var(--shadow-float);
  animation: hudPulse 1s ease-in-out infinite;
}

.personal-alert-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.hud-turn-flash {
  color: var(--cat-chaos-accent) !important;
  background: var(--cat-chaos-bg) !important;
  border-color: var(--cat-chaos-accent) !important;
  animation: turnFlashPulse 0.45s ease-in-out infinite alternate;
}

@keyframes turnFlashPulse {
  from {
    box-shadow: 0 0 0 0 rgba(201, 106, 27, 0.25);
    transform: scale(1);
  }
  to {
    box-shadow: 0 0 10px 2px rgba(201, 106, 27, 0.35);
    transform: scale(1.04);
  }
}

/* Nickname Join Overlay */
.nickname-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: rgba(248, 247, 244, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.nickname-card {
  width: min(100%, 420px);
  max-height: 92%;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-float);
  text-align: center;
}

.nickname-title {
  margin: 0 0 6px;
  font-size: 1.06rem;
  font-weight: 800;
  color: var(--text-primary);
}

.nickname-desc {
  margin: 0 0 14px;
  font-size: 0.79rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.nickname-form {
  display: flex;
  gap: 8px;
}

.nickname-input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.nickname-input:focus {
  border-color: var(--accent-primary);
  background: #FFFFFF;
}

.join-error-text {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--cat-attack-accent);
  font-weight: 600;
}

.nickname-rules-box {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  text-align: left;
}

.nickname-rules-title {
  margin-bottom: 6px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.nickname-rules-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--text-secondary);
  word-break: keep-all;
}

.nickname-rules-list strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Online Lobby Card */
.online-slots {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.online-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  font-size: 0.78rem;
}

.online-slot-color {
  color: var(--text-secondary);
  font-weight: 600;
  flex-shrink: 0;
}

.online-slot-name {
  margin-left: auto;
  color: var(--text-primary);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.online-map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border-hairline);
}

.online-map-row .setting-select {
  min-width: 148px;
}

.online-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.online-actions .btn {
  flex: 1;
}

/* Integrated Game Log Panel (Right Sidebar, Half Height + Collapsible) */
.log-card-header {
  cursor: pointer;
  user-select: none;
  gap: 8px;
}

.log-card.is-collapsed .log-card-header {
  margin-bottom: 0;
}

.log-title-group {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.btn-collapse-toggle {
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.69rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-collapse-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 165px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-card.is-collapsed .log-list,
.log-card.is-collapsed .chat-pane {
  display: none;
}

.log-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.log-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.log-tab-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.log-tab-btn.is-active {
  background: #1E293B;
  border-color: #1E293B;
  color: #FFFFFF;
}

.log-tab-btn.is-active .hint-text {
  color: #CBD5E1;
}

.chat-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #EF4444;
  color: #FFFFFF;
  font-size: 0.64rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chat-unread-badge.hidden {
  display: none;
}

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.chat-pane.hidden {
  display: none;
}

.chat-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 4px;
  border-bottom: 1px dashed var(--border-hairline);
  flex: 0 0 auto;
}

.chat-pane-status {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn-chat-mute {
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.69rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.btn-chat-mute:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-chat-mute.is-muted {
  background: #FFF1F2;
  border-color: rgba(225, 29, 72, 0.35);
  color: #BE123C;
}

.chat-message-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 110px;
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-empty-hint {
  padding: 16px 8px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.chat-muted-hint {
  color: #9F1239;
  font-weight: 700;
}

.chat-msg-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-subtle);
  font-size: 0.74rem;
  line-height: 1.36;
  word-break: break-word;
}

.chat-msg-row.is-emote {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
}

.chat-msg-sender {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  color: var(--text-primary);
  flex-shrink: 0;
}

.chat-msg-sender .stone-dot {
  width: 8px;
  height: 8px;
}

.chat-spec-tag {
  padding: 0 4px;
  border-radius: 4px;
  background: #E2E8F0;
  color: #475569;
  font-size: 0.62rem;
  font-weight: 800;
}

.chat-msg-text {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.chat-msg-row.is-emote .chat-msg-text {
  font-weight: 700;
  color: #92400E;
}

.chat-msg-time {
  font-size: 0.62rem;
  color: var(--text-dim);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.chat-quick-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.chat-quick-bar:empty {
  display: none;
}

.chat-quick-btn {
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-hairline);
  background: #FFFFFF;
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.chat-quick-btn:hover {
  background: #EFF6FF;
  border-color: #93C5FD;
  color: #1E3A8A;
}

.chat-quick-btn.is-custom {
  background: #FFFBEB;
  border-color: #FCD34D;
  color: #92400E;
}

.chat-quick-btn.is-custom:hover {
  background: #FEF3C7;
  border-color: #F59E0B;
}

.chat-preset-editor {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px;
  border-radius: 9px;
  background: #F8FAFC;
  border: 1px solid var(--border-hairline);
  flex-shrink: 0;
}

.chat-preset-editor.hidden {
  display: none;
}

.chat-preset-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.chat-preset-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.chat-preset-inputs input {
  width: 100%;
  min-width: 0;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-hairline);
  font-size: 0.69rem;
  background: #FFFFFF;
  color: var(--text-primary);
}

.chat-quick-popup {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 68px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100% - 74px);
  padding: 8px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.chat-quick-popup.hidden {
  display: none;
}

.chat-quick-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 800;
  color: #1E3A8A;
  flex-shrink: 0;
}

.btn-chat-popup-close {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-chat-popup-close:hover {
  background: #F1F5F9;
  color: var(--text-primary);
}

.chat-quick-popup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  overflow-y: auto;
  padding-right: 2px;
}

.chat-quick-popup-btn {
  position: relative;
  padding: 5px 7px;
  border-radius: 7px;
  border: 1px solid var(--border-hairline);
  background: #F8FAFC;
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.chat-quick-popup-btn-label {
  position: relative;
  z-index: 1;
}

.chat-quick-popup-btn:hover {
  background: #EFF6FF;
  border-color: #93C5FD;
  color: #1E3A8A;
}

.chat-quick-popup-grid.is-cooldown .chat-quick-popup-btn {
  cursor: wait;
}

.chat-quick-popup-grid.is-cooldown .chat-quick-popup-btn:not(.is-cooling-selected) {
  opacity: 0.62;
}

.chat-quick-popup-btn.is-cooling-selected {
  border-color: #3B82F6;
  color: #1E3A8A;
  animation: quickPopupBtnDeepen 1s linear forwards;
}

.chat-quick-popup-btn.is-cooling-selected::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  transform-origin: left center;
  animation: quickPopupFillSweep 1s linear forwards;
}

@keyframes quickPopupBtnDeepen {
  0% {
    background-color: #EFF6FF;
    border-color: #93C5FD;
  }
  100% {
    background-color: #BFDBFE;
    border-color: #2563EB;
  }
}

@keyframes quickPopupFillSweep {
  0% {
    transform: scaleX(0);
    background-color: rgba(147, 197, 253, 0.35);
  }
  100% {
    transform: scaleX(1);
    background-color: rgba(59, 130, 246, 0.42);
  }
}

.chat-tool-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-chat-emote-soon {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px dashed #CBD5E1;
  background: #F8FAFC;
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.btn-chat-emote-soon:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
}

.chat-soon-badge {
  padding: 1px 5px;
  border-radius: 999px;
  background: #E2E8F0;
  color: #475569;
  font-size: 0.6rem;
  font-weight: 800;
  white-space: nowrap;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-chat-quick-popup {
  height: 26px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid #BFDBFE;
  background: #EFF6FF;
  color: #1D4ED8;
  font-size: 0.69rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.btn-chat-quick-popup:hover,
.btn-chat-quick-popup.is-open {
  background: #DBEAFE;
  border-color: #60A5FA;
}

.btn-chat-preset-edit {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-chat-preset-edit:hover {
  background: var(--surface-hover);
}

.chat-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: #FFFFFF;
  color: var(--text-primary);
  font-size: 0.75rem;
}

.chat-input:focus {
  outline: none;
  border-color: #60A5FA;
}

.log-item-row {
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  line-height: 1.36;
  background: var(--surface-subtle);
  border-left: 3px solid var(--border-strong);
  color: var(--text-primary);
  word-break: keep-all;
  font-variant-numeric: tabular-nums;
}

.log-item-row.log-move {
  border-left-color: #CBD2D9;
  color: var(--text-secondary);
}

.log-item-row.log-item {
  border-left-color: var(--cat-chaos-accent);
  background: var(--cat-chaos-bg);
  color: #8F4910;
  font-weight: 600;
}

.log-item-row.log-overclock {
  border: 1px solid rgba(212, 160, 23, 0.52);
  border-left: 4px solid #D4A017;
  background: linear-gradient(90deg, #FFFBEB 0%, #FEF3C7 100%);
  color: #92400E;
  font-weight: 700;
}

.log-item-row.log-system {
  border-left-color: var(--cat-defense-accent);
  background: var(--cat-defense-bg);
  color: #1F4F82;
}

.log-item-row.log-warn {
  border-left-color: var(--cat-attack-accent);
  background: var(--cat-attack-bg);
  color: #A62F2F;
  font-weight: 700;
}

/* Held Item Card (2-Slot Inventory: Regular + Overclock Staging) */
.held-item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.held-slot-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 7px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  min-width: 0;
}

.held-slot-val {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.held-slot-pill.is-filled .held-slot-val {
  color: var(--text-primary);
  font-weight: 700;
}

.inventory-slots-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.my-held-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.my-held-box.has-item {
  background: #FFFFFF;
  border-color: var(--cat-defense-accent);
  box-shadow: 0 2px 10px rgba(43, 108, 176, 0.08);
}

.my-held-box.is-casting {
  border: 1.5px solid var(--cat-attack-accent);
  background: #FFF8F8;
  box-shadow: 0 2px 10px rgba(214, 69, 69, 0.10);
}

.my-held-icon {
  font-size: 1.28rem;
  line-height: 1;
  flex-shrink: 0;
}

.my-held-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.my-held-head-row,
.overclock-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.slot-kind-label {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-dim);
}

.my-held-name {
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.my-held-desc {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.25;
  word-break: keep-all;
}

.slot-action-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  align-items: stretch;
}

.btn-overclock-transfer {
  background: #FFF8E6;
  border: 1px solid #DFB14B;
  color: #8A5A00;
  font-weight: 800;
  padding: 3px 7px;
  font-size: 0.68rem;
  border-radius: 6px;
  white-space: nowrap;
}

.btn-overclock-transfer:hover:not(:disabled) {
  background: #FDECB8;
  border-color: #C98B14;
}

.btn-overclock-use {
  background: linear-gradient(135deg, #D99B1C 0%, #B87408 100%);
  border: 1px solid #A36505;
  color: #FFFFFF;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.28);
}

.btn-overclock-use:hover:not(:disabled) {
  background: linear-gradient(135deg, #E5A924 0%, #C67F0B 100%);
}

/* Overclock One-Way Maturing Slot */
.overclock-slot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px dashed var(--border-strong);
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.overclock-slot.is-standby {
  opacity: 0.78;
}

.overclock-slot.is-maturing {
  border-style: solid;
  border-color: rgba(201, 106, 27, 0.45);
  background: #FFFBF4;
}

.overclock-slot.is-charged {
  border-style: solid;
  border-color: #E2A93B;
  background: #FFF9EB;
  animation: overclockSpark 1.5s ease-in-out infinite alternate;
}

.overclock-slot.is-overload {
  border-style: solid;
  border-color: var(--cat-attack-accent);
  background: var(--cat-attack-bg);
  animation: hudPulse 0.75s ease-in-out infinite;
}

.overclock-slot.is-mutated {
  border-style: solid;
  border-color: var(--cat-move-accent);
  background: #FAF7FF;
}

.overclock-slot.is-casting {
  border-style: solid;
  border-width: 1.5px;
  border-color: var(--cat-attack-accent);
  background: #FFF8F8;
  box-shadow: 0 2px 10px rgba(214, 69, 69, 0.12);
}

@keyframes overclockSpark {
  from {
    box-shadow: 0 0 0 0 rgba(245, 176, 65, 0.18);
  }
  to {
    box-shadow: 0 0 12px 2px rgba(245, 176, 65, 0.34);
  }
}

.overclock-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.overclock-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.overclock-name {
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overclock-status-pill {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--cat-chaos-accent);
  background: var(--cat-chaos-bg);
  border: 1px solid var(--cat-chaos-border);
  white-space: nowrap;
}

.overclock-status-pill.is-charged {
  color: #8A5A00;
  background: #FFF1C2;
  border-color: #DFB14B;
}

.overclock-status-pill.is-overload {
  color: var(--cat-attack-accent);
  background: var(--cat-attack-bg);
  border-color: var(--cat-attack-border);
}

.overclock-status-pill.is-mutated {
  color: var(--cat-move-accent);
  background: var(--cat-move-bg);
  border-color: var(--cat-move-border);
}

.overclock-desc {
  font-size: 0.67rem;
  color: var(--text-dim);
  line-height: 1.25;
  word-break: keep-all;
}

.slot-tag-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.slot-extra-info {
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.3;
  color: #475569;
  background: rgba(241, 245, 249, 0.72);
  border-radius: 5px;
  padding: 3px 6px;
  word-break: keep-all;
}

.overclock-progress-wrap {
  width: 100%;
  height: 5px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.overclock-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #F59E0B 0%, #D97706 100%);
  transition: width 0.25s ease;
}

.overclock-progress-fill.is-charged {
  background: linear-gradient(90deg, #D97706 0%, #FBBF24 50%, #B45309 100%);
}

.overclock-progress-fill.is-overload {
  background: linear-gradient(90deg, #EA580C 0%, #DC2626 100%);
}

.inventory-phase-odds {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
}

.phase-odds-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.phase-odds-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.phase-mythic-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  background: #F1F5F9;
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  white-space: nowrap;
}

.phase-mythic-badge.is-unlocked {
  background: #FDF2F8;
  border-color: #F472B6;
  color: #9D174D;
}

.phase-odds-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.odds-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.odds-chip-defense {
  background: var(--cat-defense-bg);
  color: var(--cat-defense-accent);
  border: 1px solid var(--cat-defense-border);
}

.odds-chip-attack {
  background: var(--cat-attack-bg);
  color: var(--cat-attack-accent);
  border: 1px solid var(--cat-attack-border);
}

.odds-chip-move {
  background: var(--cat-move-bg);
  color: var(--cat-move-accent);
  border: 1px solid var(--cat-move-border);
}

.odds-chip-chaos {
  background: var(--cat-chaos-bg);
  color: var(--cat-chaos-accent);
  border: 1px solid var(--cat-chaos-border);
}

.odds-chip-mythic {
  background: #FDF2F8;
  color: #B83256;
  border: 1px solid rgba(184, 50, 86, 0.42);
}

.inventory-field-summary {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dashed var(--border-hairline);
}

.inventory-field-head {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.inventory-field-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.field-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 700;
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  white-space: nowrap;
}

.field-stat-chip.is-highlight {
  background: #FFFBEB;
  border-color: #FCD34D;
  color: #92400E;
}

.field-stat-chip.is-mythic {
  background: #FDF2F8;
  border-color: #F472B6;
  color: #9D174D;
}

.field-stat-chip.is-stealth {
  background: #F5F3FF;
  border-color: #C4B5FD;
  color: #5B21B6;
}

/* Turn Order Cycle Card (3-Player Triangle Diagram) */
.turn-order-card {
  padding: 8px 12px 6px;
  gap: 4px;
  transition: border-color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
}

.turn-order-card.is-reverse {
  border-color: var(--cat-chaos-border);
  background: #FFFDF8;
}

.turn-order-card.is-reversing {
  border-color: var(--cat-chaos-accent);
  animation: turnCycleReversePulse 0.65s ease-in-out 3;
}

@keyframes turnCycleReversePulse {
  0%, 100% {
    box-shadow: var(--shadow-card);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(201, 106, 27, 0.26), 0 6px 20px rgba(201, 106, 27, 0.16);
  }
}

.turn-cycle-dir-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 800;
}

.turn-cycle-dir-badge.is-forward {
  background: var(--cat-defense-bg);
  color: var(--cat-defense-accent);
  border: 1px solid var(--cat-defense-border);
}

.turn-cycle-dir-badge.is-reverse {
  background: var(--cat-chaos-bg);
  color: var(--cat-chaos-accent);
  border: 1px solid var(--cat-chaos-border);
}

.turn-cycle-svg {
  width: 100%;
  height: 86px;
  display: block;
  overflow: visible;
}

.cycle-center-icon {
  font-size: 24px;
  font-weight: 800;
  fill: rgba(43, 108, 176, 0.22);
  dominant-baseline: central;
  transition: fill 0.2s ease;
}

.turn-order-card.is-reverse .cycle-center-icon {
  fill: rgba(201, 106, 27, 0.28);
}

.cycle-arrow {
  fill: none;
  stroke: #BEB8AC;
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.cycle-arrow.is-next {
  stroke: var(--cat-defense-accent);
  stroke-width: 3.4;
  stroke-dasharray: 6 4;
  animation: cycleArrowFlow 0.7s linear infinite;
}

.turn-order-card.is-reverse .cycle-arrow.is-next {
  stroke: var(--cat-chaos-accent);
}

@keyframes cycleArrowFlow {
  from {
    stroke-dashoffset: 20;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.cycle-stone-black {
  fill: #262932;
  stroke: #181A20;
  stroke-width: 1.5;
}

.cycle-stone-white {
  fill: #FFFFFF;
  stroke: #B7C0CA;
  stroke-width: 1.8;
}

.cycle-stone-blue {
  fill: #4C8EDA;
  stroke: #316EB4;
  stroke-width: 1.5;
}

.cycle-stone-label {
  font-size: 11px;
  font-weight: 800;
  dominant-baseline: central;
  text-anchor: middle;
  pointer-events: none;
}

.cycle-stone-label.label-light {
  fill: #FFFFFF;
}

.cycle-stone-label.label-dark {
  fill: #1E2028;
}

.cycle-active-ring {
  opacity: 0;
  fill: none;
  stroke: var(--cat-defense-accent);
  stroke-width: 2.4;
  transform-box: fill-box;
  transform-origin: center;
}

.turn-order-card.is-reverse .cycle-active-ring {
  stroke: var(--cat-chaos-accent);
}

.cycle-node.is-active .cycle-active-ring {
  opacity: 1;
  animation: cycleNodePulse 1.3s ease-in-out infinite;
}

@keyframes cycleNodePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.45;
  }
}

.cycle-role-tag {
  font-size: 9px;
  font-weight: 800;
  fill: var(--cat-defense-accent);
  text-anchor: middle;
  dominant-baseline: central;
}

.turn-order-card.is-reverse .cycle-role-tag {
  fill: var(--cat-chaos-accent);
}

/* Big Reverse Turn Fullscreen Non-Blocking Overlay */
.reverse-turn-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.reverse-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(43, 108, 176, 0.14) 0%, rgba(237, 245, 255, 0.08) 45%, transparent 76%);
  animation: reverseBackdropFlash 1.75s ease-out forwards;
}

.reverse-turn-overlay.is-reverse .reverse-overlay-backdrop {
  background: radial-gradient(circle at center, rgba(201, 106, 27, 0.16) 0%, rgba(110, 71, 201, 0.09) 45%, transparent 76%);
}

@keyframes reverseBackdropFlash {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  75% {
    opacity: 0.82;
  }
  100% {
    opacity: 0;
  }
}

.reverse-overlay-stage {
  position: relative;
  width: min(58vw, 58vh, 360px);
  height: min(58vw, 58vh, 360px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.reverse-shock-ring {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: 3px solid rgba(43, 108, 176, 0.42);
  opacity: 0;
}

.reverse-turn-overlay.is-reverse .reverse-shock-ring {
  border-color: rgba(201, 106, 27, 0.46);
}

.reverse-shock-ring.ring-1 {
  animation: reverseShockExpand 1.3s ease-out forwards;
}

.reverse-shock-ring.ring-2 {
  animation: reverseShockExpand 1.5s ease-out 0.16s forwards;
}

@keyframes reverseShockExpand {
  0% {
    transform: scale(0.55);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

.reverse-spin-disc {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--cat-defense-border);
  box-shadow: 0 18px 54px rgba(30, 32, 40, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: reverseDiscPop 1.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.reverse-turn-overlay.is-reverse .reverse-spin-disc {
  border-color: var(--cat-chaos-border);
}

@keyframes reverseDiscPop {
  0% {
    opacity: 0;
    transform: scale(0.42);
  }
  16% {
    opacity: 1;
    transform: scale(1.04);
  }
  28% {
    opacity: 1;
    transform: scale(1);
  }
  80% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.1);
  }
}

.reverse-spin-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.reverse-turn-overlay.is-reverse .reverse-arcs-cw,
.reverse-turn-overlay.is-forward .reverse-arcs-ccw {
  display: none;
}

.reverse-turn-overlay.is-reverse .reverse-spin-svg {
  animation: reverseSpinCCW 1.45s cubic-bezier(0.18, 0.9, 0.25, 1) forwards;
}

.reverse-turn-overlay.is-forward .reverse-spin-svg {
  animation: reverseSpinCW 1.45s cubic-bezier(0.18, 0.9, 0.25, 1) forwards;
}

@keyframes reverseSpinCCW {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-420deg);
  }
}

@keyframes reverseSpinCW {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(420deg);
  }
}

.reverse-arc-path {
  fill: none;
  stroke: var(--cat-defense-accent);
  stroke-width: 14;
  stroke-linecap: round;
}

.reverse-arrow-head {
  fill: var(--cat-defense-accent);
}

.reverse-turn-overlay.is-reverse .reverse-arc-path {
  stroke: var(--cat-chaos-accent);
}

.reverse-turn-overlay.is-reverse .reverse-arrow-head {
  fill: var(--cat-chaos-accent);
}

.reverse-center-badge {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
  padding: 12px 16px;
}

.reverse-overlay-icon {
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  color: var(--cat-defense-accent);
}

.reverse-turn-overlay.is-reverse .reverse-overlay-icon {
  color: var(--cat-chaos-accent);
}

.reverse-overlay-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.reverse-overlay-order {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
  background: var(--cat-defense-bg);
  color: var(--cat-defense-accent);
  border: 1px solid var(--cat-defense-border);
  white-space: nowrap;
}

.reverse-turn-overlay.is-reverse .reverse-overlay-order {
  background: var(--cat-chaos-bg);
  color: var(--cat-chaos-accent);
  border-color: var(--cat-chaos-border);
}

/* Responsive Tablet / Mobile (Allow vertical scrolling below 1120px) */
@media (max-width: 1120px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .board-stage {
    order: 1;
  }

  .left-panel {
    order: 2;
    width: min(100%, 640px);
    margin: 0 auto;
  }

  .right-panel {
    order: 3;
    width: min(100%, 640px);
    margin: 0 auto;
  }

  .board-frame,
  .balance-hud,
  .personal-alert-banner,
  .item-prompt-banner {
    width: min(100%, 640px);
  }
}

/* Global Alert Themes & Board-Center Non-Blocking Event Toast */
.global-item-banner.theme-shrink {
  background: linear-gradient(135deg, #FFF1F2 0%, #FFE4E6 100%);
  border: 2.5px solid #E11D48;
  border-left: 8px solid #BE123C;
  box-shadow: 0 8px 26px rgba(225, 29, 72, 0.30);
}

.global-item-banner.theme-reverse {
  background: linear-gradient(135deg, #F5F3FF 0%, #EDE9FE 100%);
  border: 2.5px solid #7C3AED;
  border-left: 8px solid #5B21B6;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.28);
}

.global-item-banner.theme-item {
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border: 2.5px solid #2563EB;
  border-left: 8px solid #1D4ED8;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
}

.global-item-banner.theme-expire {
  background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
  border: 2.5px solid #EA580C;
  border-left: 8px solid #C2410C;
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.28);
}

.global-item-banner.is-alert-pulse {
  animation: bannerAlertMobilePop 0.44s ease-out;
}

@keyframes bannerAlertMobilePop {
  0% {
    opacity: 0.72;
    transform: translateX(-50%) scale(0.94);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.045);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@media (min-width: 1121px) {
  .global-item-banner.is-alert-pulse {
    animation: bannerAlertPulse 0.46s cubic-bezier(0.2, 0.9, 0.3, 1.12);
  }
}

@keyframes bannerAlertPulse {
  0% {
    opacity: 0.72;
    transform: scale(0.94);
  }
  50% {
    opacity: 1;
    transform: scale(1.045);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.board-center-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 38;
  pointer-events: none;
  width: min(88%, 430px);
  max-width: calc(100% - 24px);
  padding: 14px 34px 14px 24px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: boardCenterPopupPop 5s cubic-bezier(0.2, 0.9, 0.3, 1.05) forwards;
}

.board-center-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.38);
  color: #F8FAFC;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.board-center-popup-close:hover {
  background: rgba(15, 23, 42, 0.68);
  transform: scale(1.08);
}

.board-center-popup-close:active {
  transform: scale(0.95);
}

@keyframes boardCenterPopupPop {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px)) scale(0.90);
  }
  4% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.03);
  }
  7% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  91% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 6px)) scale(0.98);
  }
}

body.reduce-motion .board-center-popup {
  animation: boardCenterPopupFade 5s ease-out forwards;
}

@keyframes boardCenterPopupFade {
  0% {
    opacity: 0;
  }
  5%, 91% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .board-center-popup {
    animation: boardCenterPopupFade 5s ease-out forwards;
  }
}

.board-center-popup-title {
  font-size: clamp(0.95rem, 1.75vw, 1.16rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.25;
  word-break: keep-all;
}

.board-center-popup-subtitle {
  font-size: clamp(0.76rem, 1.25vw, 0.88rem);
  font-weight: 700;
  line-height: 1.38;
  word-break: keep-all;
}

.board-center-popup.theme-gold {
  background: linear-gradient(135deg, rgba(113, 63, 18, 0.96) 0%, rgba(180, 83, 9, 0.95) 55%, rgba(146, 64, 14, 0.96) 100%);
  border: 2.5px solid #FACC15;
  box-shadow: 0 14px 34px rgba(180, 83, 9, 0.42), 0 0 0 1px rgba(254, 240, 138, 0.35) inset;
}

.board-center-popup.theme-gold .board-center-popup-title {
  color: #FEF08A;
}

.board-center-popup.theme-gold .board-center-popup-subtitle {
  color: #FFFBEB;
}

.board-center-popup.theme-danger {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.96) 0%, rgba(185, 28, 28, 0.95) 55%, rgba(136, 19, 55, 0.96) 100%);
  border: 2.5px solid #FDA4AF;
  box-shadow: 0 14px 34px rgba(185, 28, 28, 0.44), 0 0 0 1px rgba(254, 205, 211, 0.30) inset;
}

.board-center-popup.theme-danger .board-center-popup-title {
  color: #FEF08A;
}

.board-center-popup.theme-danger .board-center-popup-subtitle {
  color: #FFE4E6;
}

.board-center-popup.theme-tactical {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.96) 0%, rgba(49, 46, 129, 0.95) 55%, rgba(15, 23, 42, 0.96) 100%);
  border: 2.5px solid #60A5FA;
  box-shadow: 0 14px 34px rgba(30, 58, 138, 0.42), 0 0 0 1px rgba(191, 219, 254, 0.28) inset;
}

.board-center-popup.theme-tactical .board-center-popup-title {
  color: #E0F2FE;
}

.board-center-popup.theme-tactical .board-center-popup-subtitle {
  color: #E2E8F0;
}

/* =========================================================================
   Item Codex Button & 5x5 Live Preview Modal
   ========================================================================= */
.inventory-codex-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-hairline);
}

.btn-codex-open {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1E3A8A;
  background: linear-gradient(180deg, #F4F8FF 0%, #E7F0FF 100%);
  border: 1px solid #BFDBFE;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.btn-codex-open:hover {
  border-color: #60A5FA;
  background: linear-gradient(180deg, #EFF6FF 0%, #DBEAFE 100%);
  transform: translateY(-1px);
}

.codex-overlay {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.codex-overlay.hidden {
  display: none;
}

.codex-modal-card {
  width: min(760px, 100%);
  max-height: min(92vh, 800px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  overflow-y: auto;
}

.codex-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
}

.codex-modal-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.codex-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.codex-modal-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
}

.btn-codex-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-codex-close:hover {
  background: #F1F5F9;
  color: var(--text-primary);
}

.codex-preview-stage {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  flex-shrink: 0;
}

.codex-canvas-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.codex-canvas-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid #C9C1B0;
  background: #F2EFE9;
  box-shadow: 0 6px 18px rgba(30, 25, 18, 0.12);
}

#codexPreviewCanvas {
  display: block;
  width: 220px;
  height: 220px;
}

.codex-stage-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  color: #1E293B;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.55);
  pointer-events: none;
}

.codex-stage-badge.is-oc {
  color: #92400E;
  background: rgba(255, 251, 235, 0.95);
  border-color: #F59E0B;
}

.codex-loop-bar {
  width: 220px;
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
}

.codex-loop-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3B82F6 0%, #8B5CF6 100%);
}

.codex-loop-fill.is-oc {
  background: linear-gradient(90deg, #F59E0B 0%, #D97706 100%);
}

.codex-preview-caption {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.38;
  color: var(--text-secondary);
  text-align: center;
  min-height: 2.1em;
}

.codex-detail-pane {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.codex-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.codex-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.codex-item-title-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.codex-item-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.codex-item-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.codex-cost-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 700;
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #CBD5E1;
}

.codex-mode-toggle {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.codex-mode-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.codex-mode-btn.is-active {
  background: #EFF6FF;
  border-color: #3B82F6;
  color: #1D4ED8;
}

.codex-mode-btn.is-oc-active {
  background: linear-gradient(180deg, #FFFBEB 0%, #FEF3C7 100%);
  border-color: #D97706;
  color: #92400E;
}

.codex-mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.codex-mythic-notice {
  font-size: 0.71rem;
  font-weight: 600;
  color: #BE185D;
}

.codex-detail-box,
.codex-overclock-box {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
}

.codex-overclock-box {
  background: #FFFDF4;
  border-color: #FDE68A;
}

.codex-overclock-box.is-disabled {
  opacity: 0.58;
  background: #F8FAFC;
  border-color: var(--border-hairline);
}

.codex-detail-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.codex-overclock-box .codex-detail-label {
  color: #B45309;
}

.codex-item-desc,
.codex-overclock-desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.42;
  color: var(--text-primary);
}

.codex-filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border-hairline);
  flex-shrink: 0;
}

.codex-tab-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.codex-tab-btn.is-active {
  background: #1E293B;
  border-color: #1E293B;
  color: #FFFFFF;
}

.codex-item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 6px;
  overflow-y: auto;
  flex: 1 1 170px;
  min-height: 150px;
  max-height: 230px;
  padding-right: 4px;
}

.codex-item-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--border-hairline);
  background: #FFFFFF;
  color: var(--text-primary);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.codex-item-chip:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
}

.codex-item-chip.is-selected {
  background: #EFF6FF;
  border-color: #2563EB;
  color: #1E3A8A;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.codex-item-chip-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.codex-item-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.codex-item-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.codex-item-chip-tier {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-dim);
}

/* Master Control Test Panel */
.btn-master {
  color: #5B21B6;
  border-color: rgba(124, 58, 237, 0.32);
  background: #F5F3FF;
}

.btn-master:hover:not(:disabled) {
  background: #EDE9FE;
  border-color: rgba(124, 58, 237, 0.55);
}

.btn-master.is-active {
  background: linear-gradient(135deg, #6D28D9, #4F46E5);
  color: #FFFFFF;
  border-color: #4C1D95;
  box-shadow: 0 2px 8px rgba(109, 40, 217, 0.28);
}

.master-control-panel {
  position: fixed;
  top: 58px;
  right: 16px;
  z-index: 65;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: #FFFFFF;
  border: 1.5px solid #C4B5FD;
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.master-control-panel.hidden {
  display: none;
}

.master-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.master-panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #1E1B4B;
}

.master-state-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: #F1F5F9;
  color: #64748B;
}

.master-state-badge.is-on {
  background: #DDD6FE;
  color: #5B21B6;
}

.btn-master-close {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border-hairline);
  background: #F8FAFC;
  color: #64748B;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-master-close:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.master-toggle-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  cursor: pointer;
}

.master-toggle-box.is-on {
  background: #F5F3FF;
  border-color: #C4B5FD;
}

.master-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.master-toggle-info strong {
  font-size: 0.8rem;
  color: #1E293B;
}

.master-toggle-info small {
  font-size: 0.7rem;
  color: #64748B;
}

.master-status-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.master-pill {
  font-size: 0.71rem;
  font-weight: 700;
  text-align: center;
  padding: 4px 6px;
  border-radius: 8px;
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.master-pill.is-on {
  background: #EEF2FF;
  color: #4338CA;
  border-color: #C7D2FE;
}

.master-item-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 4px;
  border-top: 1px dashed #E2E8F0;
}

.master-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  color: #334155;
}

.master-player-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #F1F5F9;
  color: #334155;
}

.master-item-select {
  width: 100%;
  border: 1.5px solid #CBD5E1;
  border-radius: 9px;
  background: #F8FAFC;
  color: #0F172A;
  font-size: 0.76rem;
  font-family: inherit;
  padding: 4px;
  outline: none;
}

.master-item-select:focus {
  border-color: #7C3AED;
}

.master-item-select option {
  padding: 4px 6px;
  border-radius: 5px;
}

.master-item-desc {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.38;
  color: #475569;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 36px;
}

.master-oc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #B45309;
  cursor: pointer;
}

.master-oc-row.is-disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.master-item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.turn-timer-box.is-master .turn-timer-label {
  color: #5B21B6;
  font-weight: 800;
}

.turn-timer-box.is-master .turn-timer-text {
  color: #6D28D9;
}

.turn-timer-fill.is-master {
  background: linear-gradient(90deg, #8B5CF6, #6366F1);
}

/* Online Lobby Trait Mode Toggle */
.online-trait-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #F8FAFC;
  border: 1px solid var(--border-hairline);
  cursor: pointer;
}

/* Scoreboard Compact Passive Trait Badge & Floating Tooltip */
.score-trait-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 122px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: #334155;
  font-size: 0.67rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
  user-select: none;
  flex-shrink: 1;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.score-trait-badge:hover,
.score-trait-badge:focus-visible,
.score-trait-badge.is-tooltip-open {
  background: #EFF6FF;
  border-color: #60A5FA;
  color: #1D4ED8;
  outline: none;
}

.score-trait-badge.hidden {
  display: none;
}

.trait-tooltip-popover {
  position: fixed;
  z-index: 90;
  width: min(260px, calc(100vw - 24px));
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #F8FAFC;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.32);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trait-tooltip-popover.hidden {
  display: none;
}

.trait-tooltip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trait-tooltip-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #FFFFFF;
}

.trait-tooltip-owner {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  color: #E2E8F0;
}

.trait-tooltip-desc {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.38;
  color: #E2E8F0;
  word-break: keep-all;
}

.trait-tooltip-progress {
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 0.7rem;
  font-weight: 700;
  color: #93C5FD;
}

/* Global Item Banner Passive Trait Theme */
.global-item-banner.theme-trait {
  background: linear-gradient(135deg, #EEF2FF 0%, #E0F2FE 100%);
  border-color: #6366F1;
  color: #1E1B4B;
}

/* Global Item Banner High-Contrast Overdrive / Crown Warning Theme */
.global-item-banner.theme-overdrive {
  background: linear-gradient(135deg, #FEF08A 0%, #FDE047 45%, #FDBA74 100%);
  border: 2.5px solid #B91C1C;
  color: #450A0A;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.72), 0 10px 24px rgba(185, 28, 28, 0.28);
}

.global-item-banner.theme-overdrive .global-item-title {
  color: #7F1D1D;
  font-weight: 900;
}

.global-item-banner.theme-overdrive .global-item-summary {
  color: #450A0A;
  font-weight: 800;
}

.global-item-banner.theme-overdrive .global-banner-gauge {
  background: linear-gradient(90deg, #DC2626 0%, #EA580C 50%, #CA8A04 100%);
}

/* Compact Scoreboard Status Flags (Last Stand Immunity / Overdrive Skip / Crown 4-in-a-Row) */
.score-status-flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  flex: 1 0 100%;
  margin-top: 1px;
}

.score-status-flags.hidden {
  display: none;
}

.score-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.63rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.score-status-pill.flag-last-stand {
  background: #CCFBF1;
  border: 1px solid #14B8A6;
  color: #0F766E;
}

.score-status-pill.flag-skip-turn {
  background: #FEF3C7;
  border: 1px solid #D97706;
  color: #92400E;
}

.score-status-pill.flag-crown-four {
  background: linear-gradient(135deg, #FEF08A 0%, #FDE047 100%);
  border: 1px solid #CA8A04;
  color: #713F12;
}

.score-status-pill.flag-crown-four-alert {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  border: 1px solid #FACC15;
  color: #FEF9C3;
  animation: fourThreatPillPulse 1.1s ease-in-out infinite;
}

@keyframes fourThreatCardPulse {
  0%, 100% {
    border-color: #DC2626;
  }
  50% {
    border-color: #F59E0B;
  }
}

@keyframes fourThreatPillPulse {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.03);
    filter: brightness(1.08);
  }
}

body.reduce-motion .score-tile.is-four-threat,
body.reduce-motion .score-status-pill.flag-crown-four-alert {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .score-tile.is-four-threat,
  .score-status-pill.flag-crown-four-alert {
    animation: none;
  }
}

/* Master Control Passive Trait Switcher */
.master-control-panel {
  max-height: calc(100vh - 76px);
  overflow-y: auto;
}

.master-trait-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 4px;
  border-top: 1px dashed #E2E8F0;
}

.master-trait-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.master-trait-select {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  background: #F8FAFC;
  color: #0F172A;
  font-size: 0.75rem;
  font-family: inherit;
  padding: 0 6px;
  outline: none;
}

.master-trait-select:focus {
  border-color: #7C3AED;
}

.master-trait-desc {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.34;
  color: #475569;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 7px;
  padding: 5px 7px;
}

/* ==========================================================================
   First-Screen 3-Mode Lobby, Rules Modal, Room Code Bar & Local Turn Handoff
   ========================================================================== */
.btn-lobby-return {
  font-size: 0.76rem;
  padding: 5px 10px;
}

.online-room-code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
}

.online-room-code-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.online-room-code-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1E3A8A;
}

.online-room-vis-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: #DBEAFE;
  color: #1D4ED8;
}

.online-room-vis-badge.is-private {
  background: #F3E8FF;
  color: #6D28D9;
}

.start-lobby-overlay {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 20px;
  background:
    radial-gradient(circle at 12% 14%, rgba(217, 179, 114, 0.22), transparent 46%),
    radial-gradient(circle at 88% 82%, rgba(43, 108, 176, 0.18), transparent 48%),
    linear-gradient(155deg, #F6F1E7 0%, #EFE8D8 52%, #E8EEF6 100%);
  overflow-y: auto;
}

.start-lobby-overlay.hidden {
  display: none;
}

.start-lobby-shell {
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.lobby-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.lobby-title {
  margin: 0;
  font-size: 1.24rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.lobby-subtitle {
  margin: 1px 0 0;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.lobby-shared-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}

.lobby-control-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.lobby-control-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.lobby-input,
.lobby-select {
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
}

.lobby-input:focus,
.lobby-select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: #2563EB;
}

#lobbyNicknameInput {
  width: 170px;
}

#lobbyMapSelect {
  width: 196px;
}

.lobby-top-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lobby-mode-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.84fr) minmax(220px, 0.84fr) minmax(390px, 1.48fr);
  gap: 14px;
  align-items: stretch;
}

.lobby-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.lobby-card:hover {
  border-color: #94A3B8;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.11);
}

.lobby-card-online.is-room-prefilled {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18), 0 14px 32px rgba(37, 99, 235, 0.14);
}

.lobby-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.lobby-card-head-online {
  justify-content: space-between;
}

.lobby-card-head-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.lobby-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #1E293B;
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
}

.lobby-card-icon {
  font-size: 1.45rem;
  line-height: 1;
}

.lobby-card-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-primary);
}

.lobby-card-kicker {
  margin: 1px 0 0;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.lobby-card-desc {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.48;
  color: #334155;
  flex: 1 1 auto;
}

.lobby-card-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lobby-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #F1F5F9;
  color: #334155;
  border: 1px solid #E2E8F0;
}

.lobby-inline-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
}

.lobby-inline-setting .lobby-select {
  height: 32px;
  min-width: 108px;
}

.lobby-local-note {
  padding: 7px 10px;
  border-radius: 10px;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  font-size: 0.74rem;
  font-weight: 600;
  color: #166534;
}

.lobby-cta-btn {
  width: 100%;
  justify-content: center;
  min-height: 40px;
  font-size: 0.86rem;
  font-weight: 800;
}

.lobby-conn-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
  flex-shrink: 0;
}

.lobby-conn-badge.is-connected {
  background: #DCFCE7;
  color: #166534;
  border-color: #86EFAC;
}

.lobby-conn-badge.is-offline {
  background: #FEE2E2;
  color: #991B1B;
  border-color: #FCA5A5;
}

.lobby-online-error {
  margin: 0;
  padding: 7px 10px;
  border-radius: 9px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  font-size: 0.78rem;
  font-weight: 700;
}

.lobby-online-error.hidden {
  display: none;
}

.lobby-online-split {
  display: grid;
  grid-template-columns: 0.88fr 1.25fr;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.lobby-online-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px;
  border-radius: 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  min-width: 0;
}

.lobby-pane-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 800;
  color: #0F172A;
}

.lobby-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.lobby-waiting-count-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
  white-space: nowrap;
}

.lobby-waiting-count-badge.is-full {
  background: #FEF2F2;
  color: #B91C1C;
  border-color: #FECACA;
}

.lobby-pane-desc {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.42;
  color: #475569;
  flex: 1 1 auto;
}

.lobby-vis-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.lobby-vis-btn {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.lobby-vis-btn.is-active {
  background: #DBEAFE;
  border-color: #2563EB;
  color: #1D4ED8;
}

.lobby-code-row {
  display: flex;
  gap: 6px;
}

.lobby-code-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lobby-join-btn {
  flex-shrink: 0;
  min-width: 66px;
}

.lobby-quick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.lobby-quick-btn,
.lobby-refresh-btn {
  min-height: 34px;
  font-size: 0.76rem;
}

.lobby-room-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 185px;
  overflow-y: auto;
  padding-right: 2px;
}

.lobby-room-empty {
  padding: 14px 10px;
  border-radius: 9px;
  border: 1px dashed #CBD5E1;
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
  text-align: center;
  color: #64748B;
}

.lobby-room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
}

.lobby-room-item-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lobby-room-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lobby-room-host {
  font-size: 0.76rem;
  font-weight: 700;
  color: #0F172A;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-room-item-sub {
  font-size: 0.7rem;
  color: #64748B;
}

.lobby-room-enter-btn {
  flex-shrink: 0;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.74rem;
}

.lobby-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-size: 0.78rem;
  color: var(--text-primary);
}

.lobby-stats-badge {
  font-weight: 800;
  color: #1E3A8A;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.lobby-stats-values {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lobby-stats-values strong {
  color: #1D4ED8;
  font-weight: 800;
}

.lobby-stats-sep,
.lobby-footer-sep {
  color: #94A3B8;
}

.lobby-stats-note {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.lobby-footer {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--text-secondary);
}

.lobby-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.lobby-footer-ai-notice {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--text-dim);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.lobby-footer-credits,
.lobby-footer-legal {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.lobby-footer-link,
.lobby-legal-btn {
  color: #1D4ED8;
  font-weight: 700;
  font-size: 0.74rem;
  text-decoration: none;
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
}

.lobby-footer-link:hover,
.lobby-legal-btn:hover {
  text-decoration: underline;
}

/* ⚖️ 이용약관 · 개인정보처리방침 모달 */
.legal-overlay {
  position: fixed;
  inset: 0;
  z-index: 84;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.legal-overlay.hidden {
  display: none;
}

.legal-card {
  width: min(600px, 100%);
  max-height: min(85vh, 660px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
}

.legal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.legal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.legal-subtitle {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.legal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legal-tab-btn {
  min-height: 36px;
  border-radius: 9px;
  border: 1px solid #CBD5E1;
  background: #F8FAFC;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.legal-tab-btn.is-active {
  background: #DBEAFE;
  border-color: #2563EB;
  color: #1D4ED8;
}

.legal-body {
  padding: 12px 14px;
  border-radius: 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
}

.legal-body.hidden {
  display: none;
}

.legal-body ul {
  margin: 0;
  padding-left: 17px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #334155;
}

/* 📜 게임 규칙 모달 */
.rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.rules-overlay.hidden {
  display: none;
}

.rules-card {
  width: min(760px, 100%);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
}

.rules-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rules-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-primary);
}

.rules-subtitle {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

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

.rules-block {
  padding: 12px 14px;
  border-radius: 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
}

.rules-block h3 {
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #0F172A;
}

.rules-block ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  line-height: 1.46;
  color: #334155;
}

/* 📱 3인 로컬 대전 턴 전환 은닉 정보 보호 오버레이 */
.local-handoff-overlay {
  position: fixed;
  inset: 0;
  z-index: 68;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.local-handoff-overlay.hidden {
  display: none;
}

.local-handoff-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 24px 22px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.local-handoff-stone-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
}

.local-handoff-tag {
  font-size: 0.76rem;
  font-weight: 800;
  color: #334155;
}

.local-handoff-title {
  margin: 0;
  font-size: 1.32rem;
  font-weight: 900;
  color: #0F172A;
}

.local-handoff-desc {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #475569;
}

.local-handoff-confirm-btn {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  font-size: 0.94rem;
  font-weight: 800;
}

/* ==========================================================================
   Mobile & Tablet Responsive UI (<= 900px only; >= 901px desktop untouched)
   ========================================================================== */
.mobile-only-inline {
  display: none;
}

.mobile-action-info-bar {
  display: none;
}

#omokCanvas.is-slingshot-aiming {
  touch-action: none;
}

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-tap-highlight-color: transparent;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 8px 10px 24px;
    gap: 8px;
  }

  /* 1. 상단 컴팩트 헤더 */
  .top-bar {
    padding: 8px 10px;
    gap: 8px;
  }

  .brand-group {
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .brand-stones {
    padding: 4px 7px;
    gap: 4px;
  }

  .app-title {
    font-size: 0.96rem;
  }

  .app-subtitle {
    display: none;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
  }

  .mobile-only-inline {
    display: inline-flex;
  }

  .top-actions .meta-badge {
    font-size: 0.72rem;
    padding: 5px 9px;
  }

  .top-actions kbd {
    display: none;
  }

  .btn-mobile-header {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .global-item-banner {
    top: 8px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    padding: 9px 44px 11px 12px;
  }

  .global-item-summary {
    white-space: normal;
    word-break: keep-all;
  }

  /* 1단 세로 스택 재배치 (display: contents + order) */
  .main-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .left-panel,
  .board-stage,
  .right-panel {
    display: contents;
  }

  /* 2. 3인 가로형 전적 / 타이머 / 상태 바 */
  #scoreboard {
    order: 1;
    width: 100%;
    margin: 0;
    padding: 8px 9px;
  }

  #scoreboard .card-header {
    margin-bottom: 6px;
  }

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

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

  .score-tile {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 6px 7px;
    min-height: 44px;
  }

  .score-tile-main {
    justify-content: space-between;
    gap: 4px;
    width: 100%;
  }

  .score-tile-head {
    min-width: 0;
    flex: 1;
    gap: 4px;
  }

  .role-tag {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .score-value {
    font-size: 0.98rem;
    min-width: 14px;
  }

  .score-trait-badge {
    max-width: 100%;
    width: 100%;
    min-height: 44px;
    padding: 4px 8px;
    font-size: 0.72rem;
    cursor: pointer;
    justify-content: flex-start;
  }

  .score-chat-bubble {
    position: static;
    max-width: 100%;
    font-size: 0.67rem;
    padding: 3px 7px;
  }

  .score-chat-bubble::before,
  .score-chat-bubble::after {
    display: none;
  }

  #statusCard {
    order: 2;
    width: 100%;
    margin: 0;
    padding: 8px 10px;
    gap: 6px;
  }

  .status-meta-bar {
    gap: 6px;
  }

  .status-title {
    font-size: 0.92rem;
  }

  .status-sub {
    font-size: 0.74rem;
  }

  .turn-timer-box {
    padding-top: 5px;
    gap: 4px;
  }

  #onlineLobbyCard,
  #watchControls {
    order: 3;
    width: 100%;
    margin: 0;
  }

  #balanceHud {
    order: 4;
    width: 100%;
    padding: 5px 7px;
    gap: 4px;
  }

  #personalAlertBanner {
    order: 4;
    width: 100%;
  }

  #itemPromptBanner {
    order: 4;
    width: 100%;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }

  #itemPromptBanner .btn-cancel-item {
    width: 100%;
    justify-content: center;
  }

  /* 3. 화면 폭 맞춤 정사각형 오목판 */
  .board-viewport {
    order: 5;
    width: 100%;
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .board-frame {
    width: min(94vw, 56dvh);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    padding: 6px;
    margin: 0 auto;
    border-radius: 12px;
  }

  .board-center-popup {
    width: min(92%, 340px);
    padding: 11px 36px 11px 14px;
  }

  .board-center-popup-title {
    font-size: 0.95rem;
  }

  .board-center-popup-subtitle {
    font-size: 0.76rem;
  }

  /* 4. 하단 엄지 조작 컨트롤 */
  .mobile-action-info-bar {
    order: 6;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 9px 11px;
    border-radius: var(--radius-md);
    background: var(--surface-card);
    border: 1.5px solid var(--border-strong);
    box-shadow: var(--shadow-card);
    font-size: 0.8rem;
    color: var(--text-primary);
  }

  .mobile-action-info-bar.hidden {
    display: none;
  }

  .mobile-action-info-bar.is-preview {
    border-color: #2563EB;
    background: #EFF6FF;
  }

  .mobile-action-info-bar.is-item {
    border-color: #6366F1;
    background: #F5F7FF;
  }

  .mobile-action-info-bar.is-trait {
    border-color: #0EA5E9;
    background: #F0F9FF;
  }

  .mobile-action-info-bar.is-slingshot {
    border-color: #EA580C;
    background: #FFF7ED;
  }

  .mobile-info-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }

  .mobile-info-title {
    font-size: 0.86rem;
    font-weight: 800;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .mobile-info-cost-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    background: #E0E7FF;
    color: #3730A3;
    border: 1px solid #C7D2FE;
  }

  .mobile-info-cost-badge.is-free {
    background: #ECFDF5;
    color: #047857;
    border-color: #A7F3D0;
  }

  .mobile-info-desc {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
    word-break: keep-all;
  }

  .mobile-info-oc {
    margin: 0;
    padding: 5px 8px;
    border-radius: 8px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    font-size: 0.75rem;
    font-weight: 700;
    color: #92400E;
    line-height: 1.35;
    word-break: keep-all;
  }

  .mobile-info-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .mobile-info-actions .btn {
    flex: 1 1 auto;
  }

  .mobile-passive-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }

  .mobile-quick-trait-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 44px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #CBD5E1;
    background: var(--surface-subtle);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
  }

  #heldItemCard {
    order: 7;
    width: 100%;
    margin: 0;
    padding: 10px;
  }

  .my-held-box,
  .overclock-slot {
    min-height: 44px;
    padding: 8px 10px;
    cursor: pointer;
  }

  .my-held-box.is-mobile-selected,
  .overclock-slot.is-mobile-selected {
    border-color: #2563EB;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.24);
    background: #F5F9FF;
  }

  #turnOrderCard {
    order: 8;
    width: 100%;
    margin: 0;
    padding: 8px 10px;
  }

  .turn-cycle-svg {
    height: 84px;
  }

  #gameLogPanel {
    order: 9;
    width: 100%;
    margin: 0;
  }

  #settingsAccordion {
    order: 10;
    width: 100%;
    margin: 0;
  }

  .log-list {
    max-height: 180px;
  }

  .chat-message-list {
    min-height: 120px;
    max-height: 200px;
  }

  /* 모바일 입력 자동 줌 방지 (최소 16px) & 터치 영역 44px 확보 */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px !important;
  }

  .setting-select {
    width: auto;
    min-width: 148px;
    max-width: 58%;
    min-height: 44px;
  }

  .btn,
  .btn-sm,
  .btn-xs,
  .btn-cancel-item,
  .btn-codex-open,
  .btn-overclock-transfer,
  .btn-overclock-use,
  .log-tab-btn,
  .btn-collapse-toggle,
  .item-option-btn,
  .item-choice-btn,
  .laser-dir-btn,
  .codex-mode-btn,
  .codex-tab-btn,
  .codex-item-chip,
  .btn-chat-quick-popup,
  .btn-chat-emote-soon,
  .btn-chat-preset-edit,
  .btn-chat-mute,
  .btn-codex-close,
  .btn-master-close {
    min-height: 44px;
  }

  .btn-codex-close,
  .btn-master-close,
  .btn-chat-preset-edit {
    min-width: 44px;
  }

  .board-center-popup-close,
  .banner-close-btn {
    min-width: 36px;
    min-height: 36px;
  }

  /* 모달 · 오버레이 · 도감 · 결과 배너 · 마스터 패널 폭/높이 보정 */
  .nickname-overlay,
  .card-draw-overlay,
  .item-choice-overlay {
    position: fixed;
    inset: 0;
    z-index: 65;
    border-radius: 0;
    padding: 12px;
  }

  .nickname-card,
  .card-draw-modal,
  .item-choice-card,
  .codex-modal-card {
    width: 100%;
    max-width: calc(100vw - 24px);
    max-height: 85dvh;
    overflow-y: auto;
    padding: 14px;
  }

  .result-banner {
    position: fixed;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: 85dvh;
    overflow-y: auto;
    z-index: 55;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .result-banner-actions {
    width: 100%;
    justify-content: stretch;
  }

  .result-banner-actions .btn {
    flex: 1;
  }

  .master-control-panel {
    top: 10px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: calc(100vw - 24px);
    max-height: 85dvh;
    overflow-y: auto;
    z-index: 70;
  }

  .codex-overlay,
  .rules-overlay,
  .legal-overlay {
    padding: 12px;
    z-index: 84;
  }

  .start-lobby-overlay {
    align-items: flex-start;
    padding: 12px;
  }

  .lobby-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .lobby-shared-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #lobbyNicknameInput,
  #lobbyMapSelect,
  #lobbyAiDifficulty,
  #lobbyRoomCodeInput {
    width: 100%;
    font-size: 16px;
    min-height: 44px;
  }

  .lobby-top-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .lobby-top-buttons .btn,
  .lobby-cta-btn,
  .lobby-vis-btn,
  .lobby-join-btn,
  .lobby-quick-btn,
  .lobby-refresh-btn,
  .local-handoff-confirm-btn {
    min-height: 44px;
  }

  .lobby-mode-grid,
  .lobby-online-split,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .lobby-stats-bar,
  .lobby-footer,
  .lobby-footer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .lobby-footer-ai-notice {
    font-size: 0.71rem;
    line-height: 1.4;
  }

  .legal-tab-btn,
  .lobby-legal-btn {
    min-height: 44px;
  }

  .rules-card,
  .local-handoff-card,
  .legal-card {
    width: 100%;
    max-width: calc(100vw - 24px);
    max-height: 85dvh;
    overflow-y: auto;
    padding: 14px;
  }

  .codex-preview-stage {
    grid-template-columns: 1fr;
  }

  .codex-item-grid {
    max-height: 190px;
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  }

  .card-draw-cards {
    gap: 8px;
  }

  .card-draw-cards.has-traits .draw-card {
    height: 186px;
  }

  .reverse-overlay-stage {
    width: min(72vw, 72dvh, 280px);
    height: min(72vw, 72dvh, 280px);
  }
}

@media (max-width: 720px) {
  .codex-preview-stage {
    grid-template-columns: 1fr;
  }

  .codex-item-grid {
    max-height: 170px;
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding: 8px 8px 20px;
    gap: 8px;
  }

  .top-bar {
    padding: 7px 9px;
  }

  .board-frame {
    padding: 6px;
    border-radius: 12px;
  }

  .item-prompt-banner {
    flex-wrap: wrap;
  }

  .item-prompt-banner .btn-cancel-item {
    width: 100%;
    justify-content: center;
  }

  .result-banner {
    bottom: 10px;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }

  .result-banner-actions {
    width: 100%;
    justify-content: stretch;
  }

  .setting-select {
    width: 132px;
  }

  .turn-cycle-svg {
    height: 92px;
  }

  .reverse-overlay-stage {
    width: min(72vw, 72dvh, 260px);
    height: min(72vw, 72dvh, 260px);
  }
}
