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

body {
  font-family: Georgia, serif;
  background: #1a1a1a;
  color: #e8e0d0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: #111;
  border-bottom: 1px solid #333;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

header h1 {
  font-size: 1.6rem;
  color: #D4A84B;
  letter-spacing: 3px;
  font-weight: normal;
}

#mode-controls { display: flex; gap: 4px; }

#mode-controls button {
  padding: 6px 18px;
  border: 1px solid #555;
  background: #222;
  color: #aaa;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 3px;
  transition: all 0.15s;
}

#mode-controls button.active, #mode-controls button:hover {
  background: #D4A84B;
  color: #111;
  border-color: #D4A84B;
}

main {
  display: flex;
  flex: 1;
  gap: 0;
  overflow: hidden;
}

/* ── Board area ── */

#board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  flex: 1;
  background: #1a1a1a;
}

#board-canvas {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  cursor: crosshair;
  border: 2px solid #5A3A0A;
  border-radius: 3px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}

#game-status {
  margin-top: 14px;
  display: flex;
  gap: 24px;
  align-items: center;
  font-size: 0.95rem;
  color: #ccc;
}

#player-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  color: #e8e0d0;
}

.stone-indicator {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid #555;
  vertical-align: middle;
}

.stone-indicator.black { background: radial-gradient(circle at 35% 35%, #888, #111); }
.stone-indicator.white { background: radial-gradient(circle at 35% 35%, #fff, #bbb); border-color: #999; }

#game-controls {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

#game-controls button, #game-controls select {
  padding: 7px 16px;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #ddd;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 3px;
  transition: background 0.15s;
}

#game-controls button:hover:not(:disabled) { background: #3a3a3a; }
#game-controls button:disabled { opacity: 0.4; cursor: default; }
#game-controls select { cursor: pointer; }

/* ── Side panel ── */

#panel {
  width: 320px;
  min-width: 280px;
  background: #111;
  border-left: 1px solid #333;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#tutorial-panel, #game-panel { padding: 24px; }

/* Tutorial progress */
#tutorial-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

#progress-bar {
  flex: 1;
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: #D4A84B;
  transition: width 0.3s ease;
}

#progress-text { font-size: 0.8rem; color: #888; white-space: nowrap; }

#tutorial-title {
  font-size: 1.2rem;
  color: #D4A84B;
  margin-bottom: 14px;
  font-weight: normal;
}

#tutorial-content {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #ccc;
  margin-bottom: 18px;
}

#tutorial-content p { margin-bottom: 10px; }
#tutorial-content ul { padding-left: 20px; }
#tutorial-content li { margin-bottom: 6px; }
#tutorial-content strong { color: #e8e0d0; }
#tutorial-content em { color: #D4A84B; font-style: normal; }

/* Challenge box */
#tutorial-challenge {
  background: #1e2a1e;
  border: 1px solid #3a5a3a;
  border-radius: 4px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.challenge-icon { font-size: 1.2rem; line-height: 1.5; }
#challenge-text { font-size: 0.88rem; color: #8fcc8f; line-height: 1.6; }

/* Step complete message */
#step-complete-msg {
  background: #1a2e1a;
  border: 1px solid #4a8a4a;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: #6fcf6f;
  text-align: center;
}

/* Nav buttons */
#tutorial-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

#tutorial-nav button {
  flex: 1;
  padding: 8px;
  border: 1px solid #555;
  background: #222;
  color: #ddd;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 3px;
  transition: background 0.15s;
}

#tutorial-nav button:hover:not(:disabled) { background: #D4A84B; color: #111; border-color: #D4A84B; }
#tutorial-nav button:disabled { opacity: 0.35; cursor: default; }

#btn-start-playing {
  width: 100%;
  padding: 10px;
  background: #D4A84B;
  color: #111;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  font-weight: bold;
  margin-bottom: 12px;
  transition: background 0.15s;
}

#btn-start-playing:hover { background: #e8c060; }

/* Hint area */
#tutorial-hint { margin-top: 4px; }
#btn-show-hint {
  background: none;
  border: 1px solid #444;
  color: #888;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  border-radius: 3px;
  transition: all 0.15s;
}
#btn-show-hint:hover { border-color: #888; color: #ccc; }
#hint-text {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #aaa;
  font-style: italic;
  line-height: 1.6;
}

/* ── Game panel ── */
#game-panel h2 { font-size: 1.1rem; color: #D4A84B; font-weight: normal; margin-bottom: 16px; }

#game-message { margin-bottom: 16px; }
.score-result {
  background: #1a1a2a;
  border: 1px solid #445;
  border-radius: 4px;
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #ccc;
}
.score-result strong { color: #D4A84B; display: block; font-size: 1.05rem; margin-bottom: 4px; }

#hints-panel h3 { font-size: 0.95rem; color: #aaa; font-weight: normal; margin-bottom: 10px; }
#hints-toggle { margin-bottom: 10px; font-size: 0.85rem; color: #888; }
#hints-toggle input { margin-right: 6px; cursor: pointer; }
#hint-content { font-size: 0.85rem; color: #aaa; line-height: 1.7; }
#hint-content p { margin-bottom: 8px; }
#hint-content p:last-child { margin-bottom: 0; }

/* ── Multiplayer panel ── */

#multiplayer-panel { padding: 24px; }
#multiplayer-panel h2 { font-size: 1.1rem; color: #D4A84B; font-weight: normal; margin-bottom: 20px; }

.mp-action-btn {
  width: 100%;
  padding: 10px;
  background: #D4A84B;
  color: #111;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
  margin-bottom: 12px;
}
.mp-action-btn:hover { background: #e8c060; }

.mp-divider { text-align: center; color: #555; margin: 4px 0 14px; font-size: 0.85rem; }

.mp-tabs { display: flex; gap: 0; margin-bottom: 18px; border-radius: 4px; overflow: hidden; border: 1px solid #444; }
.mp-tab  { flex: 1; padding: 7px; background: #1a1a1a; border: none; color: #888; font-family: inherit; font-size: 0.88rem; cursor: pointer; transition: all 0.15s; }
.mp-tab.active { background: #D4A84B; color: #111; font-weight: bold; }
.mp-tab:hover:not(.active) { background: #2a2a2a; }

.mp-email-input {
  width: 100%; padding: 8px 10px; margin-bottom: 10px;
  background: #222; border: 1px solid #444; border-radius: 3px;
  color: #eee; font-family: inherit; font-size: 0.88rem;
}
.mp-email-input:focus { outline: none; border-color: #D4A84B; }

.corr-link-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.corr-link-label { font-size: 0.85rem; color: #aaa; }
.corr-copy-btn {
  padding: 5px 12px; background: #2a2a2a; border: 1px solid #555; border-radius: 3px;
  color: #ddd; font-family: inherit; font-size: 0.82rem; cursor: pointer; transition: background 0.15s;
}
.corr-copy-btn:hover { background: #3a3a3a; }

.mp-join-row { display: flex; gap: 8px; margin-bottom: 12px; }

.mp-join-row input {
  flex: 1;
  padding: 8px 10px;
  background: #222;
  border: 1px solid #444;
  border-radius: 3px;
  color: #eee;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
}
.mp-join-row input:focus { outline: none; border-color: #D4A84B; }

.mp-join-row button {
  padding: 8px 16px;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 3px;
  color: #ddd;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.mp-join-row button:hover { background: #3a3a3a; }

.mp-error { color: #e07070; font-size: 0.85rem; margin-top: 4px; }

.mp-code-box {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 14px;
  text-align: center;
  margin-bottom: 14px;
}
.mp-code-label { display: block; font-size: 0.75rem; color: #777; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
#mp-code-value { font-size: 2rem; letter-spacing: 8px; color: #D4A84B; font-weight: bold; }

.mp-hint { font-size: 0.82rem; color: #777; margin-bottom: 16px; text-align: center; }

.mp-cancel-btn {
  width: 100%;
  padding: 8px;
  background: none;
  border: 1px solid #444;
  border-radius: 3px;
  color: #888;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.mp-cancel-btn:hover { border-color: #888; color: #ccc; }

#mp-color-label { font-size: 0.9rem; color: #aaa; margin-bottom: 16px; }

.mp-resign-btn {
  width: 100%;
  padding: 8px;
  background: none;
  border: 1px solid #633;
  border-radius: 3px;
  color: #c66;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}
.mp-resign-btn:hover { background: #2a1a1a; border-color: #c66; }

#mp-result { margin-bottom: 14px; }

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 700px) {
  main { flex-direction: column; }
  #panel { width: 100%; border-left: none; border-top: 1px solid #333; }
  #board-canvas { max-height: 55vw; }
}
