/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --text: #eee;
  --text-dim: #999;
  --board-bg: #dcb35c;
  --board-line: #8b6914;
  --black-stone: #222;
  --white-stone: #f0f0f0;
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

/* Navigation */
nav {
  background: var(--surface);
  border-bottom: 2px solid var(--surface2);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

nav .logo {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--accent);
}

nav .nav-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

nav .nav-links a {
  color: var(--text-dim);
  font-size: 0.9em;
  transition: color 0.2s;
}

nav .nav-links a:hover,
nav .nav-links a.active {
  color: var(--text);
  text-decoration: none;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 60px 20px 40px;
}

.hero h1 {
  font-size: 2.5em;
  margin-bottom: 12px;
}

.hero p {
  color: var(--text-dim);
  font-size: 1.1em;
  max-width: 500px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--surface2);
}

.card h2 {
  margin-bottom: 16px;
  color: var(--accent);
}

/* Forms */
input[type="text"], input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--surface2);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1em;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #d13350;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover {
  background: #1a4a8a;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85em;
}

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

/* Lobby */
.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 30px;
}

.nickname-section {
  text-align: center;
  margin-bottom: 20px;
}

.nickname-section input {
  max-width: 300px;
  display: inline-block;
  text-align: center;
}

.room-code {
  font-size: 2em;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--accent);
  text-align: center;
  padding: 20px;
  background: var(--bg);
  border-radius: 8px;
  margin: 16px 0;
  font-family: monospace;
}

.copy-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
}

.copy-btn:hover { background: var(--accent); color: white; }

/* Room List */
.room-list {
  margin-top: 30px;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--surface2);
}

.room-item .room-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.room-item .room-code-tag {
  font-family: monospace;
  background: var(--surface2);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.waiting { background: #4caf50; }
.status-dot.playing { background: #ff9800; }

/* Game Board */
.game-container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  padding: 20px;
}

.board-wrapper {
  position: relative;
}

#board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 0;
  background: var(--board-bg);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  width: min(85vw, 540px);
  height: min(85vw, 540px);
}

.cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Board grid lines */
.cell::before {
  content: '';
  position: absolute;
  background: var(--board-line);
}

/* Horizontal lines */
.cell::before {
  width: 100%;
  height: 1px;
  top: 50%;
  left: 0;
}

.cell::after {
  content: '';
  position: absolute;
  width: 1px;
  height: 100%;
  left: 50%;
  top: 0;
  background: var(--board-line);
}

/* Edge cells - half lines */
.cell[data-x="0"]::before { width: 50%; left: 50%; }
.cell[data-x="14"]::before { width: 50%; left: 0; }
.cell[data-y="0"]::after { height: 50%; top: 50%; }
.cell[data-y="14"]::after { height: 50%; top: 0; }

/* Star points */
.cell.star-point .dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--board-line);
  border-radius: 50%;
  z-index: 1;
}

/* Stones */
.cell .stone {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  z-index: 2;
  position: relative;
}

.cell .stone.black {
  background: radial-gradient(circle at 35% 35%, #555, var(--black-stone));
  box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

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

.cell .stone.last-move {
  box-shadow: 0 0 0 3px var(--accent);
}

.cell:hover .hover-preview {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  z-index: 2;
  opacity: 0.4;
}

.hover-preview.black {
  background: var(--black-stone);
}

.hover-preview.white {
  background: var(--white-stone);
}

/* Game Info Panel */
.game-info {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 240px;
  border: 1px solid var(--surface2);
}

.game-info h3 {
  margin-bottom: 16px;
  color: var(--accent);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg);
}

.player-info.active {
  border: 2px solid var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.player-stone {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-stone.black {
  background: radial-gradient(circle at 35% 35%, #555, var(--black-stone));
}

.player-stone.white {
  background: radial-gradient(circle at 35% 35%, #fff, #ccc);
  border: 1px solid #999;
}

.turn-indicator {
  text-align: center;
  padding: 12px;
  margin: 16px 0;
  border-radius: 8px;
  font-weight: bold;
  font-size: 1.1em;
}

.turn-indicator.my-turn {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
}

.turn-indicator.opponent-turn {
  background: rgba(255, 152, 0, 0.2);
  color: #ff9800;
}

/* Waiting overlay */
.waiting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.waiting-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 400px;
}

.waiting-box .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Win Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  border: 2px solid var(--accent);
}

.modal h2 {
  font-size: 1.8em;
  margin-bottom: 12px;
}

.modal .result {
  font-size: 1.2em;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.modal .btn { margin: 6px; }

/* Content Pages */
.content-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
}

.content-page h1 {
  font-size: 2em;
  margin-bottom: 24px;
  color: var(--accent);
}

.content-page h2 {
  font-size: 1.4em;
  margin: 28px 0 12px;
  color: var(--text);
}

.content-page p {
  color: var(--text-dim);
  margin-bottom: 16px;
}

.content-page ul, .content-page ol {
  color: var(--text-dim);
  margin: 12px 0 20px 24px;
}

.content-page li {
  margin-bottom: 8px;
}

.content-page .board-diagram {
  background: var(--board-bg);
  color: #333;
  padding: 16px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.9em;
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.4;
}

/* Ad Placeholder */
.ad-banner {
  background: var(--surface);
  border: 1px dashed var(--surface2);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85em;
  margin: 20px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer */
footer {
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  padding: 24px 20px;
  margin-top: 60px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85em;
}

footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Toast Messages */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9em;
  z-index: 300;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 { font-size: 1.8em; }

  .game-container {
    flex-direction: column;
    align-items: center;
  }

  .game-info {
    width: 100%;
    min-width: unset;
  }

  nav .nav-links { gap: 10px; }
}

@media (max-width: 400px) {
  #board { padding: 8px; }
  .room-code { font-size: 1.5em; letter-spacing: 4px; }
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
