/* Boardgames — application styles */
:root {
  --bg: #0f1420;
  --bg-2: #151c2b;
  --panel: #1b2333;
  --panel-2: #212c40;
  --border: #2c3a52;
  --text: #e7edf7;
  --muted: #93a1b8;
  --accent: #4f8cff;
  --accent-2: #35d0a5;
  --danger: #ff6b6b;
  --gold: #f5c542;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #1a2338 0%, var(--bg) 55%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
.sub { color: var(--muted); margin: 0 0 1.25rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0; }
.hint.err { color: var(--danger); }
.back { color: var(--muted); font-size: 0.9rem; }
.back:hover { color: var(--text); }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 32, 0.7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: 0.3px; }
.topnav { display: flex; align-items: center; gap: 0.75rem; }
.topnav .user { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }

/* ---- layout ---- */
.scene {
  max-width: 1100px;
  margin: 1.5rem auto 4rem;
  padding: 0 1.25rem;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: #2a3752; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #3d7dff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-oidc { width: 100%; justify-content: center; padding: 0.65rem; }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn-steam { background: #1b2838; border-color: #2a3f5a; color: #fff; }
.btn-google { background: #fff; border-color: #fff; color: #1f1f1f; }
.oidc-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; border-radius: 6px; background: rgba(255,255,255,0.18);
  font-weight: 700;
}

/* ---- avatars ---- */
.avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border); background: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); font-weight: 700;
}
.avatar-lg { width: 4rem; height: 4rem; font-size: 1.5rem; }
.avatar-fallback { background: var(--panel-2); }

/* ---- game list ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.card {
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.card-img { width: 100%; height: 130px; object-fit: cover; background: var(--panel-2); }
.card-body { padding: 0.9rem 1rem 0.25rem; display: flex; flex-direction: column; gap: 0.2rem; }
.card-body h3 { margin: 0; }
.card-seats { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.card-players { color: var(--muted); font-size: 0.85rem; }
.card-cta { margin: 0.75rem 1rem 1rem; color: var(--accent); font-weight: 600; }

/* ---- login ---- */
.login { max-width: 420px; margin: 2rem auto; }
.login-games {
  list-style: none; margin: 0 0 1.5rem; padding: 0.75rem 1rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.login-games li { padding: 0.2rem 0; }
.login-games li::before { content: "▸ "; color: var(--accent); }
.login-oidc { display: flex; flex-direction: column; gap: 0.6rem; }
.login-sep { text-align: center; color: var(--muted); margin: 1.1rem 0; position: relative; }
.login-email, .login-otp { display: flex; flex-direction: column; gap: 0.6rem; }
.login label, .profile label, .create label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"] {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 0.55rem 0.7rem; font: inherit; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
.online { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); margin-top: 1.25rem; font-size: 0.9rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

/* ---- profile ---- */
.profile { max-width: 460px; }
.profile-avatar-preview { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1rem; }
.profile form { display: flex; flex-direction: column; gap: 0.8rem; }
.save-ok { color: var(--accent-2); font-size: 0.9rem; }

/* ---- parties ---- */
.parties-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 1rem; }
.create { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.create h3 { margin-bottom: 0.75rem; }
.create-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.create-row input[type="text"], .create-row input[type="password"] { flex: 1 1 160px; width: auto; }
.chk { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.9rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.4px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); }
.room-host { display: flex; align-items: center; gap: 0.5rem; }
.lock { color: var(--gold); }
.open { color: var(--accent-2); }
tr.empty td { color: var(--muted); text-align: center; padding: 1.5rem; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(5, 8, 14, 0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[style*="display: none"] { display: none !important; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; width: min(92vw, 380px); box-shadow: var(--shadow); }
.modal-box h3 { margin-bottom: 0.75rem; }
.modal-box label { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.6rem 0; color: var(--muted); font-size: 0.9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

/* ---- game screen ---- */
.game { max-width: 720px; margin: 0 auto; }
.game-head { margin-bottom: 1rem; }
.score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.side { display: flex; align-items: center; gap: 0.6rem; }
.side-1 { justify-content: flex-end; }
.side-name { font-weight: 600; }
.side-tag { font-size: 0.8rem; padding: 0.1rem 0.45rem; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); }
.tag-y { color: var(--gold); }
.tag-r { color: var(--danger); }
.scores { font-size: 1.5rem; font-weight: 700; letter-spacing: 2px; }

.board { display: grid; gap: 8px; width: min(92vw, 460px); margin: 0 auto 1.25rem; }
.board-ttt { grid-template-columns: repeat(3, 1fr); }
.board-c4 { grid-template-columns: repeat(7, 1fr); }
.cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 2px solid var(--border); border-radius: 10px;
  cursor: pointer; padding: 0; transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.cell:hover { border-color: var(--accent); background: var(--panel-2); }
.cell:active { transform: scale(0.97); }
.piece { font-size: clamp(1.4rem, 6vw, 2.4rem); font-weight: 800; line-height: 1; }
.cell.x .piece { color: var(--accent); }
.cell.o .piece { color: var(--accent-2); }
.cell.y .piece { color: var(--gold); }
.cell.r .piece { color: var(--danger); }

.game-status { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.status { font-weight: 600; }
.status.won { color: var(--gold); }
.status.draw { color: var(--muted); }

/* ---- chat ---- */
.chat {
  position: fixed; right: 16px; bottom: 16px; width: min(92vw, 340px);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; z-index: 40;
}
.chat-head { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); font-weight: 600; background: var(--panel-2); }
.chat-log { height: 240px; overflow-y: auto; padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.45rem; }
.chat-line { display: flex; align-items: baseline; gap: 0.35rem; font-size: 0.9rem; flex-wrap: wrap; }
.chat-line .who { font-weight: 600; }
.chat-line .chan { color: var(--muted); font-size: 0.8rem; }
.chat-line .arrow { color: var(--muted); }
.chat-line .ts { margin-left: auto; color: var(--muted); font-size: 0.72rem; }
.chat-form { display: flex; gap: 0.5rem; padding: 0.6rem; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; width: auto; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .chat { width: calc(100vw - 24px); right: 12px; bottom: 12px; }
  .scene { padding: 0 0.9rem; }
  .side-name { font-size: 0.9rem; }
}
