/* ── Go-Stop (GoStop) Styles ── */
/* Dark-mode compatible, matches platform.css variables */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-muted: #666;
  --accent-gold: #F0C040;
  --accent-green: #4CAF50;
  --accent-red: #F44336;
  --accent-blue: #2196F3;
  --border-subtle: rgba(255,255,255,0.08);
  --shadow-card: 0 4px 16px rgba(0,0,0,0.3);
  --card-w: clamp(42px, 9vw, 70px);
  --card-h: calc(var(--card-w) * 1.5);
  --mini-card-w: clamp(28px, 5.5vw, 42px);
  --mini-card-h: calc(var(--mini-card-w) * 1.4);
}

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Hub page (index) ─────────────────────────────── */
body.hub-page { min-height: 100vh; }

/* ── Game page ─────────────────────────────────────── */
body.game-page { min-height: 100vh; min-height: 100svh; }

/* ── Topbar ────────────────────────────────────────── */
.game-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 100;
}
.topbar-logo {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-primary); text-decoration: none;
  font-weight: 600; font-size: 0.95rem;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-back {
  color: var(--text-secondary); text-decoration: none; font-size: 0.85rem;
}
.topbar-back:hover { color: var(--accent-gold); }

/* ── Language selector ─────────────────────────────── */
.lang-selector { position: relative; }
.lang-btn {
  background: transparent; border: 1px solid var(--border-subtle);
  color: var(--text-secondary); padding: 4px 10px; border-radius: 6px;
  cursor: pointer; font-size: 0.8rem;
  display: flex; align-items: center; gap: 4px;
}
.lang-btn:hover { border-color: var(--accent-gold); color: var(--text-primary); }
.lang-dropdown {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 4px; width: 140px; z-index: 200;
  box-shadow: var(--shadow-card); max-height: 300px; overflow-x: hidden; overflow-y: auto;
}
.lang-dropdown.open { display: block; }
.lang-option {
  display: block; width: 100%; background: none; border: none;
  color: var(--text-secondary); padding: 6px 12px; text-align: left;
  cursor: pointer; font-size: 0.85rem; border-radius: 4px;
  box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lang-option:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

/* ── Site header (index page) ──────────────────────── */
.site-header {
  text-align: center; padding: 40px 16px 20px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}
.header-inner { max-width: 800px; margin: 0 auto; }
.site-title { margin: 0; }
.title-ko {
  display: block; font-size: 2.5rem; color: var(--accent-gold); letter-spacing: 0.15em;
  font-weight: 700;
}
.title-sub {
  display: block; font-size: 1.1rem; color: var(--text-secondary); margin-top: 4px;
}

/* ── Hub main ──────────────────────────────────────── */
.hub-main { max-width: 800px; margin: 0 auto; padding: 0 16px 40px; }

.section-title {
  font-size: 1.1rem; color: var(--text-secondary);
  margin: 32px 0 16px; text-transform: uppercase; letter-spacing: 0.06em;
}

/* ── Mode cards ────────────────────────────────────── */
.mode-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
}
.mode-card {
  display: block; background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 24px 20px; text-decoration: none;
  color: var(--text-primary); transition: all 0.2s ease; position: relative;
}
.mode-card:hover {
  border-color: var(--accent-gold); transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.mode-card.featured { border-color: rgba(240,192,64,0.3); }
.mode-icon { font-size: 2rem; margin-bottom: 8px; }
.mode-card h3 { margin: 0 0 6px; font-size: 1rem; }
.mode-card p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); }
.mode-badge {
  position: absolute; top: 12px; right: 12px; background: var(--accent-gold);
  color: #000; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem;
  font-weight: 600;
}

/* ── Setup section ─────────────────────────────────── */
.setup-grid { display: grid; gap: 16px; }
.setup-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 20px;
}
.setup-card h4 { margin: 0 0 12px; color: var(--accent-gold); }

.option-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border-subtle);
}
.option-row:last-child { border-bottom: none; }
.option-label { flex: 1; font-size: 0.9rem; }
.option-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Toggle switch */
.toggle-switch {
  position: relative; width: 44px; height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #555; border-radius: 24px; transition: 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-gold); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.quick-start-row { text-align: center; margin-top: 24px; }

/* ── Buttons ───────────────────────────────────────── */
.btn-large {
  padding: 12px 32px; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary {
  background: var(--accent-gold); color: #000;
  padding: 10px 24px; border: none; border-radius: 8px;
  font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { background: #e0b030; transform: translateY(-1px); }
.btn-secondary {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-subtle); padding: 10px 24px;
  border-radius: 8px; cursor: pointer; text-decoration: none;
  font-size: 0.9rem; display: inline-block;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text-primary); }

/* ── Rules section ─────────────────────────────────── */
.rules-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.rule-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 20px;
}
.rule-card h4 { margin: 0 0 12px; color: var(--accent-gold); font-size: 0.95rem; }
.rule-card ul { margin: 0; padding-left: 20px; }
.rule-card li { margin-bottom: 6px; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

/* ── Ad wrap ───────────────────────────────────────── */
.ad-wrap { margin: 24px auto; max-width: 728px; }

/* ── Footer ────────────────────────────────────────── */
.site-footer {
  text-align: center; padding: 24px 16px;
  color: var(--text-muted); font-size: 0.8rem;
}

/* ══════════════════════════════════════════════════════
   GAME PAGE STYLES
   ══════════════════════════════════════════════════════ */

.game-layout {
  max-width: 560px; margin: 0 auto; padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
}

/* ── Opponents bar ─────────────────────────────────── */
.opponents-bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.opp-panel {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 8px 10px; transition: border-color 0.3s;
}
.opp-panel.active-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(240,192,64,0.2);
}
.opp-name { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.opp-stats {
  font-size: 0.75rem; color: var(--text-secondary);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.opp-captured {
  display: flex; gap: 6px; margin-top: 4px; font-size: 0.7rem;
}
.opp-captured span {
  padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,0.05);
}
.capt-kwang { color: #FFD700; }
.capt-animal { color: #4FC3F7; }
.capt-ribbon { color: #E91E63; }
.capt-pi { color: #999; }
.opp-go {
  color: var(--accent-red); font-weight: 700; font-size: 0.8rem; margin-top: 2px;
}

/* ── Turn indicator ────────────────────────────────── */
.turn-row { text-align: center; padding: 4px 0; }
.turn-indicator {
  display: inline-block; padding: 3px 16px; border-radius: 12px;
  font-size: 0.8rem; font-weight: 600;
  background: var(--accent-gold); color: #000;
  animation: pulse-turn 1.5s ease-in-out infinite;
}
@keyframes pulse-turn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.turn-p0 { background: var(--accent-gold); }
.turn-p1 { background: var(--accent-blue); color: #fff; }
.turn-p2 { background: var(--accent-green); color: #fff; }

/* ── Field ─────────────────────────────────────────── */
.field-section {
  background: linear-gradient(135deg, rgba(0,60,0,0.25), rgba(0,40,0,0.15));
  border: 1px solid rgba(0,100,0,0.35);
  border-radius: 10px; padding: 8px; min-height: 100px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}
.field-label {
  font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 4px;
}
#field-area {
  display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
}
.field-month-group {
  display: flex; gap: 2px; margin: 2px 3px;
  background: rgba(255,255,255,0.03); border-radius: 4px; padding: 2px;
}

/* ── Stock pile ────────────────────────────────────── */
.stock-section {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 0;
}
.stock-card {
  width: var(--card-w); height: var(--card-h);
  border: 2px solid rgba(255,255,255,0.12); border-radius: 6px;
  overflow: hidden; background: #222;
}
.stock-card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.stock-label { font-size: 0.8rem; color: var(--text-secondary); }
#stock-count { font-weight: 600; color: var(--accent-gold); }

/* ── Player captured cards ─────────────────────────── */
.captured-section {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 6px 8px;
  max-height: 120px; overflow-y: auto;
}
.captured-label {
  font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 4px;
}
#player-captured {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.capt-group { display: flex; flex-direction: column; gap: 2px; }
.capt-group label { font-size: 0.65rem; color: var(--text-muted); }
.capt-cards { display: flex; gap: 2px; }
.capt-empty { font-size: 0.8rem; color: var(--text-muted); padding: 8px 0; }

/* ── Mini cards (captured) ─────────────────────────── */
.mini-card {
  width: var(--mini-card-w); height: var(--mini-card-h);
  border-radius: 3px; position: relative; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: #222;
}
.mini-card img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; border-radius: 2px;
  pointer-events: none;
}

/* ── Player info bar ───────────────────────────────── */
.player-info-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px; background: var(--bg-card);
  border: 1px solid var(--border-subtle); border-radius: 8px;
  font-size: 0.85rem; transition: border-color 0.3s;
}
.player-info-bar.active-turn {
  border-color: var(--accent-gold);
}
.pi-name { font-weight: 600; }
.pi-score { color: var(--accent-gold); }
.pi-money { color: var(--accent-green); }
.pi-go { color: var(--accent-red); font-weight: 700; }

/* ── Hand section ──────────────────────────────────── */
.hand-section {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 8px; min-height: calc(var(--card-h) + 16px);
}
.hand-label {
  font-size: 0.75rem; color: var(--accent-gold); text-align: center;
  margin-bottom: 4px; font-weight: 600;
}
#player-hand {
  display: flex; gap: 4px; justify-content: center; flex-wrap: wrap;
}

/* ── Cards ─────────────────────────────────────────── */
.card {
  width: var(--card-w); height: var(--card-h);
  border-radius: 5px; position: relative; overflow: hidden;
  border: 2px solid rgba(255,255,255,0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
  cursor: default; user-select: none;
  background: #222;
}
.card img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; border-radius: 3px;
  pointer-events: none;
}

/* Clickable cards */
.card.clickable {
  cursor: pointer;
}
.card.clickable:hover {
  transform: translateY(-6px);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 12px rgba(240,192,64,0.3);
}
.card.clickable:hover .card-bg { opacity: 0.8; }

/* Selectable field cards */
.card.selectable {
  cursor: pointer; animation: pulse-select 1s ease-in-out infinite;
  border-color: var(--accent-gold);
}
@keyframes pulse-select {
  0%, 100% { box-shadow: 0 0 6px rgba(240,192,64,0.3); }
  50% { box-shadow: 0 0 14px rgba(240,192,64,0.6); }
}

/* Kwang cards — special glow */
.card-kwang { border-color: rgba(255,215,0,0.4); box-shadow: 0 0 6px rgba(255,215,0,0.15); }

/* Cards with matching pair on field — raised + highlighted */
.card.has-match {
  transform: translateY(-6px);
  border-color: rgba(76,175,80,0.7);
  box-shadow: 0 4px 10px rgba(76,175,80,0.25);
}
.card.has-match:hover {
  transform: translateY(-10px);
  box-shadow: 0 6px 16px rgba(76,175,80,0.4);
}

/* Card placement animation */
.card-anim-place {
  animation: card-land 0.3s ease-out;
}
@keyframes card-land {
  0% { transform: scale(0.5) translateY(-30px); opacity: 0.3; }
  60% { transform: scale(1.05) translateY(2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Capture flash on captured area */
.capture-flash {
  animation: capture-glow 0.35s ease-out;
}
@keyframes capture-glow {
  0% { box-shadow: 0 0 0 rgba(240,192,64,0); }
  40% { box-shadow: 0 0 20px rgba(240,192,64,0.5); }
  100% { box-shadow: 0 0 0 rgba(240,192,64,0); }
}

/* Opponent panels — clickable cursor */
.opp-panel { cursor: pointer; }
.opp-panel:hover { border-color: rgba(255,255,255,0.2); }

/* ── Giri Modal ────────────────────────────────────── */
.giri-box { max-width: 500px; }
.giri-cards {
  display: flex; gap: 16px; justify-content: center; margin: 16px 0;
}
.giri-player {
  text-align: center; padding: 8px; border-radius: 8px;
  background: rgba(255,255,255,0.03); border: 2px solid transparent;
}
.giri-winner {
  border-color: var(--accent-gold);
  background: rgba(240,192,64,0.08);
}
.giri-name { font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
.giri-card { width: 70px; margin: 0 auto; }
.giri-card img { width: 100%; border-radius: 4px; }
.giri-month { font-size: 0.9rem; font-weight: 700; color: var(--accent-gold); margin-top: 4px; }
.giri-result {
  text-align: center; font-size: 1.1rem; font-weight: 700;
  color: var(--accent-gold); margin-top: 8px;
}

/* ── Opponent Detail Modal ─────────────────────────── */
.opp-detail-box { max-width: 480px; text-align: left; }
.opp-detail-stats {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
  font-size: 0.9rem;
}
.opp-detail-stats b { color: var(--accent-gold); }
.opp-detail-captured { margin-top: 8px; }
.opp-capt-section { margin-bottom: 10px; }
.opp-capt-label {
  font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; font-weight: 600;
}
.opp-capt-cards { display: flex; gap: 4px; flex-wrap: wrap; }
.opp-detail-card {
  width: 50px; border-radius: 3px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.opp-detail-card img { width: 100%; display: block; }

/* ── Control bar ───────────────────────────────────── */
.control-bar {
  display: flex; gap: 8px; justify-content: center; padding: 4px 0;
}
.ctrl-btn {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 0.8rem; text-decoration: none;
  transition: all 0.2s;
}
.ctrl-btn:hover { border-color: var(--accent-gold); color: var(--text-primary); }

/* ── Status bar ────────────────────────────────────── */
.status-bar {
  text-align: center; padding: 8px 16px;
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: 0.85rem; border-top: 1px solid var(--border-subtle);
  position: sticky; bottom: 0;
}

/* ── Event toast ───────────────────────────────────── */
.event-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0,0,0,0.85); color: var(--accent-gold);
  padding: 16px 32px; border-radius: 12px;
  font-size: 1.3rem; font-weight: 700;
  pointer-events: none; opacity: 0;
  transition: all 0.3s ease; z-index: 500;
}
.event-toast.show {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
}

/* ── Modals ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 16px; padding: 24px; max-width: 420px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5); text-align: center;
}
.modal-box h3 {
  margin: 0 0 16px; color: var(--accent-gold); font-size: 1.2rem;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap;
}

/* Go/Stop modal */
.gostop-modal-content { text-align: center; }
.gostop-score-display { font-size: 1.4rem; font-weight: 700; margin: 8px 0; }
.gostop-go-info { color: var(--accent-red); font-weight: 600; margin-bottom: 12px; }
.btn-go {
  background: var(--accent-red); color: #fff; border: none;
  padding: 12px 32px; border-radius: 10px; font-size: 1.1rem;
  font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.btn-go:hover { background: #d32f2f; transform: scale(1.05); }
.btn-stop {
  background: var(--accent-green); color: #fff; border: none;
  padding: 12px 32px; border-radius: 10px; font-size: 1.1rem;
  font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.btn-stop:hover { background: #388E3C; transform: scale(1.05); }

/* ── Result modal ──────────────────────────────────── */
.result-nagari { color: var(--text-secondary); }
.result-winner { color: var(--accent-gold); margin-bottom: 4px; }
.result-score { font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; }
.result-breakdown { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.badge {
  padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600;
}
.badge-kwang { background: rgba(255,215,0,0.2); color: #FFD700; }
.badge-godori { background: rgba(79,195,247,0.2); color: #4FC3F7; }
.badge-animal { background: rgba(129,212,250,0.2); color: #81D4FA; }
.badge-hong { background: rgba(255,82,82,0.2); color: #FF5252; }
.badge-cheong { background: rgba(68,138,255,0.2); color: #448AFF; }
.badge-cho { background: rgba(105,240,174,0.2); color: #69F0AE; }
.badge-ribbon { background: rgba(206,147,216,0.2); color: #CE93D8; }
.badge-pi { background: rgba(150,150,150,0.2); color: #999; }
.badge-mult { background: rgba(244,67,54,0.2); color: #F44336; }

.result-mults { margin-bottom: 12px; }
.result-payments {
  text-align: left; padding: 8px 16px; background: rgba(255,255,255,0.03);
  border-radius: 8px; margin-bottom: 12px;
}
.payment-line { font-size: 0.85rem; padding: 4px 0; }
.result-money {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px;
}
.money-line {
  font-size: 0.9rem; padding: 4px 0;
  display: flex; justify-content: center; gap: 8px;
}
.money-zero { color: var(--accent-red); font-weight: 700; }
.zero-warning {
  background: rgba(244,67,54,0.15); color: var(--accent-red);
  padding: 8px 12px; border-radius: 8px; font-size: 0.85rem; margin-top: 8px;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
  .game-layout { padding: 4px; gap: 4px; }
  .opp-panel { padding: 6px 8px; }
  .opp-stats { font-size: 0.7rem; }
  .player-info-bar { font-size: 0.8rem; padding: 4px 8px; }
  .field-section { padding: 6px; }
  .captured-section { padding: 4px 6px; max-height: 90px; }
  .hand-section { padding: 6px; }
  #player-hand { gap: 2px; }
  .control-bar { gap: 4px; }
  .ctrl-btn { padding: 4px 10px; font-size: 0.75rem; }
}

@media (max-width: 360px) {
  :root {
    --card-w: 38px;
    --mini-card-w: 24px;
  }
}
