:root {
  --bg: #0a0a16;
  --bg2: #12122a;
  --panel: #1a1a35;
  --panel2: #23234a;
  --accent: #7c4dff;
  --accent2: #00e5ff;
  --pink: #ff2e88;
  --green: #18e06f;
  --yellow: #ffd23f;
  --text: #e8e8ff;
  --muted: #9090b8;
  --border: #2c2c55;
  --shadow: 0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent2); }

/* ===================== AUTH ===================== */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1d1147 0%, var(--bg) 60%);
  z-index: 100;
}
.auth-bg {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 80% 70%, rgba(124,77,255,.25), transparent 40%),
    radial-gradient(circle at 15% 80%, rgba(0,229,255,.18), transparent 40%);
  pointer-events: none;
}
.auth-card {
  position: relative;
  width: 360px; max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}
.logo { font-size: 30px; font-weight: 800; margin-bottom: 6px; }
.logo span {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  color: var(--muted); font-weight: 600; border-radius: 9px; transition: .15s;
}
.auth-tab.active { background: var(--accent); color: #fff; }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
input[type=text], input[type=password] {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 11px; padding: 13px 15px; color: var(--text); font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--pink));
  color: #fff; border: none; padding: 13px; border-radius: 11px;
  font-size: 16px; font-weight: 700; transition: .15s;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.auth-error { color: var(--pink); font-size: 13px; min-height: 16px; }
.auth-hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ===================== APP SHELL ===================== */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 26px; background: var(--bg2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 22px; font-weight: 800; cursor: pointer; }
.nav { display: flex; gap: 6px; margin-left: 10px; }
.nav-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 14px;
}
.nav-btn:hover { color: var(--text); background: var(--panel); }
.nav-btn.active { color: #fff; background: var(--accent); }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 700; }
.user-stats { color: var(--muted); font-size: 13px; }
.btn-ghost {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: 9px; font-size: 13px;
}
.btn-ghost:hover { border-color: var(--accent); }
.main { flex: 1; padding: 30px 26px; max-width: 1100px; width: 100%; margin: 0 auto; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

/* ===================== LOBBY ===================== */
.section-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.section-sub { color: var(--muted); margin-bottom: 24px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.game-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; cursor: pointer;
  transition: .18s; position: relative; overflow: hidden;
}
.game-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.game-card .emoji { font-size: 46px; display: block; margin-bottom: 12px; }
.game-card h3 { font-size: 18px; margin-bottom: 5px; }
.game-card p { color: var(--muted); font-size: 13px; line-height: 1.4; }
.badge {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px;
}
.badge.solo { background: rgba(0,229,255,.15); color: var(--accent2); }
.badge.mp { background: rgba(255,46,136,.18); color: var(--pink); }

/* ===================== GAME VIEW ===================== */
.game-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.back-btn { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 9px 15px; border-radius: 10px; font-weight: 600; }
.back-btn:hover { border-color: var(--accent); }
.game-title { font-size: 24px; font-weight: 800; }
.game-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.scorebar { display: flex; gap: 24px; font-size: 16px; font-weight: 600; }
.scorebar b { color: var(--accent2); }
canvas { background: #07070f; border-radius: 12px; border: 1px solid var(--border); touch-action: none; }
.controls-hint { color: var(--muted); font-size: 13px; text-align: center; }
.btn { background: var(--accent); color: #fff; border: none; padding: 10px 20px; border-radius: 10px; font-weight: 700; }
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--panel2); }
.overlay-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(7,7,15,.82); border-radius: 12px; text-align: center;
}
.overlay-msg h2 { font-size: 30px; }
.stage-wrap { position: relative; display: inline-block; }

/* 2048 */
.grid2048 { display: grid; grid-template-columns: repeat(4, 80px); grid-gap: 10px; background: var(--panel2); padding: 12px; border-radius: 12px; }
.tile2048 { width: 80px; height: 80px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 26px; background: #2a2a4a; transition: .1s; }

/* memory */
.mem-grid { display: grid; gap: 10px; }
.mem-card { width: 78px; height: 78px; border-radius: 10px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 34px; cursor: pointer; border: 2px solid var(--border); transition: .15s; }
.mem-card.flipped { background: var(--accent); }
.mem-card.matched { background: var(--green); cursor: default; }

/* minesweeper */
.ms-grid { display: grid; gap: 3px; background: var(--panel2); padding: 8px; border-radius: 10px; user-select: none; }
.ms-cell { width: 32px; height: 32px; background: #2e2e54; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; cursor: pointer; }
.ms-cell.revealed { background: #14142b; cursor: default; }
.ms-cell.mine { background: var(--pink); }

/* tic tac toe / multiplayer boards */
.ttt-board { display: grid; grid-template-columns: repeat(3, 96px); grid-template-rows: repeat(3, 96px); gap: 8px; }
.ttt-cell { background: var(--panel2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 52px; font-weight: 800; cursor: pointer; border: 2px solid transparent; transition: .12s; }
.ttt-cell:hover { border-color: var(--accent); }
.ttt-cell.x { color: var(--accent2); }
.ttt-cell.o { color: var(--pink); }

.c4-board { display: grid; grid-template-columns: repeat(7, 56px); gap: 6px; background: var(--accent); padding: 10px; border-radius: 14px; }
.c4-cell { width: 56px; height: 56px; border-radius: 50%; background: #0b0b1a; cursor: pointer; transition: .1s; }
.c4-cell.r { background: radial-gradient(circle at 35% 30%, #ff6b6b, #d61f1f); }
.c4-cell.y { background: radial-gradient(circle at 35% 30%, #ffe26b, #e0b900); }
.c4-col:hover .c4-cell:first-child { box-shadow: inset 0 0 0 3px #fff5; }

.rps-choices { display: flex; gap: 18px; }
.rps-btn { font-size: 50px; background: var(--panel2); border: 2px solid var(--border); border-radius: 16px; width: 100px; height: 100px; transition: .15s; }
.rps-btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-4px); }
.rps-btn:disabled { opacity: .4; cursor: default; }
.rps-btn.chosen { border-color: var(--green); background: rgba(24,224,111,.15); }

/* multiplayer lobby */
.mp-games { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.mp-game-pick { background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 16px 22px; min-width: 150px; text-align: center; }
.mp-game-pick.active { border-color: var(--accent); }
.mp-game-pick .emoji { font-size: 34px; display: block; margin-bottom: 6px; }
.room-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.room-row { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.room-row .host { font-weight: 700; }
.room-row .game-tag { color: var(--muted); font-size: 13px; }
.room-row button { margin-left: auto; }
.empty-note { color: var(--muted); padding: 18px 0; }

/* status / turn indicator */
.turn-indicator { font-size: 17px; font-weight: 700; padding: 8px 18px; border-radius: 30px; background: var(--panel); border: 1px solid var(--border); }
.turn-indicator.you { border-color: var(--green); color: var(--green); }
.turn-indicator.them { border-color: var(--yellow); color: var(--yellow); }
.players-row { display: flex; gap: 18px; align-items: center; font-size: 15px; }
.player-chip { padding: 7px 14px; border-radius: 30px; background: var(--panel); border: 1px solid var(--border); font-weight: 600; }
.player-chip.me { border-color: var(--accent2); }

/* chat */
.chat-box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.chat-log { height: 130px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.chat-log .me { color: var(--accent2); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; padding: 9px 12px; }
.room-code { font-family: monospace; background: var(--bg2); padding: 4px 10px; border-radius: 7px; letter-spacing: 2px; color: var(--yellow); }

/* among us */
.role-card { width: 100%; max-width: 420px; text-align: center; padding: 16px; border-radius: 14px; border: 2px solid var(--border); background: var(--panel); font-size: 18px; }
.role-card.crew { border-color: var(--accent2); }
.role-card.impostor { border-color: #ff4d6d; }
.role-card .role-sub { font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.au-players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.player-chip.crew { border-color: var(--accent2); }
.player-chip.impostor { border-color: #ff4d6d; color: #ff8fa3; }
.player-chip.dead { opacity: .45; text-decoration: line-through; }
.au-actions { flex-wrap: wrap; justify-content: center; }
.task-bar { width: 100%; max-width: 420px; height: 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 30px; overflow: hidden; }
.task-fill { height: 100%; background: var(--green); transition: width .3s; }
.vote-btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 9px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.vote-btn:hover:not(:disabled) { border-color: var(--accent); }
.vote-btn.chosen { border-color: var(--green); color: var(--green); }
.vote-btn:disabled { opacity: .45; cursor: default; }
.vote-btn.kill { margin-left: 8px; background: #ff4d6d; color: #fff; border: none; padding: 4px 12px; font-size: 13px; }

/* five nights at freddy's */
.fnaf-office { display: flex; gap: 14px; align-items: stretch; width: 100%; max-width: 560px; background: #07070f; border: 1px solid var(--border); border-radius: 14px; padding: 16px; transition: filter .3s; }
.fnaf-office.fnaf-dark { filter: brightness(.35); }
.fnaf-side { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.fnaf-door.active { background: #ff4d6d; }
.fnaf-center { flex: 1; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: flex-start; }
.fnaf-view { width: 100%; min-height: 120px; display: flex; align-items: center; justify-content: center; font-size: 40px; background: var(--bg2); border-radius: 10px; text-align: center; padding: 10px; }
.fnaf-view .fnaf-warn { font-size: 18px; font-weight: 800; color: #ff4d6d; }
.fnaf-view .fnaf-ok { font-size: 16px; font-weight: 700; color: var(--green); }
.fnaf-cams { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 13px; }
.fnaf-cam-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.fnaf-over { color: #ff4d6d; }
.fnaf-win { color: var(--green); }
.fnaf-jump { font-size: 72px; line-height: 1; margin-bottom: 6px; }

/* papa's pizzeria */
.papas-play { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 440px; }
.papas-ticket { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; text-align: center; width: 100%; }
.papas-ticket .ticket-row { font-size: 22px; margin-top: 6px; letter-spacing: 4px; }
.pizza { position: relative; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, #e8a33d 0%, #d98324 60%, #b5651d 100%); border: 8px solid #c9882e; display: flex; align-items: center; justify-content: center; }
.pizza-base { font-size: 0; }
.pizza-toppings { position: absolute; inset: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 24px; }
.papas-tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.topping-btn { font-size: 26px; padding: 8px 12px; }
.topping-btn.active { background: var(--green); color: #07070f; }
.bake-track { position: relative; width: 100%; height: 26px; background: var(--bg2); border: 1px solid var(--border); border-radius: 30px; overflow: hidden; }
.bake-zone { position: absolute; top: 0; height: 100%; background: rgba(24,224,111,.35); border-left: 2px solid var(--green); border-right: 2px solid var(--green); }
.bake-fill { height: 100%; background: linear-gradient(90deg, #ffd23f, #ff6a00); width: 0; }
.papas-stars { font-size: 40px; letter-spacing: 4px; }

/* leaderboard */
.lb-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 14px; overflow: hidden; }
.lb-table th, .lb-table td { padding: 13px 18px; text-align: left; }
.lb-table th { background: var(--panel2); color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.lb-table tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.lb-table .rank { font-weight: 800; color: var(--yellow); width: 50px; }
.lb-table tr.me-row td { background: rgba(124,77,255,.18); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent); color: var(--text); padding: 12px 22px; border-radius: 12px; box-shadow: var(--shadow); z-index: 200; font-weight: 600; }

@media (max-width: 640px) {
  .nav span, .user-stats { display: none; }
  .topbar { gap: 10px; padding: 12px 14px; }
  .main { padding: 20px 14px; }
  .ttt-board { grid-template-columns: repeat(3, 80px); grid-template-rows: repeat(3, 80px); }
}
