/* ══════════════════════════════════════════════
   CSS Variables & Reset
══════════════════════════════════════════════ */
:root {
  --bg-from: #0f0c29;
  --bg-via: #302b63;
  --bg-to: #24243e;
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --primary: #e94560;
  --primary-dark: #c73652;
  --secondary: #4a90d9;
  --success: #27ae60;
  --gold: #ffd700;
  --text: #f0f0f0;
  --text-muted: rgba(240, 240, 240, 0.55);
  --cell-bg: rgba(255, 255, 255, 0.08);
  --cell-border: rgba(255, 255, 255, 0.15);
  --cell-hover: rgba(255, 255, 255, 0.14);
  --cell-marked-bg: rgba(233, 69, 96, 0.18);
  --cell-marked-border: rgba(233, 69, 96, 0.6);
  --cell-bingo-bg: rgba(255, 215, 0, 0.18);
  --cell-bingo-border: #ffd700;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

/* ══ 숨김 유틸리티 ══ */
.hidden { display: none !important; }

body {
  min-height: 100%;
  background: linear-gradient(135deg, var(--bg-from), var(--bg-via), var(--bg-to));
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input { outline: none; font-family: inherit; }

/* ══════════════════════════════════════════════
   Screen System
══════════════════════════════════════════════ */
.screen {
  display: none;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
.screen.active {
  display: block;
  animation: screenEnter 0.28s ease;
}
@keyframes screenEnter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ══════════════════════════════════════════════
   Page Navigation Header
══════════════════════════════════════════════ */
.page-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(15, 12, 41, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}
.page-nav-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.page-nav-back {
  background: transparent;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  min-width: 64px;
  text-align: left;
  transition: background var(--transition);
}
.page-nav-back:hover { background: rgba(233,69,96,0.12); }
.page-nav-home {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  min-width: 64px;
  text-align: right;
  transition: background var(--transition), border-color var(--transition);
}
.page-nav-home:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}

/* ══════════════════════════════════════════════
   Hero
══════════════════════════════════════════════ */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}
.hero-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(233, 69, 96, 0.6));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.game-title {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  background: linear-gradient(135deg, #fff 30%, #e94560);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}
.game-subtitle {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 0.9rem;
}

/* ══════════════════════════════════════════════
   Card
══════════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ══════════════════════════════════════════════
   Form
══════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}
.form-input::placeholder { color: var(--text-muted); }

.code-input { font-size: 1.4rem !important; font-weight: 700; }

/* ══════════════════════════════════════════════
   Buttons
══════════════════════════════════════════════ */
.btn-primary {
  background: linear-gradient(135deg, #e94560, #c73652);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(233, 69, 96, 0.5);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary.btn-full { width: 100%; display: block; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  transition: background var(--transition);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.16); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all var(--transition);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--card-border);
  background: rgba(255, 255, 255, 0.06);
}
.btn-ghost.btn-sm { font-size: 0.8rem; padding: 6px 10px; }
.btn-ghost.btn-xs { font-size: 0.75rem; padding: 4px 8px; }

.btn-full { width: 100%; }
.btn-sm { font-size: 0.85rem; padding: 8px 16px; }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* ══════════════════════════════════════════════
   Size / Win-Lines Selectors
══════════════════════════════════════════════ */
.size-selector, .win-lines-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.size-btn, .win-btn {
  flex: 1;
  min-width: 56px;
  padding: 10px 4px;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition);
  text-align: center;
}
.size-btn:hover, .win-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.size-btn.active, .win-btn.active {
  background: rgba(233, 69, 96, 0.2);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 10px rgba(233, 69, 96, 0.25);
}

/* ══════════════════════════════════════════════
   Mode Tabs
══════════════════════════════════════════════ */
.mode-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.mode-tab {
  flex: 1;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  transition: all var(--transition);
}
.mode-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(233, 69, 96, 0.4);
}

/* Multi actions */
.multi-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.multi-actions .btn-primary, .multi-actions .btn-secondary {
  flex: 1;
  padding: 13px 8px;
}

/* ══════════════════════════════════════════════
   Lobby
══════════════════════════════════════════════ */
.screen-header { margin-bottom: 16px; }
.screen-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.screen-sub { color: var(--text-muted); font-size: 0.9rem; }

.room-code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.room-code-label { color: var(--text-muted); font-size: 0.85rem; }
.room-code-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--gold);
  flex: 1;
  text-align: center;
  text-shadow: 0 0 12px rgba(255,215,0,0.4);
}

.section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  display: block;
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.players-list { display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}
.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #c73652);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.player-name { flex: 1; font-weight: 600; }
.player-badges { display: flex; gap: 6px; flex-shrink: 0; }
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-host { background: rgba(255,215,0,0.2); color: var(--gold); border: 1px solid rgba(255,215,0,0.4); }
.badge-ready { background: rgba(39,174,96,0.2); color: #2ecc71; border: 1px solid rgba(46,204,113,0.4); }
.badge-waiting { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--card-border); }

.settings-readonly p {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 8px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.settings-readonly strong { color: var(--text); }

/* ══════════════════════════════════════════════
   Setup Board
══════════════════════════════════════════════ */
.board-wrapper {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.bingo-board {
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 3), 1fr);
  gap: clamp(4px, 1.5vw, 8px);
  width: 100%;
  max-width: min(96vw, 520px);
}

.bingo-cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--cell-bg);
  border: 1.5px solid var(--cell-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-break: break-all;
  font-size: clamp(9px, 2.8vw, 15px);
  font-weight: 600;
  padding: clamp(2px, 1vw, 6px);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  line-height: 1.2;
  color: var(--text);
  touch-action: manipulation;
}
.bingo-cell:hover { background: var(--cell-hover); border-color: rgba(255,255,255,0.3); }
.bingo-cell:active { transform: scale(0.95); }

/* Empty cell (setup) */
.bingo-cell.empty .plus-icon {
  font-size: 1.4em;
  opacity: 0.35;
  font-weight: 300;
}

/* Filled cell */
.bingo-cell.filled { border-color: rgba(255,255,255,0.25); }

/* Marked cell */
.bingo-cell.marked {
  background: var(--cell-marked-bg);
  border-color: var(--cell-marked-border);
  color: rgba(240,240,240,0.5);
}
.bingo-cell.marked .cell-text { text-decoration: line-through; }

/* X overlay */
.bingo-cell.marked::before,
.bingo-cell.marked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 12%;
  width: 76%;
  height: clamp(2px, 0.5vw, 4px);
  background: rgba(233, 69, 96, 0.75);
  border-radius: 2px;
  pointer-events: none;
}
.bingo-cell.marked::before { transform: translateY(-50%) rotate(45deg); }
.bingo-cell.marked::after  { transform: translateY(-50%) rotate(-45deg); }

/* Bingo line */
.bingo-cell.bingo-line {
  background: var(--cell-bingo-bg) !important;
  border-color: var(--cell-bingo-border) !important;
  box-shadow: 0 0 12px rgba(255,215,0,0.35);
  color: var(--text) !important;
}
.bingo-cell.bingo-line .cell-text { text-decoration: none !important; }

/* Can mark (your turn) */
.bingo-cell.can-mark:hover {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

/* Auto-marked (상대 단어와 매칭되어 자동 X) */
@keyframes autoMarkPulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 144, 217, 0.7); }
  50%  { box-shadow: 0 0 0 8px rgba(74, 144, 217, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 144, 217, 0); }
}
.bingo-cell.auto-marked {
  animation: markPop 0.35s ease, autoMarkPulse 0.6s ease 0.1s !important;
}

/* Just marked animation */
@keyframes markPop {
  0% { transform: scale(1); }
  40% { transform: scale(0.88); }
  70% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.bingo-cell.just-marked { animation: markPop 0.35s ease; }

/* Setup footer */
.setup-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.setup-footer .btn-primary { flex: 1; min-width: 120px; }

/* Waiting panel */
.waiting-panel {
  text-align: center;
  padding: 24px;
  margin-top: 16px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ready-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.ready-chip {
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}
.ready-chip.ready { background: rgba(39,174,96,0.2); color: #2ecc71; }
.ready-chip.waiting { background: rgba(255,255,255,0.07); color: var(--text-muted); }

/* ══════════════════════════════════════════════
   Game Screen
══════════════════════════════════════════════ */
.turn-banner {
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.3s ease;
}
.turn-banner.my-turn {
  background: linear-gradient(135deg, rgba(233,69,96,0.25), rgba(199,54,82,0.15));
  border: 1.5px solid rgba(233,69,96,0.5);
  color: #ff8fa3;
  animation: pulse-border 1.5s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233,69,96,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(233,69,96,0); }
}
.turn-banner.other-turn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

.word-history {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 10px;
}
.word-history-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 3px;
  flex-shrink: 0;
}
.word-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 72px;
  overflow-y: auto;
}
.word-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 0.78rem;
}
.word-chip:first-child {
  background: rgba(233,69,96,0.25);
  border: 1px solid rgba(233,69,96,0.4);
}
.word-chip-name {
  color: var(--text-muted);
  font-size: 0.7rem;
}
.word-chip-word {
  color: var(--text);
  font-weight: 600;
}

.my-board-section { margin-bottom: 24px; }

.bingo-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,215,0,0.15);
  color: var(--gold);
  border: 1px solid rgba(255,215,0,0.3);
  transition: all 0.3s;
}
.bingo-badge.updated {
  animation: bingoPop 0.4s ease;
}
@keyframes bingoPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); background: rgba(255,215,0,0.3); }
  100% { transform: scale(1); }
}

/* Other boards */
.other-boards-section { display: flex; flex-direction: column; gap: 16px; }
.other-board-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(10px);
}
.other-board-card.active-turn {
  border-color: rgba(74,144,217,0.5);
  box-shadow: 0 0 0 2px rgba(74,144,217,0.2);
}
.other-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.other-board-name {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary);
  animation: pulseDot 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}
.other-bingo-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255,215,0,0.12);
  color: var(--gold);
}

/* Other boards use smaller cells */
.other-board-card .bingo-board { max-width: 320px; margin: 0 auto; }
.other-board-card .bingo-cell {
  font-size: clamp(7px, 2.2vw, 11px);
  cursor: default;
}
.other-board-card .bingo-cell:hover { background: var(--cell-bg); }

.solo-goal {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 16px;
  padding: 10px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm);
}

/* ══════════════════════════════════════════════
   Modals
══════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, #1a1a3a, #252550);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.15); }

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-footer .btn-secondary, .modal-footer .btn-primary { flex: 1; }

/* Drawing section */
.drawing-section {
  margin-bottom: 16px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.drawing-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  font-size: 0.9rem;
}
.pen-icon { font-size: 1rem; }
.drawing-label span:nth-child(2) { flex: 1; color: var(--text-muted); }

.canvas-wrap {
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 240px;
}
.canvas-wrap.collapsed { max-height: 0; }

#drawing-canvas {
  display: block;
  width: 100%;
  height: 160px;
  background: rgba(255,255,255,0.96);
  cursor: crosshair;
  touch-action: none;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid var(--card-border);
}
.canvas-hint { font-size: 0.75rem; color: var(--text-muted); }

.text-input-wrap { margin-bottom: 4px; }
.text-input-wrap .form-input { font-size: 1.05rem; }

/* ══════════════════════════════════════════════
   Winner Modal
══════════════════════════════════════════════ */
.winner-modal {
  text-align: center;
  overflow: hidden;
}
.winner-trophy {
  font-size: 4rem;
  margin-bottom: 8px;
  animation: trophyBounce 0.6s ease;
}
@keyframes trophyBounce {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}
.winner-name {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.winner-detail { color: var(--text-muted); font-size: 1rem; }
.winner-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.winner-actions .btn-secondary,
.winner-actions .btn-primary { flex: 1; }

/* 수동 마킹 바 */
.manual-mark-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.btn-manual {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-manual:hover {
  border-color: rgba(233, 69, 96, 0.5);
  color: var(--text);
  background: rgba(233, 69, 96, 0.08);
}
.btn-manual.active {
  background: rgba(233, 69, 96, 0.18);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.25);
}
.btn-manual-icon {
  font-size: 1rem;
  font-weight: 800;
}
.manual-mark-hint {
  font-size: 0.82rem;
  color: var(--primary);
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 수동 마킹 모드일 때 보드 테두리 */
.bingo-board.manual-mode .bingo-cell:not(.marked) {
  border-color: rgba(233, 69, 96, 0.45);
  cursor: crosshair;
}
.bingo-board.manual-mode .bingo-cell:not(.marked):hover {
  background: rgba(233, 69, 96, 0.15);
  border-color: var(--primary);
}

/* 게임 종료 후 재시작 바 */
.game-over-bar {
  margin-top: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

/* Confetti */
#confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

/* ══════════════════════════════════════════════
   Toast
══════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(90vw, 400px);
}
.toast {
  background: rgba(20, 20, 40, 0.95);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.9rem;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  backdrop-filter: blur(12px);
  pointer-events: all;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  width: 100%;
  text-align: center;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-info { border-left: 3px solid var(--secondary); }
.toast.toast-warn { border-left: 3px solid var(--gold); }
.toast.toast-error { border-left: 3px solid var(--primary); }
@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateY(12px); opacity: 0; }
}

/* ══════════════════════════════════════════════
   Shake animation (not-your-turn)
══════════════════════════════════════════════ */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

/* ══════════════════════════════════════════════
   Responsive: Tablet / Desktop
══════════════════════════════════════════════ */
@media (min-width: 600px) {
  .container { padding: 32px 24px; }
  .card { padding: 28px; }
  .bingo-cell { border-radius: 10px; }
  .other-boards-section { flex-direction: row; flex-wrap: wrap; }
  .other-board-card { flex: 1; min-width: 240px; }
}

@media (min-width: 900px) {
  .screen-game .container { max-width: 900px; }
  .game-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

/* Larger touch targets on mobile */
@media (max-width: 480px) {
  .setup-footer { justify-content: space-between; }
  .setup-footer .btn-primary { padding: 14px; }
}
