/* === REVERSI === */

:root {
  --bg: #0a0f0c;
  --surface: #111a14;
  --surface2: #192118;
  --board-bg: #162115;
  --board-line: #254a28;
  --primary: #d8e8d0;
  --dim: #4a6b50;
  --dark-disc: #111111;
  --dark-disc-hi: #2a2a2a;
  --light-disc: #f0efe8;
  --light-disc-hi: #ffffff;
  --action: #6bcf7f;
  --action-dark: #4aaa5a;
  --action-glow: rgba(107,207,127,0.2);
  --hint: rgba(107,207,127,0.35);
  --hint-border: rgba(107,207,127,0.7);
  --warn: #f39c12;
  --danger: #e74c3c;
  --accent: #a78bfa;
}

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

html, body {
  height: 100%;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  background: var(--bg);
  color: var(--primary);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* === SCREENS === */

.screen {
  display: none;
  width: 100%;
  max-width: 560px;
  padding: 1.5rem;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.screen.active { display: flex; }

/* === LOGO === */

.logo {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--action);
  text-shadow: 0 0 40px rgba(107,207,127,0.35);
  text-align: center;
  line-height: 1;
}

.logo-sub {
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  color: var(--dim);
  text-transform: uppercase;
  text-align: center;
  margin-top: 0.4rem;
}

/* === BUTTONS === */

.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.1s;
  text-transform: uppercase;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--action);
  color: #0a1a0c;
  box-shadow: 0 0 20px var(--action-glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--action-dark);
  box-shadow: 0 0 30px var(--action-glow);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--primary);
  border: 1px solid var(--board-line);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--dim);
  background: #232f25;
}

.btn-large { width: 100%; padding: 1rem 2rem; font-size: 1.1rem; }

.btn-small {
  font-size: 0.72rem;
  padding: 0.45rem 1rem;
}

/* === PILL SELECTORS === */

.pill-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-pill, .color-pill {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  border: 1px solid var(--board-line);
  background: var(--surface);
  color: var(--dim);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}

.diff-pill:hover, .color-pill:hover {
  border-color: var(--action);
  color: var(--primary);
}

.diff-pill.active, .color-pill.active {
  background: var(--action);
  border-color: var(--action);
  color: #0a1a0c;
}

/* === HOME SCREEN === */

.home-hero {
  text-align: center;
  padding-top: 1rem;
}

.home-tagline {
  font-size: 0.8rem;
  color: var(--dim);
  letter-spacing: 0.05em;
  line-height: 1.7;
  margin-top: 0.5rem;
}

.preview-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  background: var(--board-bg);
  border: 2px solid var(--board-line);
  border-radius: 6px;
  padding: 6px;
  width: min(220px, 55vw);
  aspect-ratio: 1;
}

.preview-cell {
  background: var(--board-bg);
  border-radius: 50%;
  aspect-ratio: 1;
}

.preview-cell.dark { background: var(--dark-disc); box-shadow: inset 0 2px 4px rgba(255,255,255,0.1); }
.preview-cell.light { background: var(--light-disc); box-shadow: inset 0 -2px 4px rgba(0,0,0,0.3); }

.how-steps {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 400px;
}

.how-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.77rem;
  color: var(--dim);
  line-height: 1.6;
}

.how-num {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--action);
  margin-top: 0.1rem;
}

.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  max-width: 360px;
}

.input-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--dim);
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.35rem;
}

.home-footer-links {
  display: flex;
  gap: 1.5rem;
  padding-bottom: 1rem;
}

.back-link {
  font-size: 0.72rem;
  color: var(--dim);
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.back-link:hover { color: var(--primary); }

.section-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  text-align: center;
}

/* === GAME SCREEN === */

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--board-line);
  gap: 0.5rem;
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 80px;
}

.score-disc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: box-shadow 0.3s;
}

.score-disc.dark {
  background: var(--dark-disc);
  border: 2px solid var(--dark-disc-hi);
  box-shadow: 0 0 0 0 transparent;
}

.score-disc.light {
  background: var(--light-disc);
  box-shadow: 0 0 0 0 transparent;
}

.score-disc.active-turn.dark {
  box-shadow: 0 0 12px 3px rgba(107,207,127,0.5);
  border-color: var(--action);
}
.score-disc.active-turn.light {
  box-shadow: 0 0 12px 3px rgba(107,207,127,0.5);
}

.score-count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.score-who {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--dim);
  text-transform: uppercase;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
}

.turn-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--dim);
  text-transform: uppercase;
  text-align: center;
}

.turn-status {
  font-size: 0.72rem;
  color: var(--action);
  text-align: center;
  min-height: 1em;
}

/* === BOARD === */

.board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  background: var(--board-line);
  border: 2px solid var(--board-line);
  border-radius: 4px;
  overflow: hidden;
  width: min(480px, calc(100vw - 2rem));
  aspect-ratio: 1;
}

.cell {
  background: var(--board-bg);
  border: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.cell:hover { background: var(--surface2); }
.cell.no-move { cursor: default; }
.cell.no-move:hover { background: var(--board-bg); }

/* Disc */
.disc {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  position: absolute;
  transition: transform 0.08s;
}

.disc.dark {
  background: radial-gradient(circle at 35% 35%, var(--dark-disc-hi), var(--dark-disc));
  box-shadow: 0 2px 6px rgba(0,0,0,0.8), inset 0 1px 2px rgba(255,255,255,0.08);
}

.disc.light {
  background: radial-gradient(circle at 35% 35%, var(--light-disc-hi), #d8d7d0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 -1px 3px rgba(0,0,0,0.2);
}

/* Flip animation */
@keyframes flip-to-dark {
  0%   { transform: scaleX(1); background: radial-gradient(circle at 35% 35%, var(--light-disc-hi), #d8d7d0); }
  49%  { transform: scaleX(0); }
  50%  { transform: scaleX(0); background: radial-gradient(circle at 35% 35%, var(--dark-disc-hi), var(--dark-disc)); }
  100% { transform: scaleX(1); background: radial-gradient(circle at 35% 35%, var(--dark-disc-hi), var(--dark-disc)); }
}

@keyframes flip-to-light {
  0%   { transform: scaleX(1); background: radial-gradient(circle at 35% 35%, var(--dark-disc-hi), var(--dark-disc)); }
  49%  { transform: scaleX(0); }
  50%  { transform: scaleX(0); background: radial-gradient(circle at 35% 35%, var(--light-disc-hi), #d8d7d0); }
  100% { transform: scaleX(1); background: radial-gradient(circle at 35% 35%, var(--light-disc-hi), #d8d7d0); }
}

@keyframes place {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.disc.placing { animation: place 0.15s ease-out forwards; }
.disc.flip-to-dark { animation: flip-to-dark 0.22s ease-in-out forwards; }
.disc.flip-to-light { animation: flip-to-light 0.22s ease-in-out forwards; }

/* Hint dot */
.hint-dot {
  width: 30%;
  height: 30%;
  border-radius: 50%;
  border: 2px solid var(--hint-border);
  background: var(--hint);
  pointer-events: none;
}

/* Coach hint */
.cell.coach-hint { background: rgba(255, 215, 0, 0.08); }

.coach-dot {
  width: 55%;
  height: 55%;
  border-radius: 50%;
  border: 2px solid #FFD700;
  background: rgba(255, 215, 0, 0.22);
  pointer-events: none;
  animation: coach-pulse 0.75s ease-in-out infinite alternate;
}

@keyframes coach-pulse {
  from { transform: scale(0.88); opacity: 0.7; }
  to   { transform: scale(1.12); opacity: 1; }
}

.btn-hint {
  background: var(--surface2);
  color: #FFD700;
  border: 1px solid rgba(255, 215, 0, 0.4);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.1s;
  text-transform: uppercase;
}
.btn-hint:hover:not(:disabled) {
  background: rgba(255, 215, 0, 0.1);
  border-color: #FFD700;
}
.btn-hint:active { transform: scale(0.97); }
.btn-hint:disabled { opacity: 0.3; cursor: not-allowed; }

/* Valid move highlight */
.cell.valid-move:hover .hint-dot { display: none; }
.cell.valid-move:hover::after {
  content: '';
  position: absolute;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 2px solid var(--action);
  background: rgba(107,207,127,0.1);
}

/* === COACH PANEL === */

#coach-panel {
  display: none;
  width: 100%;
  background: rgba(255, 215, 0, 0.05);
  border: 1px solid rgba(255, 215, 0, 0.22);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  animation: coach-fade-in 0.2s ease-out;
}

#coach-panel.active { display: block; }

@keyframes coach-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.coach-label {
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  color: #FFD700;
  margin-bottom: 0.45rem;
}

#coach-text {
  font-size: 0.75rem;
  color: #b8b090;
  line-height: 1.7;
}

#coach-text .coach-line::before {
  content: '→ ';
  color: rgba(255, 215, 0, 0.5);
}

/* === GAME ACTIONS === */

.game-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* === AI THINKING === */

.thinking-bar {
  height: 2px;
  width: 100%;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}

.thinking-bar.active { opacity: 1; }

@keyframes thinking-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.thinking-fill {
  height: 100%;
  width: 25%;
  background: var(--action);
  border-radius: 2px;
  animation: thinking-sweep 1s ease-in-out infinite;
}

/* === RESULT SCREEN === */

.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

.result-title {
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  line-height: 1.1;
}

.result-title.win { color: var(--action); text-shadow: 0 0 40px var(--action-glow); }
.result-title.loss { color: var(--danger); }
.result-title.draw { color: var(--warn); }

.result-reason {
  font-size: 0.8rem;
  color: var(--dim);
  text-align: center;
  letter-spacing: 0.05em;
}

.result-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  background: var(--board-line);
  border: 2px solid var(--board-line);
  border-radius: 4px;
  overflow: hidden;
  width: min(280px, 70vw);
  aspect-ratio: 1;
}

.result-cell {
  background: var(--board-bg);
  border: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-disc {
  width: 78%;
  height: 78%;
  border-radius: 50%;
}
.result-disc.dark { background: radial-gradient(circle at 35% 35%, var(--dark-disc-hi), var(--dark-disc)); }
.result-disc.light { background: radial-gradient(circle at 35% 35%, var(--light-disc-hi), #d8d7d0); }

.score-breakdown {
  background: var(--surface);
  border: 1px solid var(--board-line);
  border-radius: 8px;
  padding: 1.25rem;
  width: 100%;
  max-width: 340px;
}

.breakdown-title {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--surface2);
  font-size: 0.8rem;
}

.score-row:last-child { border-bottom: none; }
.score-row .label { color: var(--dim); }
.score-row .val { font-weight: 700; color: var(--primary); }
.score-row.total .label { color: var(--primary); }
.score-row.total .val { color: var(--action); font-size: 1rem; }

.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* === STATS SCREEN === */

.stats-screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.stat-block {
  background: var(--surface);
  border: 1px solid var(--board-line);
  border-radius: 8px;
  padding: 1rem 0.75rem;
  text-align: center;
}

.stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--action);
  line-height: 1;
}

.stat-label {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--dim);
  text-transform: uppercase;
  margin-top: 0.3rem;
}

/* === TOAST === */

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--board-line);
  border-radius: 6px;
  padding: 0.6rem 1.25rem;
  font-size: 0.8rem;
  color: var(--primary);
  letter-spacing: 0.05em;
  animation: toast-in 0.2s ease-out, toast-out 0.3s ease-in 2.2s forwards;
  white-space: nowrap;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* === RESPONSIVE === */

@media (max-width: 520px) {
  .screen { padding: 1rem; gap: 1rem; }
  .score-count { font-size: 1.2rem; }
}
