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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px 36px;
  background:
    radial-gradient(900px 520px at 50% -12%, #2b3442 0%, rgba(43, 52, 66, 0) 70%),
    radial-gradient(700px 400px at 90% 110%, #2a2118 0%, rgba(42, 33, 24, 0) 70%),
    #0e1116;
  color: #e8edf4;
  font-family: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- header ---------- */

.top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fdf3e2, #e6b978);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #c99a5c;
  border: 1px solid rgba(201, 154, 92, 0.35);
  border-radius: 999px;
  padding: 3px 9px;
}

.sub {
  margin: 0;
  font-size: 13px;
  color: #8b95a5;
  line-height: 1.5;
}

/* ---------- controls ---------- */

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

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.seg-btn {
  flex: 1;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #8b95a5;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn:hover {
  color: #c9d2df;
}

.seg-btn.active {
  background: rgba(240, 185, 104, 0.14);
  color: #f5c684;
  box-shadow: inset 0 0 0 1px rgba(240, 185, 104, 0.34);
}

.panel.hide-level #levelSeg {
  display: none;
}

/* ---------- board ---------- */

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #d9a463;
  box-shadow:
    0 22px 45px -12px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px rgba(120, 70, 20, 0.25);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- status ---------- */

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 14px;
  font-weight: 600;
  color: #cdd5e0;
  transition: background 0.2s ease, color 0.2s ease;
}

.status.win {
  background: rgba(240, 185, 104, 0.14);
  border-color: rgba(240, 185, 104, 0.4);
  color: #f6c98a;
}

.status.thinking {
  color: #9aa5b5;
}

.turn-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.turn-dot.black {
  background: radial-gradient(circle at 32% 30%, #6a6a6a, #101010 70%);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.turn-dot.white {
  background: radial-gradient(circle at 32% 30%, #ffffff, #cfcabf 75%);
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.status.thinking .turn-dot {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.86);
  }
}

/* ---------- actions ---------- */

.actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.btn {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #e8edf4;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #f2bd6c, #d99843);
  border-color: rgba(0, 0, 0, 0.2);
  color: #2b1c08;
  box-shadow: 0 8px 18px -8px rgba(240, 185, 104, 0.7);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #f8c87c, #e2a24d);
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: #6f7987;
}

@media (max-width: 420px) {
  h1 {
    font-size: 26px;
  }
  .app {
    gap: 12px;
  }
}
