/**
 * Kymi Games - Gomoku Style Sheet (assets/css/games/gomoku.css)
 * 100% Scoped to Gomoku game pages to prevent regressions on other games.
 * Conforms to Kymi Design System (DESIGN_SYSTEM.md & tokens.css).
 */

.gomoku-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* Breadcrumbs */
.gomoku-wrapper .breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  padding: 8px 0;
}

.gomoku-wrapper .breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.gomoku-wrapper .breadcrumbs a:hover {
  color: var(--blue);
}

/* Game Title & Header Bar */
.gomoku-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.gomoku-title-group h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--ink-heading);
  margin: 4px 0 0;
}

.gomoku-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--blue-light);
  color: var(--blue);
}

/* Lang Switcher Pill */
.lang-switch-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-alt);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
}

.lang-switch-pill a {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s ease;
}

.lang-switch-pill a.active {
  background: white;
  color: var(--ink-heading);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-weight: 700;
}

/* Main Layout Grid */
.gomoku-account-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  font-size: 14px;
}
.gomoku-account-bar #user-display { font-weight: 700; overflow-wrap: anywhere; }
.gomoku-account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-session-notice { margin: 0 0 16px; padding: 12px 16px; background: #fff7df; border-radius: var(--radius-md); font-size: 14px; }
.gomoku-side-panel { min-width: 0; }
.gomoku-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 992px) {
  .gomoku-main-grid {
    grid-template-columns: 1fr;
  }
}

/* Board Card Container */
.gomoku-board-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gomoku-board-card .game-interaction-area {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
}

@media (max-width: 600px) {
  .gomoku-board-card {
    padding: 12px;
    border-radius: var(--radius-lg);
  }
}

/* Top Dashboard inside Board Card */
.gomoku-dashboard-bar {
  width: 100%;
  max-width: 540px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.player-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stone-indicator {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.stone-indicator.black {
  background: radial-gradient(circle at 35% 35%, #4a4f5d, #141722);
}

.stone-indicator.white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #d2d6df);
  border: 1px solid #c0c5d0;
}

.player-profile-badge .player-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.player-profile-badge .player-timer {
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--muted);
}

.player-profile-badge.active-turn .player-name {
  color: var(--blue-dark);
}

.player-profile-badge.active-turn .player-timer {
  color: var(--blue);
  font-weight: 800;
}

.game-status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
}

.game-status-pill.your-turn {
  background: var(--blue-light);
  color: var(--blue);
  border-color: #c7d9fc;
}

.game-status-pill.ai-thinking {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

/* Board Outer Wrapper */
.gomoku-board-outer {
  position: relative;
  width: min(100%, 640px);
  aspect-ratio: 1 / 1;
  background: #e8caa4; /* Warm Goban color */
  background-image: radial-gradient(#dfbf97 15%, transparent 16%), radial-gradient(#d3b288 15%, transparent 16%);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(66, 44, 21, 0.25), inset 0 0 0 2px #aa7c4b;
  padding: 24px;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 600px) {
  .gomoku-board-outer {
    width: min(100%, 480px);
    padding: 16px;
  }
}

/* SVG Board Layer */
.gomoku-svg-board {
  width: 100%;
  height: 100%;
  display: block;
}

/* Intersections overlay for touch/keyboard */
.gomoku-interactive-grid {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
}

@media (max-width: 600px) {
  .gomoku-interactive-grid {
    top: 16px;
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

.gomoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
}

.gomoku-cell:focus-visible {
  box-shadow: inset 0 0 0 2px var(--blue);
  border-radius: 50%;
}

/* Rendered Stones */
.board-stone {
  width: 90%;
  height: 90%;
  border-radius: 50%;
  transition: transform 0.12s ease;
  pointer-events: none;
}

.board-stone.black {
  background: radial-gradient(circle at 35% 32%, #525866 0%, #1e222e 60%, #0d0f17 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
}

.board-stone.white {
  background: radial-gradient(circle at 35% 32%, #ffffff 0%, #edf0f5 65%, #c8cdd7 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(0,0,0,0.12);
}

/* Ghost Preview Stone */
.board-stone.preview {
  opacity: 0.45;
  transform: scale(0.92);
}

/* Last Move Ring */
.last-move-marker {
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  border: 2.5px solid #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.8);
  pointer-events: none;
}

.board-stone.black .last-move-marker {
  border-color: #f59e0b;
}

/* Foul Indicator (Renju Assist) */
.foul-marker {
  position: absolute;
  width: 60%;
  height: 60%;
  display: grid;
  place-items: center;
  color: #ef4444;
  font-size: 15px;
  font-weight: 900;
  background: rgba(254, 226, 226, 0.7);
  border-radius: 50%;
  border: 1px dashed #ef4444;
  pointer-events: none;
}

/* Colorblind Marker Option */
.colorblind-mark {
  position: absolute;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}
.board-stone.black .colorblind-mark { color: white; }
.board-stone.white .colorblind-mark { color: #202536; }

/* Quick Action Buttons below board */
.gomoku-actions-bar {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.btn-game-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-game-action:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--line-strong);
}

.btn-game-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-game-action.primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue-dark);
}

.btn-game-action.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

/* Side Panel Tabs & Controls */
.gomoku-side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-tabs-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

.side-tab-btn {
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  text-align: center;
  transition: all 0.15s ease;
}

.side-tab-btn.active {
  background: white;
  color: var(--ink-heading);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Tab Content Cards */
.side-tab-content {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.side-tab-content h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 14px;
  color: var(--ink-heading);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Control Rows */
.control-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.control-field-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.segmented-control {
  display: flex;
  gap: 4px;
  background: var(--wash);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.segmented-control button {
  flex: 1;
  padding: 7px 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented-control button.active {
  background: white;
  color: var(--ink-heading);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.switch-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.switch-toggle-row:last-child {
  border-bottom: none;
}

.switch-toggle-row span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 34px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider-round {
  background-color: var(--blue);
}

input:checked + .slider-round:before {
  transform: translateX(20px);
}

/* Active Rooms List Table */
.room-list-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--wash);
  border-radius: var(--radius-md);
  border: 1px dashed var(--line);
}

.active-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  max-height: 280px;
  overflow-y: auto;
}

.room-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.room-card-item .room-code-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--blue-dark);
}

/* Modals & Dialogs */
.gomoku-modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.gomoku-modal-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
}

.gomoku-modal-card h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 10px;
  color: var(--ink-heading);
}

.gomoku-modal-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 20px;
}

/* Tournament & Leaderboard Tables */
.table-responsive {
  overflow-x: auto;
  margin-top: 12px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ranking-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.ranking-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.ranking-table tr:hover {
  background: var(--wash);
}

.rank-pill {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 11px;
}

.rank-pill.first { background: #fef08a; color: #854d0e; }
.rank-pill.second { background: #e2e8f0; color: #334155; }
.rank-pill.third { background: #fed7aa; color: #9a3412; }
.gomoku-online-notice {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line, #dce3f0);
  border-radius: var(--radius-md, 12px);
  background: var(--wash, #f5f7fb);
  color: var(--muted, #58657a);
  font-size: 0.875rem;
  line-height: 1.55;
}

.side-tab-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}
