:root {
  --felt: #1c6b45;
  --felt-dark: #114730;
  --frame: #5a3a22;
  --frame-dark: #3d2716;
  --cream: #f4efe6;
  --charcoal: #232323;
  --accent: #e8b93c;
  --panel-bg: #f7f4ee;
  --text: #23241f;
  --muted: #6b6b63;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #2a2a2a, #101010);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  padding: 24px;
}

.app {
  width: 100%;
  max-width: 920px;
}

.titlebar {
  text-align: center;
  color: var(--cream);
  margin-bottom: 20px;
}

.titlebar h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 4px 0 0;
  color: #b9b6ac;
  font-size: 0.9rem;
}

.layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.board-wrap {
  background: var(--frame);
  background-image: linear-gradient(135deg, var(--frame), var(--frame-dark));
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.message {
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  padding: 8px 4px 14px;
  min-height: 1.2em;
  font-size: 1.05rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 56px);
  grid-template-rows: repeat(8, 56px);
  background: var(--felt);
  background-image: radial-gradient(circle at 30% 20%, var(--felt), var(--felt-dark));
  border: 4px solid var(--frame-dark);
  border-radius: 4px;
}

.square {
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.square.legal {
  cursor: pointer;
}

.square.legal:hover {
  background: rgba(255, 255, 255, 0.08);
}

.disc {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.4);
  transform: scale(0);
  animation: place 220ms ease-out forwards;
}

.disc-human {
  background: radial-gradient(circle at 35% 30%, var(--cream), #d8cfba);
}

.disc-computer {
  background: radial-gradient(circle at 35% 30%, #4a4a4a, var(--charcoal));
}

.disc.flipping {
  animation: flip 320ms ease-in-out forwards;
}

@keyframes place {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes flip {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0.05); }
  100% { transform: scaleX(1); }
}

.legal-dot {
  width: 18%;
  height: 18%;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

.panel {
  background: var(--panel-bg);
  border-radius: 12px;
  padding: 20px;
  width: 260px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.scores {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.score-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2ddcf;
}

.score-card .disc {
  width: 26px;
  height: 26px;
  animation: none;
  transform: scale(1);
}

.score-card .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-card .count {
  font-size: 1.4rem;
  font-weight: 700;
}

.control-group {
  margin-bottom: 16px;
}

.control-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

#skill {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #d5cfbe;
  font-size: 0.95rem;
  background: #fff;
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #c9c2ac;
  background: #fff;
  cursor: pointer;
  transition: background 120ms ease;
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#hintBtn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.4em;
  margin-bottom: 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ccc;
  border-top-color: var(--frame);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 0;
  font-size: 0.85rem;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.modal h2 {
  margin-top: 0;
}

.modal button {
  margin-top: 12px;
}

@media (max-width: 620px) {
  .board {
    grid-template-columns: repeat(8, 11vw);
    grid-template-rows: repeat(8, 11vw);
  }
  .panel {
    width: 100%;
  }
}
