:root {
  --bg-deep: #1a1525;
  --bg-mid: #2a2138;
  --bg-soft: #3a3050;
  --ink: #f4ecd8;
  --ink-dim: #b8a99a;
  --moss: #7fa87a;
  --rose: #d97a8c;
  --gold: #e8c87a;
  --p1: #8db7d9;     /* 푸른 정령 */
  --p1-glow: #b5d4ee;
  --p2: #d99876;     /* 호박 정령 */
  --p2-glow: #f0bb95;
  --shadow: rgba(0,0,0,0.4);
  --line: rgba(244,236,216,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Gowun Dodum', 'Cormorant Garamond', serif;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(141,183,217,0.08), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(217,152,118,0.08), transparent 50%),
    radial-gradient(ellipse at 50% 50%, var(--bg-mid), var(--bg-deep) 80%);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  position: relative;
}

/* 별가루 배경 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 13% 22%, rgba(244,236,216,0.6), transparent),
    radial-gradient(1px 1px at 87% 35%, rgba(244,236,216,0.4), transparent),
    radial-gradient(1px 1px at 43% 78%, rgba(232,200,122,0.5), transparent),
    radial-gradient(2px 2px at 67% 12%, rgba(244,236,216,0.3), transparent),
    radial-gradient(1px 1px at 23% 65%, rgba(141,183,217,0.5), transparent),
    radial-gradient(1px 1px at 92% 82%, rgba(217,152,118,0.4), transparent);
  pointer-events: none;
  animation: twinkle 8s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.wrap {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 1;
  margin: auto 0;
}

/* 헤더 */
header {
  text-align: center;
  padding: 4px 0 6px;
}
h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-style: italic;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(232,200,122,0.3);
}
.sub {
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* 매치 스코어 */
.match-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 14px;
}
.mscore {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mname {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-dim);
}
.mscore-p1 .mname { color: var(--p1-glow); opacity: 0.7; }
.mscore-p2 .mname { color: var(--p2-glow); opacity: 0.7; }
.mpips {
  display: inline-flex;
  gap: 5px;
}
.mpip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.35;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.mscore-p1 .mpip { color: var(--p1-glow); }
.mscore-p2 .mpip { color: var(--p2-glow); }
.mpip.won {
  background: currentColor;
  opacity: 1;
  box-shadow: 0 0 10px currentColor;
  transform: scale(1.2);
}
.mpip.just-won {
  animation: pipWin 0.8s ease-out;
}
@keyframes pipWin {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.6); opacity: 1; }
  100% { transform: scale(1.2); opacity: 1; }
}
.round-label {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 0.25em;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(0,0,0,0.3);
  transition: all 0.4s;
}
.round-label.decisive {
  color: #ffd97a;
  border-color: var(--gold);
  background: rgba(232,200,122,0.15);
  box-shadow: 0 0 14px rgba(232,200,122,0.4);
  text-shadow: 0 0 8px rgba(232,200,122,0.6);
  animation: decisivePulse 2.4s ease-in-out infinite;
}
@keyframes decisivePulse {
  0%, 100% { box-shadow: 0 0 12px rgba(232,200,122,0.35); }
  50% { box-shadow: 0 0 22px rgba(232,200,122,0.7); }
}

/* 음소거 토글 */
.sound-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.3);
  color: var(--gold);
  cursor: pointer;
  font-family: 'VT323', monospace;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  z-index: 120;
}
.sound-toggle:hover {
  border-color: var(--gold);
  transform: scale(1.08);
}
.sound-toggle.muted {
  color: var(--ink-dim);
  opacity: 0.6;
}
.help-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.3);
  color: var(--gold);
  cursor: pointer;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 20px;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  z-index: 120;
}
.help-toggle:hover {
  border-color: var(--gold);
  transform: scale(1.08);
}

/* 언어 토글 */
.lang-toggle {
  position: absolute;
  top: 16px;
  left: 60px;
  height: 36px;
  min-width: 44px;
  padding: 0 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.3);
  color: var(--gold);
  cursor: pointer;
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 0.1em;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  z-index: 120;
}
.lang-toggle:hover {
  border-color: var(--gold);
  transform: scale(1.08);
}

/* 도움말 로케일 블록: 기본 숨김, 활성 로케일만 표시 */
.help-locale { display: none; }
.help-locale.active { display: block; }

/* 룰 모달 */
.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(26,21,37,0.92);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(6px);
}
.help-modal.show {
  opacity: 1;
  pointer-events: all;
}
.help-content {
  background:
    linear-gradient(180deg, rgba(42,33,56,0.95), rgba(26,21,37,0.95));
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 28px 32px;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--ink);
  position: relative;
  box-shadow: 0 0 60px rgba(232,200,122,0.15);
}
.help-content h2 {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 26px;
  color: var(--gold);
  margin-bottom: 4px;
}
.help-content .help-sub {
  color: var(--ink-dim);
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.help-content h3 {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--gold);
  margin-top: 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.help-content p, .help-content li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
}
.help-content ul {
  list-style: none;
  padding: 0;
}
.help-content li {
  padding: 3px 0;
  padding-left: 16px;
  position: relative;
}
.help-content li::before {
  content: '◦';
  position: absolute;
  left: 0;
  color: var(--gold);
  opacity: 0.6;
}
.help-content strong, .help-content .hl {
  color: var(--gold);
  font-weight: 600;
}
.help-content .pr { color: var(--p1-glow); }
.help-content .am { color: var(--p2-glow); }
.help-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 24px;
  cursor: pointer;
  font-family: 'Cormorant Garamond', serif;
  transition: color 0.2s;
}
.help-close:hover { color: var(--ink); }
.help-content kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: 'VT323', monospace;
  font-size: 13px;
  border: 1px solid var(--ink-dim);
  border-radius: 2px;
  color: var(--ink);
  background: rgba(0,0,0,0.3);
  margin: 0 1px;
}

/* 플레이어 정보 패널 */
.players {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}
.player-card {
  padding: 10px 16px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 4px;
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}
.player-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 32px rgba(232,200,122,0.2);
}
.p1-card { text-align: left; }
.p2-card { text-align: right; }
.pname {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
}
.p1-card .pname { color: var(--p1-glow); }
.p2-card .pname { color: var(--p2-glow); }
.hp-bar {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}
.p2-card .hp-bar { justify-content: flex-end; }
.heart {
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M8 14s-5-3.5-5-7.5C3 4 5 3 6.5 3S8 4 8 5c0-1 .5-2 1.5-2S13 4 13 6.5C13 10.5 8 14 8 14z'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M8 14s-5-3.5-5-7.5C3 4 5 3 6.5 3S8 4 8 5c0-1 .5-2 1.5-2S13 4 13 6.5C13 10.5 8 14 8 14z'/></svg>") no-repeat center / contain;
  color: var(--rose);
  transition: opacity 0.3s, transform 0.3s;
}
.heart.lost { opacity: 0.15; transform: scale(0.8); }

/* STAR 바 */
.stars-bar {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
  min-height: 14px;
}
.p2-card .stars-bar { justify-content: flex-end; }
.star {
  width: 14px;
  height: 14px;
  color: var(--gold);
  opacity: 0.25;
  transition: all 0.3s;
  position: relative;
}
.star::before {
  content: '★';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.star.filled {
  opacity: 1;
  text-shadow: 0 0 8px currentColor;
  animation: starGain 0.6s ease-out;
}
.star.full {
  color: var(--gold);
  filter: drop-shadow(0 0 6px var(--gold));
}
.star.hidden {
  opacity: 0.45;
  color: var(--ink-dim);
}
.star.hidden::before {
  content: '?';
  font-family: 'VT323', monospace;
  font-size: 14px;
  font-weight: bold;
}
@keyframes starGain {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.5); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.turn-counter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.turn-counter {
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 0.15em;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0,0,0,0.3);
  min-width: 110px;
}
.expansion-info {
  font-family: 'VT323', monospace;
  font-size: 11px;
  color: rgba(217,122,140,0.8);
  letter-spacing: 0.1em;
  text-align: center;
  max-width: 140px;
  line-height: 1.2;
}
.expansion-info.imminent {
  color: #ff7a8a;
  text-shadow: 0 0 8px rgba(217,60,80,0.6);
  animation: imminentPulse 1s ease-in-out infinite;
}
@keyframes imminentPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* 보드 영역 */
.board-frame {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.15));
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px 18px;
  position: relative;
  overflow: hidden;
}
.board-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(232,200,122,0.02) 0 2px, transparent 2px 4px);
  pointer-events: none;
}
.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  position: relative;
}
.cell {
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 30% 30%, rgba(244,236,216,0.04), transparent 70%),
    rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(244,236,216,0.05);
  border-radius: 2px;
  pointer-events: none;
}
.cell-num {
  position: absolute;
  top: 3px;
  left: 4px;
  font-family: 'VT323', monospace;
  font-size: 10px;
  color: var(--ink-dim);
  opacity: 0.4;
}

/* 정령 토큰 */
.spirit {
  width: 70%;
  height: 70%;
  border-radius: 50%;
  position: absolute;
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.spirit-1 {
  background:
    radial-gradient(circle at 35% 30%, var(--p1-glow), var(--p1) 60%, #4a6b8a 100%);
  box-shadow:
    0 0 24px rgba(141,183,217,0.5),
    inset -3px -3px 6px rgba(0,0,0,0.3);
}
.spirit-2 {
  background:
    radial-gradient(circle at 35% 30%, var(--p2-glow), var(--p2) 60%, #8a5a3a 100%);
  box-shadow:
    0 0 24px rgba(217,152,118,0.5),
    inset -3px -3px 6px rgba(0,0,0,0.3);
}
.spirit svg {
  width: 75%;
  height: 75%;
  animation: runeSpin 20s linear infinite;
}
.spirit-2 svg {
  animation-direction: reverse;
}
@keyframes runeSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spirit::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.2;
  filter: blur(8px);
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.15); opacity: 0.35; }
}

/* 액션 인디케이터 (어떤 액션을 했는지 표시) */
.action-fx {
  position: absolute;
  pointer-events: none;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 3px;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--gold);
  color: var(--gold);
  z-index: 10;
  animation: fxRise 1.5s ease-out forwards;
}
@keyframes fxRise {
  0% { transform: translateY(0); opacity: 0; }
  20% { transform: translateY(-10px); opacity: 1; }
  80% { transform: translateY(-30px); opacity: 1; }
  100% { transform: translateY(-45px); opacity: 0; }
}

/* 입력 패널 */
.input-panel {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  backdrop-filter: blur(8px);
}
.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.turn-label {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
}
.p1-turn .turn-label { color: var(--p1-glow); }
.p2-turn .turn-label { color: var(--p2-glow); }
.slots {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: 'VT323', monospace;
  color: var(--ink-dim);
  font-size: 16px;
}
.slot {
  display: inline-block;
  min-width: 80px;
  padding: 4px 10px;
  border: 1px dashed var(--line);
  border-radius: 3px;
  text-align: center;
  background: rgba(0,0,0,0.2);
}
.slot.filled {
  border-style: solid;
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(232,200,122,0.08);
}

.actions {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.action-btn {
  padding: 12px 6px;
  background: rgba(244,236,216,0.04);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-family: 'Gowun Dodum', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.action-btn:hover:not(:disabled) {
  background: rgba(232,200,122,0.1);
  border-color: var(--gold);
  transform: translateY(-2px);
}
.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.action-btn.locked, .ctrl-btn.locked {
  pointer-events: none;
  opacity: 0.5;
}

/* 관통 공격 버튼 - STAR 부족 시 희미, 충전 시 빛남 */
.action-pierce {
  border-color: rgba(232,200,122,0.25);
}

/* 뛰어넘기 버튼 - 인접했을 때만 활성화 */
.action-leap {
  border-color: rgba(127,168,122,0.25);
}
.action-leap.leap-ready {
  border-color: var(--moss);
  background: rgba(127,168,122,0.1);
  box-shadow: 0 0 10px rgba(127,168,122,0.25);
  animation: leapReady 2s ease-in-out infinite;
}
.action-leap.leap-ready .action-icon {
  color: var(--moss);
  text-shadow: 0 0 8px var(--moss);
}
@keyframes leapReady {
  0%, 100% { box-shadow: 0 0 10px rgba(127,168,122,0.25); }
  50% { box-shadow: 0 0 18px rgba(127,168,122,0.5); }
}
.leap-hold-slot {
  font-style: italic;
}
.action-pierce.pierce-ready {
  border-color: var(--gold);
  background: rgba(232,200,122,0.12);
  box-shadow: 0 0 12px rgba(232,200,122,0.3);
  animation: pierceReady 2s ease-in-out infinite;
}
.action-pierce.pierce-ready .action-icon {
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold);
}
@keyframes pierceReady {
  0%, 100% { box-shadow: 0 0 12px rgba(232,200,122,0.3); }
  50% { box-shadow: 0 0 20px rgba(232,200,122,0.55); }
}
.action-icon {
  font-size: 22px;
  line-height: 1;
}
.action-name {
  font-size: 13px;
  letter-spacing: 0.05em;
}
.action-hint {
  font-size: 10px;
  color: var(--ink-dim);
  font-family: 'VT323', monospace;
  letter-spacing: 0.1em;
}
.action-key {
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: var(--ink-dim);
  opacity: 0.5;
}
.action-btn { position: relative; }
.ctrl-btn kbd {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  font-family: 'VT323', monospace;
  font-size: 11px;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: 0.6;
}

.controls {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  gap: 8px;
}
.ctrl-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: 'Gowun Dodum', sans-serif;
  font-size: 13px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}
.ctrl-btn:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--ink);
}
.ctrl-btn.primary {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold);
  font-weight: 600;
}
.ctrl-btn.primary:hover:not(:disabled) {
  background: var(--p1-glow);
  border-color: var(--p1-glow);
}
.ctrl-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* 핫시트 가림막 */
.curtain {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.curtain.show {
  opacity: 1;
  pointer-events: all;
}
.curtain h2 {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 32px;
  color: var(--gold);
}
.curtain p {
  color: var(--ink-dim);
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.curtain .ctrl-btn { margin-top: 16px; padding: 14px 32px; font-size: 16px; }

/* 추첨 연출 */
.draw-stage {
  display: flex;
  gap: 60px;
  margin: 30px 0 20px;
  align-items: center;
}
.draw-rune {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.4s ease;
  opacity: 0.3;
}
.draw-rune.p1 {
  background: radial-gradient(circle at 35% 30%, var(--p1-glow), var(--p1) 60%, #4a6b8a 100%);
  box-shadow: 0 0 24px rgba(141,183,217,0.3);
}
.draw-rune.p2 {
  background: radial-gradient(circle at 35% 30%, var(--p2-glow), var(--p2) 60%, #8a5a3a 100%);
  box-shadow: 0 0 24px rgba(217,152,118,0.3);
}
.draw-rune svg {
  width: 70%;
  height: 70%;
}
.draw-rune.blinking {
  animation: drawBlink 0.18s ease-in-out infinite;
}
@keyframes drawBlink {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.draw-rune.chosen {
  opacity: 1;
  transform: scale(1.2);
  animation: drawChosen 0.6s ease-out forwards;
}
.draw-rune.p1.chosen {
  box-shadow: 0 0 60px rgba(141,183,217,0.8), 0 0 120px rgba(141,183,217,0.4);
}
.draw-rune.p2.chosen {
  box-shadow: 0 0 60px rgba(217,152,118,0.8), 0 0 120px rgba(217,152,118,0.4);
}
@keyframes drawChosen {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1.2); }
}
.draw-vs {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 28px;
  color: var(--gold);
  opacity: 0.5;
}

/* 정령 선택 화면 */
.setup-rune {
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}
.setup-rune:hover {
  opacity: 0.9;
  transform: scale(1.06);
}
.setup-rune.picked {
  opacity: 1;
  transform: scale(1.18);
}
.setup-rune.p1.picked {
  box-shadow: 0 0 60px rgba(141,183,217,0.8), 0 0 120px rgba(141,183,217,0.4);
}
.setup-rune.p2.picked {
  box-shadow: 0 0 60px rgba(217,152,118,0.8), 0 0 120px rgba(217,152,118,0.4);
}
.setup-rune.dim {
  opacity: 0.25;
  transform: scale(0.9);
}
/* 셋업 화면은 runes와 labels의 중앙이 정확히 맞도록 동일 grid 열을 사용 */
#curtainSetup .draw-stage {
  display: grid;
  grid-template-columns: 90px 40px 90px;
  column-gap: 20px;
  align-items: center;
  justify-content: center;
  margin: 30px 0 20px;
  gap: 0 20px; /* flex의 gap:60 상속 차단 */
}
#curtainSetup .draw-stage .draw-vs {
  text-align: center;
}
.setup-mode-select {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 6px;
}
.setup-mode-btn {
  padding: 7px 20px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}
.setup-mode-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.setup-mode-btn.active {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold);
  font-weight: 600;
}

.setup-diff-select {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 6px;
}
.setup-diff-btn {
  padding: 5px 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: 'VT323', monospace;
  font-size: 15px;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}
.setup-diff-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.setup-diff-btn.active {
  background: var(--p1-glow);
  color: var(--bg-deep);
  border-color: var(--p1-glow);
  font-weight: 600;
}
#setupDiffAdvanced.active {
  background: var(--gold);
  border-color: var(--gold);
}
#setupDiffMaster.active {
  background: var(--p2-glow);
  border-color: var(--p2-glow);
}

.setup-labels {
  display: grid;
  grid-template-columns: 90px 40px 90px;
  column-gap: 20px;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-dim);
  margin-top: 12px;
  letter-spacing: 0.05em;
}
.setup-labels .azure { color: var(--p1-glow); text-align: center; }
.setup-labels .amber { color: var(--p2-glow); text-align: center; }
.setup-labels .sep { color: var(--ink-dim); opacity: 0.5; text-align: center; }
.setup-result {
  min-height: 24px;
  color: var(--gold);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
  margin-top: 16px;
  letter-spacing: 0.02em;
}
.setup-result .p1c { color: var(--p1-glow); }
.setup-result .p2c { color: var(--p2-glow); }

/* 라운드 승리 배지 */
.round-badge {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 0.3em;
  padding: 4px 14px;
  border: 1px solid var(--gold);
  border-radius: 3px;
  margin-bottom: 8px;
}
.match-score-big {
  display: flex;
  align-items: center;
  gap: 24px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  margin: 12px 0;
}
.match-score-big .num {
  font-size: 40px;
  font-weight: 600;
}
.match-score-big .num.p1 { color: var(--p1-glow); }
.match-score-big .num.p2 { color: var(--p2-glow); }
.match-score-big .dash { color: var(--ink-dim); }

/* 로그 */
.log {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 16px;
  max-height: 100px;
  overflow-y: auto;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-dim);
  line-height: 1.6;
}
.log p { margin-bottom: 4px; }
.log p.new { color: var(--ink); }
.log p .p1c { color: var(--p1-glow); font-weight: 600; }
.log p .p2c { color: var(--p2-glow); font-weight: 600; }
.log p .gold-c { color: var(--gold); }

/* ━━━━ 스크롤바 디자인 (골드 · 그라데이션) ━━━━ */
/* Firefox */
.help-content,
.log {
  scrollbar-width: thin;
  scrollbar-color: rgba(232,200,122,0.4) rgba(0,0,0,0.25);
}

/* WebKit/Chromium/Safari */
.help-content::-webkit-scrollbar,
.log::-webkit-scrollbar {
  width: 8px;
}
.log::-webkit-scrollbar { width: 6px; }

.help-content::-webkit-scrollbar-track,
.log::-webkit-scrollbar-track {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15));
  border-radius: 4px;
  border: 1px solid var(--line);
  margin: 4px 0;
}

.help-content::-webkit-scrollbar-thumb,
.log::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg,
      rgba(232,200,122,0.55) 0%,
      rgba(232,200,122,0.28) 50%,
      rgba(232,200,122,0.55) 100%);
  border-radius: 4px;
  border: 1px solid rgba(232,200,122,0.22);
  box-shadow:
    inset 0 0 3px rgba(232,200,122,0.25),
    0 0 4px rgba(232,200,122,0.15);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.help-content::-webkit-scrollbar-thumb:hover,
.log::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg,
      rgba(232,200,122,0.85) 0%,
      rgba(232,200,122,0.5) 50%,
      rgba(232,200,122,0.85) 100%);
  box-shadow:
    inset 0 0 4px rgba(232,200,122,0.45),
    0 0 8px rgba(232,200,122,0.35);
}

.help-content::-webkit-scrollbar-corner,
.log::-webkit-scrollbar-corner {
  background: transparent;
}

/* 페널티 표시 */
.penalty {
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: var(--rose);
  margin-left: 6px;
}

/* 게임 종료 모달 */
.endmodal {
  position: fixed;
  inset: 0;
  background: rgba(26,21,37,0.95);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}
.endmodal.show { opacity: 1; pointer-events: all; }
.endmodal h2 {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 48px;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(232,200,122,0.5);
}
.endmodal .winner-name {
  font-size: 24px;
  color: var(--ink);
}
.endmodal .flourish {
  color: var(--ink-dim);
  font-style: italic;
  margin-bottom: 20px;
  letter-spacing: 0.1em;
}

/* 흔들림 효과 */
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(3px, -1px); }
  60% { transform: translate(-2px, 2px); }
  80% { transform: translate(2px, -2px); }
}
.hit { animation: shake 0.4s ease; }

@keyframes flash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(2.5); }
}
.flash { animation: flash 0.4s ease; }

/* 별빛 영역 기본 — 영구 구석 (가장 짙음) */
.cell.corner-base {
  position: relative;
}
.cell.corner-base::after {
  /* 영구 별빛 영역 기본 오라 */
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(217,122,140,0.25);
  border-radius: 2px;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(217,122,140,0.04) 0%, transparent 70%);
}
/* 확장된 별빛 - 중간 레벨 (2/8번) - 옅음 */
.cell.stardust-mid::after {
  border-color: rgba(217,122,140,0.18);
  background: radial-gradient(circle at center, rgba(217,122,140,0.03) 0%, transparent 70%);
}
/* 확장된 별빛 - 안쪽 레벨 (3/7번) - 더 옅음 */
.cell.stardust-outer::after {
  border-color: rgba(217,122,140,0.12);
  background: radial-gradient(circle at center, rgba(217,122,140,0.02) 0%, transparent 70%);
}
.corner-base-mark {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'VT323', monospace;
  font-size: 8px;
  color: rgba(217,122,140,0.5);
  letter-spacing: 0.1em;
  pointer-events: none;
  z-index: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ━━━━ 전투 시각 효과 ━━━━ */
.fx-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 20;
  overflow: visible;
}

/* 공격 검광 */
.fx-slash {
  position: absolute;
  pointer-events: none;
  z-index: 15;
  animation: slashFade 0.5s ease-out forwards;
}
.fx-slash svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
@keyframes slashFade {
  0% { opacity: 0; transform: scale(0.5); }
  30% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.15); }
}
.fx-slash .slash-line {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: slashDraw 0.3s ease-out forwards;
}
@keyframes slashDraw {
  to { stroke-dashoffset: 0; }
}

/* 영파 번개 아치 */
.fx-lightning {
  position: absolute;
  pointer-events: none;
  z-index: 15;
  animation: lightningFlash 0.5s ease-out forwards;
}
.fx-lightning svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
@keyframes lightningFlash {
  0% { opacity: 0; }
  15% { opacity: 1; filter: brightness(1.6); }
  30% { opacity: 0.7; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.4); }
  100% { opacity: 0; filter: brightness(1); }
}

/* 이동 잔상 */
.fx-afterimage {
  position: absolute;
  width: 55%;
  height: 55%;
  border-radius: 50%;
  pointer-events: none;
  animation: afterimageFade 0.6s ease-out forwards;
  z-index: 5;
}
.fx-afterimage.p1 {
  background:
    radial-gradient(circle at 35% 30%, var(--p1-glow), var(--p1) 60%, transparent 100%);
}
.fx-afterimage.p2 {
  background:
    radial-gradient(circle at 35% 30%, var(--p2-glow), var(--p2) 60%, transparent 100%);
}
@keyframes afterimageFade {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.7); filter: blur(3px); }
}

/* 막기 방패 */
.fx-shield {
  position: absolute;
  pointer-events: none;
  z-index: 18;
  animation: shieldPulse 0.7s ease-out forwards;
}
.fx-shield svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
@keyframes shieldPulse {
  0% { opacity: 0; transform: scale(0.6) rotate(-10deg); }
  25% { opacity: 1; transform: scale(1.05) rotate(0deg); }
  60% { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.1) rotate(10deg); }
}

/* 카운터 섬광 */
.fx-counter {
  position: absolute;
  pointer-events: none;
  z-index: 19;
  animation: counterFlash 0.8s ease-out forwards;
}
.fx-counter svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
@keyframes counterFlash {
  0% { opacity: 0; transform: scale(0.4) rotate(0deg); }
  20% { opacity: 1; transform: scale(1.05) rotate(45deg); }
  50% { opacity: 1; transform: scale(0.95) rotate(90deg); }
  100% { opacity: 0; transform: scale(1.2) rotate(180deg); }
}

/* 피격 충격파 */
.fx-impact {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 16;
  border: 2px solid rgba(217,122,140,0.9);
  animation: impactRipple 0.6s ease-out forwards;
}
@keyframes impactRipple {
  0% { opacity: 1; transform: scale(0.3); border-width: 2px; }
  100% { opacity: 0; transform: scale(1.4); border-width: 1px; }
}
.fx-impact.inner {
  animation-delay: 0.1s;
  border-color: rgba(255,107,122,0.7);
}

/* 별빛 잠식 파티클 */
.fx-stardust {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 14;
}
.fx-stardust .particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
  animation: stardustFloat 1.2s ease-out forwards;
}
@keyframes stardustFloat {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px) scale(0); }
}

/* 별빛 확장 링 (새로 별빛이 되는 칸) */
.fx-expansion-ring {
  position: absolute;
  border: 2px solid rgba(217,122,140,0.85);
  border-radius: 4px;
  pointer-events: none;
  z-index: 15;
  animation: expansionRing 1.4s ease-out forwards;
  box-shadow:
    inset 0 0 24px rgba(217,122,140,0.5),
    0 0 20px rgba(217,122,140,0.4);
}
@keyframes expansionRing {
  0% { opacity: 0; transform: scale(0.6); }
  25% { opacity: 1; transform: scale(1); }
  80% { opacity: 0.6; }
  100% { opacity: 0; transform: scale(1.05); }
}
/* 확장 파티클은 위에서 아래로 (하강) */
.fx-stardust .particle.expansion {
  background: rgba(217,122,140,0.95);
  box-shadow: 0 0 8px rgba(217,122,140,0.8);
  width: 4px;
  height: 4px;
  animation: expansionDrop 1.4s ease-in forwards;
}
@keyframes expansionDrop {
  0% { opacity: 0; transform: translateY(-10px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(60px); }
}

/* 충돌 효과 */
.fx-collision {
  position: absolute;
  font-family: 'VT323', monospace;
  color: var(--ink-dim);
  font-size: 10px;
  letter-spacing: 0.2em;
  pointer-events: none;
  z-index: 17;
  animation: collisionFx 0.8s ease-out forwards;
}
@keyframes collisionFx {
  0% { opacity: 0; transform: translate(-50%, 0); }
  30% { opacity: 1; transform: translate(-50%, -8px); }
  100% { opacity: 0; transform: translate(-50%, -20px); }
}

.board { position: relative; }
.cell.corner-warning {
  background:
    radial-gradient(circle at 30% 30%, rgba(217,122,140,0.12), transparent 70%),
    rgba(30,10,20,0.5);
  border-color: rgba(217,122,140,0.3);
}
.cell.corner-warning::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  box-shadow: inset 0 0 20px rgba(217,122,140,0.25);
  pointer-events: none;
  animation: warnPulse 2s ease-in-out infinite;
}
.cell.corner-danger {
  background:
    radial-gradient(circle at 30% 30%, rgba(217,60,80,0.22), transparent 60%),
    rgba(40,8,16,0.7);
  border-color: rgba(217,60,80,0.6);
}
.cell.corner-danger::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  box-shadow: inset 0 0 32px rgba(217,60,80,0.5);
  pointer-events: none;
  animation: dangerPulse 1.2s ease-in-out infinite;
}
@keyframes warnPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
@keyframes dangerPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.corner-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'VT323', monospace;
  font-size: 11px;
  color: var(--rose);
  letter-spacing: 0.1em;
  pointer-events: none;
  opacity: 0.7;
  z-index: 2;
  text-transform: uppercase;
}
.cell.corner-danger .corner-mark {
  color: #ff6b7a;
  opacity: 1;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(217,60,80,0.8);
}
