/* ===== Gomoku Online — Premium Dark Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-start: #0f0c29;
  --bg-mid:   #1a1a3e;
  --bg-end:   #24243e;
  --glass:    rgba(255,255,255,.06);
  --glass-border: rgba(255,255,255,.12);
  --text:     #e8e6f0;
  --text-dim: #9a97b0;
  --accent:   #7c5cfc;
  --accent-2: #ff6b9d;
  --gold:     #f0c040;
  --board-bg: #c8a260;
  --board-line: #5a4228;
  --stone-black: #1a1a1a;
  --stone-white: #f0ece4;
  --radius:   14px;
  --shadow:   0 8px 32px rgba(0,0,0,.45);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated BG particles */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(124,92,252,.3), transparent),
    radial-gradient(2px 2px at 80% 70%, rgba(255,107,157,.25), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(240,192,64,.15), transparent),
    radial-gradient(1px 1px at 10% 80%, rgba(124,92,252,.2), transparent),
    radial-gradient(1px 1px at 90% 20%, rgba(255,107,157,.15), transparent);
  animation: twinkle 8s ease-in-out infinite alternate;
  pointer-events: none; z-index: 0;
}
@keyframes twinkle {
  0%   { opacity: .4; }
  100% { opacity: .8; }
}

/* ---------- Layout ---------- */
.wrap {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto;
  padding: 28px 20px 40px;
}

h2 {
  font-weight: 800; font-size: 1.6rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 18px;
  letter-spacing: -.5px;
}

/* ---------- Glass Panels ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: border-color .3s;
}
.glass:hover {
  border-color: rgba(124,92,252,.35);
}

/* Row layout inside panels */
.row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}

/* ---------- Buttons ---------- */
button {
  font-family: inherit; font-weight: 600; font-size: .85rem;
  padding: 9px 18px;
  border: none; border-radius: 8px;
  color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #5b3fd9);
  box-shadow: 0 4px 14px rgba(124,92,252,.35);
  transition: transform .15s, box-shadow .25s, filter .25s;
  position: relative; overflow: hidden;
}
button::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,.15) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform .5s;
}
button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(124,92,252,.5);
  filter: brightness(1.1);
}
button:hover::after { transform: translateX(100%); }
button:active { transform: translateY(0); }

button.secondary {
  background: linear-gradient(135deg, #3a3858, #2a2848);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
button.secondary:hover {
  box-shadow: 0 6px 22px rgba(0,0,0,.5);
}

button.active-mode {
  background: linear-gradient(135deg, var(--accent-2), #d94a7a);
  box-shadow: 0 4px 14px rgba(255,107,157,.4);
}

/* ---------- Inputs & Select ---------- */
input, select {
  font-family: inherit; font-size: .85rem;
  padding: 9px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  color: var(--text);
  outline: none;
  transition: border-color .25s, box-shadow .25s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,252,.2);
}
input::placeholder { color: var(--text-dim); }

select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239a97b0' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select option { background: #2a2848; color: var(--text); }

label { font-weight: 500; font-size: .85rem; color: var(--text-dim); }

/* ---------- Status Badge ---------- */
#status {
  font-weight: 700; font-size: .95rem;
  padding: 10px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(124,92,252,.15), rgba(255,107,157,.1));
  border: 1px solid rgba(124,92,252,.2);
  margin-bottom: 14px;
  text-align: center;
  animation: statusPulse 3s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { border-color: rgba(124,92,252,.2); }
  50%      { border-color: rgba(124,92,252,.45); }
}

#status.winner {
  background: linear-gradient(135deg, rgba(240,192,64,.2), rgba(255,107,157,.15));
  border-color: var(--gold);
  animation: winGlow 1.2s ease-in-out infinite;
}
@keyframes winGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(240,192,64,.3); }
  50%      { box-shadow: 0 0 24px rgba(240,192,64,.6); }
}

/* ---------- Auth Info ---------- */
#auth {
  font-size: .8rem; color: var(--gold); font-weight: 600;
}

/* ---------- Room List ---------- */
.rooms {
  max-height: 200px; overflow-y: auto;
}
.rooms b { color: var(--accent-2); font-size: .9rem; }
.rooms ul { list-style: none; padding: 0; margin: 8px 0 0; }
.rooms li {
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  margin-bottom: 4px;
  font-size: .85rem;
  transition: background .2s;
  cursor: pointer;
}
.rooms li:hover { background: rgba(124,92,252,.15); }

/* ---------- Canvas Board ---------- */
.board-wrap {
  display: flex; justify-content: center;
  position: relative;
}

canvas {
  width: 100%; max-width: 580px; aspect-ratio: 1/1;
  border-radius: 12px;
  box-shadow:
    0 4px 20px rgba(0,0,0,.5),
    inset 0 0 60px rgba(0,0,0,.15);
  display: block;
  cursor: crosshair;
}

/* ---------- Mode hint ---------- */
#modeHint {
  font-size: .8rem; color: var(--text-dim); font-style: italic;
}

/* ---------- Controls layout helpers ---------- */
.controls-right {
  margin-left: auto;
  display: flex; gap: 8px; align-items: center;
}

.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .wrap { padding: 16px 12px 30px; }
  h2 { font-size: 1.2rem; margin-bottom: 12px; }
  .row { flex-direction: column; align-items: stretch; }
  .row > * { width: 100%; }
  .controls-right { margin-left: 0; flex-direction: row; }
  button { padding: 11px 14px; font-size: .9rem; }
  input, select { padding: 11px 14px; font-size: .9rem; }
  .rooms { max-height: 160px; }
  #status { font-size: .9rem; }
}
