/**
 * Gomoku (Five in a Row) Styles - Traditional Go Board Theme
 * Theme: Japanese Go board, wood grain, traditional aesthetics
 * Colors: Warm wood tones, black/white stones
 */

/* ===== THEME VARIABLES ===== */
.gomoku-page {
  --board-bg: #dcb35c;
  --board-dark: #c9a227;
  --board-line: #2d1810;
  --wood-light: #e8c872;
  --wood-dark: #b8860b;
  --stone-black: #1a1a1a;
  --stone-white: #f5f5f5;
  --stone-shadow: rgba(0, 0, 0, 0.4);
  --text-dark: #2d1810;
  --text-light: #fef3c7;
  --accent-gold: #d4af37;
  --victory-green: #22c55e;
  --container-bg: #1a0f0f;
  
  text-align: center;
  min-height: 100vh;
  padding: 20px 10px;
}

/* ===== BOARD CONTAINER ===== */
.board-container {
  background: linear-gradient(145deg, var(--container-bg), var(--text-dark));
  border: 4px solid var(--wood-dark);
  border-radius: 8px;
  padding: 25px;
  max-width: 700px;
  margin: 0 auto;
  box-shadow: 
    0 0 40px rgba(184, 134, 11, 0.3),
    inset 0 0 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px var(--accent-gold);
  position: relative;
}

/* Wood corner decorations */
.wood-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid var(--accent-gold);
}

.wood-corner.top-left {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
}

.wood-corner.top-right {
  top: 8px;
  right: 8px;
  border-left: none;
  border-bottom: none;
}

.wood-corner.bottom-left {
  bottom: 8px;
  left: 8px;
  border-right: none;
  border-top: none;
}

.wood-corner.bottom-right {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
}

/* ===== GAME HEADER ===== */
.game-header {
  margin-bottom: 20px;
}

.stone-icon {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.stone-icon .stone {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-block;
}

.stone-icon .stone.black {
  background: radial-gradient(circle at 30% 30%, #555, var(--stone-black));
  box-shadow: 2px 2px 4px var(--stone-shadow);
}

.stone-icon .stone.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ddd);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-title {
  font-size: 2.5rem;
  color: var(--accent-gold);
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.1em;
}

.game-title-en {
  font-size: 1.5rem;
  color: var(--text-light);
  margin: 5px 0;
  font-weight: 300;
  letter-spacing: 0.2em;
}

.game-subtitle {
  font-size: 0.9rem;
  color: #a8a29e;
  margin: 0;
}

/* ===== MODE SELECTOR ===== */
.mode-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 15px 0 10px;
}

.mode-btn {
  background: rgba(0, 0, 0, 0.4);
  color: #a8a29e;
  border: 2px solid transparent;
  padding: 10px 20px;
  font-size: 0.95rem;
  border-radius: 25px;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-weight: 500;
}

.mode-btn:hover {
  background: rgba(212, 175, 55, 0.1);
  color: var(--text-light);
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--color-go-wood), var(--color-go-wood-dark));
  color: var(--text-light);
  border-color: var(--accent-gold);
}

/* ===== DIFFICULTY SELECTOR ===== */
.difficulty-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.difficulty-label {
  font-size: 0.85rem;
  color: #a8a29e;
  margin-right: 5px;
}

.diff-btn {
  background: rgba(0, 0, 0, 0.3);
  color: #a8a29e;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 15px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.diff-btn:hover {
  background: rgba(212, 175, 55, 0.1);
  color: var(--text-light);
}

.diff-btn.active {
  background: var(--accent-gold);
  color: var(--container-bg);
  font-weight: 600;
}

/* ===== TURN INDICATOR ===== */
.turn-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 15px 0;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 25px;
  display: inline-flex;
}

.current-stone {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-block;
  transition: all var(--transition-normal);
}

.current-stone.black {
  background: radial-gradient(circle at 30% 30%, #555, var(--stone-black));
  box-shadow: 2px 2px 6px var(--stone-shadow);
}

.current-stone.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ddd);
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
}

.turn-text {
  font-size: 1.1rem;
  color: var(--text-light);
  font-weight: 500;
}

/* ===== STATS PANEL ===== */
.stats-panel {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 15px 0;
}

.stat-box {
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 20px;
  border-radius: 8px;
  min-width: 80px;
}

.stat-box.black-score {
  border-left: 3px solid #555;
}

.stat-box.white-score {
  border-left: 3px solid var(--stone-white);
}

.stat-box.vs-box {
  border-left: 3px solid var(--accent-gold);
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: #a8a29e;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-light);
}

/* ===== GAME BOARD ===== */
.board-wrapper {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  overflow-x: auto;
  padding: 10px;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  background: linear-gradient(135deg, var(--board-bg), var(--board-dark));
  border: 3px solid var(--color-go-wood);
  border-radius: 4px;
  box-shadow: 
    inset 0 0 20px rgba(0, 0, 0, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.4);
  width: min(90vw, 500px);
  height: min(90vw, 500px);
  position: relative;
  transition: opacity 0.3s;
}

/* AI thinking state */
.game-board.ai-thinking {
  pointer-events: none;
  opacity: 0.85;
}

/* Grid lines */
.game-board::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    linear-gradient(to right, var(--board-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--board-line) 1px, transparent 1px);
  background-size: calc(100% / 15) calc(100% / 15);
  background-position: calc(100% / 30) calc(100% / 30);
  pointer-events: none;
  opacity: 0.6;
}

/* ===== BOARD CELLS ===== */
.cell {
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s;
  z-index: 1;
}

.cell:hover:not(.occupied) {
  background: rgba(255, 255, 255, 0.15);
}

.cell:hover:not(.occupied)::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: rgba(128, 128, 128, 0.3);
  pointer-events: none;
}

/* Star points (traditional Go board markers) */
.cell.star-point::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--board-line);
  border-radius: 50%;
  z-index: 0;
}

/* ===== STONES ===== */
.cell .stone-piece {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  height: 85%;
  border-radius: 50%;
  z-index: 2;
  animation: placeStone 0.2s ease-out;
}

@keyframes placeStone {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.cell .stone-piece.black {
  background: radial-gradient(circle at 35% 35%, #555, var(--stone-black) 60%, #000);
  box-shadow: 
    3px 3px 6px var(--stone-shadow),
    inset -2px -2px 4px rgba(255, 255, 255, 0.1);
}

.cell .stone-piece.white {
  background: radial-gradient(circle at 35% 35%, #fff, #e0e0e0 60%, #ccc);
  box-shadow: 
    3px 3px 6px rgba(0, 0, 0, 0.3),
    inset -2px -2px 4px rgba(0, 0, 0, 0.05);
}

/* Winning stones highlight */
.cell.winning .stone-piece {
  animation: winPulse 0.5s ease-in-out infinite alternate;
  box-shadow: 0 0 15px 5px var(--victory-green);
}

@keyframes winPulse {
  0% {
    box-shadow: 0 0 10px 3px var(--victory-green);
  }
  100% {
    box-shadow: 0 0 20px 8px var(--victory-green);
  }
}

/* ===== GAME RESULT ===== */
.game-result {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(45, 24, 16, 0.9));
  border: 2px solid var(--accent-gold);
  border-radius: 12px;
  padding: 20px 40px;
  margin: 20px auto;
  max-width: 300px;
  animation: resultReveal 0.5s ease-out;
}

@keyframes resultReveal {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.game-result #resultText {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-result.black-wins #resultText {
  color: #a8a29e;
}

.game-result.white-wins #resultText {
  color: var(--stone-white);
}

.game-result.draw #resultText {
  color: var(--accent-gold);
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.control-btn {
  background: linear-gradient(135deg, var(--color-go-wood), var(--color-go-wood-dark));
  color: var(--text-light);
  border: 2px solid var(--accent-gold);
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-weight: 600;
}

.control-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-go-wood-light), var(--color-go-wood));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

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

/* ===== KEYBOARD HINTS ===== */
.keyboard-hints {
  margin: 15px 0;
  color: #a8a29e;
  font-size: 0.85rem;
}

.keyboard-hints kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===== BACK LINK ===== */
.back-link {
  display: inline-block;
  margin-top: 15px;
  color: var(--accent-gold);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.3s;
}

.back-link:hover {
  color: var(--text-light);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .board-container {
    padding: 15px;
    margin: 10px;
  }
  
  .game-title {
    font-size: 2rem;
  }
  
  .game-title-en {
    font-size: 1.2rem;
  }
  
  .stats-panel {
    gap: 10px;
  }
  
  .stat-box {
    padding: 8px 12px;
    min-width: 60px;
  }
  
  .stat-value {
    font-size: 1.2rem;
  }
  
  .control-btn {
    padding: 10px 18px;
    font-size: 0.9rem;
  }
  
  .cell.star-point::before {
    width: 5px;
    height: 5px;
  }
}

@media (max-width: 400px) {
  .game-board {
    width: 95vw;
    height: 95vw;
  }
  
  .stats-panel {
    flex-wrap: wrap;
  }
}
