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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f0f0;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

#container {
  text-align: center;
  max-width: 360px;
  width: 100%;
}

h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #222;
  margin-bottom: 8px;
}

#score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.score-side {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.score-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.score-human .score-label { color: #e74c3c; }
.score-bot .score-label { color: #3498db; }

.score-value {
  font-size: 40px;
  font-weight: 800;
}

.score-human .score-value { color: #e74c3c; }
.score-bot .score-value { color: #3498db; }

.score-divider {
  font-size: 28px;
  font-weight: 800;
  color: #222;
}

#difficulty-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
}

#difficulty-row label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #888;
}

#difficulty {
  font-family: inherit;
  padding: 6px 30px 6px 12px;
  font-size: 20px;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid #ddd;
  border-radius: 0;
  background: transparent;
  color: #555;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M0 0l6 7 6-7z' fill='%23bbb'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

#difficulty:hover {
  border-color: #999;
  color: #333;
}

#difficulty:focus {
  border-color: #3498db;
}

#board {
  width: 50vh;
  height: 50vh;
  max-width: 360px;
  max-height: 360px;
  background: #fff;
  border: 2px solid #333;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  display: block;
  margin: 0 auto;
}

#status {
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  width: 50vh;
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  padding: 6px 16px;
  border-radius: 0 0 6px 6px;
  border: 2px solid #333;
  border-top: none;
  background: #fafafa;
  color: #888;
  transition: background 0.2s, color 0.2s;
}

#status.human-turn {
  background: rgba(231, 76, 60, 0.12);
  color: #e74c3c;
}

#status.bot-turn {
  background: rgba(52, 152, 219, 0.1);
  color: #2980b9;
}

#status.win {
  background: #d5f5e3;
  color: #27ae60;
  font-weight: 600;
  animation: flash-green 0.6s ease-in-out 3;
}

#status.lose {
  background: #d6eaf8;
  color: #2471a3;
  font-weight: 600;
  animation: flash-blue 0.6s ease-in-out 3;
}

@keyframes flash-green {
  0%, 100% { background: #d5f5e3; }
  50% { background: #27ae60; color: #fff; }
}

@keyframes flash-blue {
  0%, 100% { background: #d6eaf8; }
  50% { background: #5dade2; color: #fff; }
}

#controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

button {
  font-family: inherit;
  height: 40px;
  padding: 0 28px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: #222;
  color: #fff;
  transition: all 0.15s ease;
}

button:hover:not(:disabled) {
  background: #444;
}

button:active:not(:disabled) {
  transform: scale(0.96);
}

button:disabled {
  background: #d0d0d0;
  color: #999;
  cursor: default;
}

#undo-btn,
#new-game-btn {
  background: transparent;
  color: #222;
  border: 2px solid #222;
}

#undo-btn:hover:not(:disabled),
#new-game-btn:hover {
  background: #222;
  color: #fff;
}

#undo-btn:disabled {
  background: transparent;
  border-color: #ccc;
  color: #ccc;
}

#wiki-link {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: #999;
  text-decoration: none;
}

#wiki-link:hover {
  color: #555;
}

.bot-moved {
  animation: fade-in 1.0s ease-in-out;
}

.neutral-moved {
  animation: fade-in 1.0s ease-in-out;
}

.neutral-fading {
  animation: fade-out 0.5s ease-in-out forwards;
}

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 500px) {
  h1, #wiki-link {
    display: none;
  }

  body { padding: 8px; }

  #score { margin-bottom: 6px; }
  #difficulty-row { margin-bottom: 10px; }
  #controls { margin-bottom: 10px; }

  #container { max-width: none; }

  #board, #status {
    width: 100%;
    max-width: none;
  }

  #board {
    height: auto;
    aspect-ratio: 1;
    max-height: none;
  }
}
