/* Shared styles for individual game pages */
:root {
  --bg: #0a0f1f;
  --surface: #141d38;
  --border: #253158;
  --text: #e9eefb;
  --muted: #92a0c6;
  --accent: #22d3ee;
  --accent2: #a855f7;
  --radius: 16px;
}
[data-theme="light"] {
  --bg: #eef1f8;
  --surface: #ffffff;
  --border: #d4dbe8;
  --text: #0e1630;
  --muted: #5a6a8a;
}

.game-topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.game-back {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); display: grid; place-items: center;
  color: var(--muted); text-decoration: none; font-size: 1.1rem; flex-shrink: 0;
}
.game-back:hover { color: var(--accent); border-color: var(--accent); }
.game-title { flex: 1; min-width: 0; }
.game-title h1 { margin: 0; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-title p { margin: 0; color: var(--muted); font-size: .85rem; }
.theme-toggle {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); display: grid; place-items: center; flex-shrink: 0;
  background: transparent; color: var(--text); cursor: pointer;
}
.theme-toggle svg { width: 16px; height: 16px; }
.icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: block; }

.game-stage { padding: 1.5rem; max-width: 640px; margin: 0 auto; }
.game-status {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
  margin-bottom: 1rem;
}
.pill {
  padding: .35rem .75rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .85rem; font-weight: 600;
}
.pill.accent { border-color: var(--accent); color: var(--accent); }

.game-controls {
  display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center;
  margin-top: 1.25rem;
}
.controls-hint {
  text-align: center; color: var(--muted); font-size: .85rem; margin: .75rem 0 0;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .65rem 1.15rem; border-radius: 12px;
  font-weight: 600; font-size: .95rem; text-decoration: none;
  border: none; cursor: pointer; font-family: inherit;
  transition: transform .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #0a0f1f;
}
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.hidden { display: none !important; }

.room-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; max-width: 420px;
  margin: 1.5rem auto; text-align: center;
}
.room-panel h2 { margin: 0 0 .75rem; font-size: 1.25rem; }
.room-panel p { color: var(--muted); margin: 0 0 1rem; font-size: .95rem; }
.field { margin-bottom: 1rem; text-align: left; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.input {
  width: 100%; padding: .7rem .9rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 1rem; outline: none; box-sizing: border-box;
}
.input:focus { border-color: var(--accent); }
.room-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.room-actions .btn { flex: 1; min-width: 120px; }
.room-code-display {
  font-size: 2rem; font-weight: 800; letter-spacing: .2em;
  color: var(--accent); margin: 1rem 0; font-family: ui-monospace, monospace;
}
.status-line { min-height: 1.4em; font-size: .9rem; color: var(--muted); margin-top: .75rem; }
.status-line.error, .status-line.err { color: #f87171; }
.status-line.win { color: #34d399; }
.status-line.warn { color: #fbbf24; }

canvas {
  display: block; margin: 0 auto; border-radius: 12px;
  background: #0d1428; border: 1px solid var(--border);
  max-width: 100%; height: auto;
  touch-action: none;
}

/* XOX */
.xox-board {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; max-width: 300px; margin: 0 auto; aspect-ratio: 1;
}
.xox-cell {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 12px; display: grid; place-items: center;
  font-size: 2.4rem; font-weight: 800; cursor: pointer;
  transition: border-color .15s, background .15s; user-select: none;
}
.xox-cell:hover:not(.filled) { border-color: var(--accent); }
.xox-cell.filled { cursor: default; }
.xox-cell.x { color: #22d3ee; }
.xox-cell.o { color: #f472b6; }
.xox-cell.winner { background: color-mix(in srgb, #34d399 25%, var(--surface)); border-color: #34d399; }

/* Connect Four */
.c4-board {
  display: flex; gap: 4px; justify-content: center;
  max-width: 360px; margin: 0 auto; padding: 8px;
  background: #1e3a5f; border-radius: 16px;
}
.c4-col {
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; flex: 1;
}
.c4-col:hover .c4-cell:not(.p1):not(.p2) {
  background: color-mix(in srgb, var(--accent) 30%, #0d2137);
}
.c4-cell {
  aspect-ratio: 1; border-radius: 50%;
  background: #0d2137; border: 2px solid #163a5c;
  transition: background .15s;
}
.c4-cell.p1 { background: #f87171; border-color: #ef4444; }
.c4-cell.p2 { background: #fbbf24; border-color: #f59e0b; }

/* RPS */
.rps-zone { margin: 1rem 0; }
.rps-stage {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; flex-wrap: wrap;
}
.rps-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.25rem 1.5rem; text-align: center; min-width: 100px;
}
.rps-emoji { font-size: 3rem; line-height: 1; margin-bottom: .35rem; }
.rps-vs { font-weight: 800; color: var(--muted); font-size: 1.1rem; }
.rps-btn { min-width: 100px; font-size: 1rem; }
.banner {
  text-align: center; padding: .6rem 1rem; border-radius: 10px;
  margin-bottom: 1rem; font-weight: 600;
}
.banner.win { background: color-mix(in srgb, #34d399 20%, transparent); color: #34d399; }
.banner.err { background: color-mix(in srgb, #f87171 20%, transparent); color: #f87171; }
.banner.warn { background: color-mix(in srgb, #fbbf24 20%, transparent); color: #fbbf24; }

@media (max-width: 480px) {
  .game-stage { padding: 1rem; }
  .xox-cell { font-size: 1.8rem; }
  .rps-emoji { font-size: 2.4rem; }
}

/* ========== In-room chat ========== */
.pp-chat-wrap {
  max-width: 420px;
  margin: 1.25rem auto 0;
}
.pp-chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}
.pp-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .9rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-bottom: 1px solid var(--border);
}
.pp-chat-title {
  font-weight: 700;
  font-size: .9rem;
}
.pp-chat-toggle {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.pp-chat-toggle:hover { color: var(--accent); border-color: var(--accent); }
.pp-chat-msgs {
  height: 160px;
  overflow-y: auto;
  padding: .65rem .8rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  scroll-behavior: smooth;
}
.pp-chat-empty {
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  margin: auto;
}
.pp-chat-msg {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .5rem;
  align-items: baseline;
  font-size: .88rem;
  max-width: 95%;
}
.pp-chat-msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.pp-chat-msg.sys {
  align-self: center;
  opacity: .75;
  font-size: .8rem;
  font-style: italic;
}
.pp-chat-from {
  font-weight: 700;
  color: var(--accent);
  font-size: .8rem;
}
.pp-chat-msg.mine .pp-chat-from { color: var(--accent2); }
.pp-chat-text {
  background: color-mix(in srgb, var(--border) 40%, transparent);
  padding: .3rem .55rem;
  border-radius: 10px;
  word-break: break-word;
}
.pp-chat-msg.mine .pp-chat-text {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.pp-chat-msg.sys .pp-chat-text {
  background: transparent;
  padding: 0;
}
.pp-chat-time {
  font-size: .7rem;
  color: var(--muted);
  opacity: .7;
}
.pp-chat-form {
  display: flex;
  gap: .4rem;
  padding: .55rem .65rem;
  border-top: 1px solid var(--border);
}
.pp-chat-input {
  flex: 1;
  padding: .55rem .7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  outline: none;
}
.pp-chat-input:focus { border-color: var(--accent); }
.pp-chat-send {
  padding: .55rem .9rem !important;
  font-size: .85rem !important;
  flex-shrink: 0;
}

/* Never Have I Ever */
.nhie-card {
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent2) 15%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem 1.25rem;
  text-align: center;
  margin: 1rem 0;
}
.nhie-label {
  margin: 0 0 .5rem;
  color: var(--accent);
  font-weight: 700;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.nhie-question {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
}
.nhie-votes {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.nhie-btn { min-width: 130px; }
.nhie-results {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem 1rem;
  margin-top: .75rem;
}
.nhie-result-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.nhie-result-row:last-child { border-bottom: none; }
