:root {
  --bg: #0e0f1a;
  --card: #181a2b;
  --line: #262940;
  --text: #f2f3f8;
  --muted: #9a9db5;
  --red: #ff4d5e;
  --blue: #3d8bff;
  --green: #2ecc71;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }

/* Top bar on game pages */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--line); gap: 12px;
}
.topbar .back { text-decoration: none; color: var(--muted); font-weight: 600; }
.topbar .back:hover { color: var(--text); }
.topbar { position: relative; }
.topbar .title { font-weight: 800; font-size: 1.1rem; position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.topbar .back { margin-right: auto; white-space: nowrap; }
.topbar .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .topbar .title, .topbar .home-logo { display: none; }
  .topbar { gap: 8px; padding: 10px 12px; }
  .topbar .btn.small { padding: 6px 9px; }
}
.topbar .home-logo { text-decoration: none; font-weight: 900; letter-spacing: -0.02em; }
.home-logo .one { color: var(--red); } .home-logo .two { color: var(--blue); } .home-logo .vs { color: var(--muted); font-size: .7em; margin: 0 2px; }

/* Score board */
.scoreboard {
  display: flex; justify-content: center; align-items: center; gap: 22px;
  padding: 18px 12px 8px; font-weight: 800;
}
.scoreboard .p { display: flex; flex-direction: column; align-items: center; min-width: 90px; padding: 8px 14px; border-radius: 12px; border: 2px solid transparent; }
.scoreboard .p span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.scoreboard .p b { font-size: 2rem; }
.scoreboard .p.red b { color: var(--red); }
.scoreboard .p.blue b { color: var(--blue); }
.scoreboard .p.red.active { border-color: var(--red); }
.scoreboard .p.blue.active { border-color: var(--blue); }
.scoreboard .sep { color: var(--muted); font-size: 1.4rem; }

.status { text-align: center; min-height: 1.6em; font-size: 1.1rem; font-weight: 600; padding: 6px 12px; }
.status .red { color: var(--red); } .status .blue { color: var(--blue); }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; }

.btn {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  padding: 10px 20px; border-radius: 10px; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); }
.controls { display: flex; gap: 10px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: .9rem; text-align: center; padding: 0 16px 16px; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.wide { width: 100%; }
.btn[hidden] { display: none; }

/* Mode menu overlay */
.mp-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(8,9,16,.82);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(4px);
}
.mp-overlay[hidden] { display: none; }
.mp-home {
  position: absolute; top: 12px; left: 12px; text-decoration: none; font-weight: 700; font-size: .95rem;
  color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px;
}
.mp-home:hover { border-color: var(--blue); }
.mp-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  width: min(100%, 400px); padding: 26px 22px; display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.mp-box h2 { font-size: 1.35rem; margin-bottom: 4px; }
.mp-box .muted { color: var(--muted); }
.mp-box .mode {
  display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font: inherit;
}
.mp-box .mode:hover { border-color: var(--blue); }
.mp-box .mode .ic { font-size: 1.8rem; }
.mp-box .mode b { display: block; font-size: 1.05rem; }
.mp-box .mode small { color: var(--muted); }
.mp-box .or { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.mp-box .join { display: flex; gap: 8px; }
.mp-box input {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 1rem; font-family: inherit;
}
.mp-box #mp-code { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; text-align: center; }
.mp-box .code { font-size: 2.4rem; font-weight: 900; letter-spacing: .25em; color: var(--blue); }
.mp-box .linkbox { display: flex; gap: 8px; }
.mp-box .linkbox input { font-size: .85rem; color: var(--muted); }
.mp-box .err { color: var(--red); min-height: 1em; font-size: .9rem; }
.mp-box .link { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 4px; }
.mp-box .link:hover { color: var(--text); }
.spinner {
  width: 34px; height: 34px; margin: 6px auto; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--blue); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mp-bar {
  align-self: center; margin: 0 auto 12px; width: fit-content;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: .85rem; color: var(--muted); white-space: nowrap;
}
.mp-bar[hidden] { display: none; }
.mp-bar .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 4px; }
.mp-bar .red { color: var(--red); } .mp-bar .blue { color: var(--blue); }

/* Account chip in headers */
[data-auth-slot] { display: inline-flex; }
.user-chip {
  text-decoration: none; font-size: .85rem; font-weight: 700; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip:hover { border-color: var(--blue); }
.user-chip.login { background: var(--blue); border-color: var(--blue); }
@media (max-width: 520px) { .user-chip { max-width: 96px; padding: 6px 10px; } }

/* Simple content pages (account, privacy) */
.page { width: min(100%, 440px); margin: 0 auto; padding: 32px 18px 60px; }
.page.wide { width: min(100%, 720px); }
.page h1 { font-size: 1.7rem; margin-bottom: 14px; }
.page h2 { font-size: 1.15rem; margin: 22px 0 8px; }
.page p, .page li { color: var(--muted); line-height: 1.55; }
.page ul { padding-left: 20px; }
.page a { color: var(--blue); }
.page a.btn { color: var(--text); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; background: none; border: none; color: var(--muted); font: inherit; font-weight: 700; padding: 9px; border-radius: 9px; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 1rem; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--blue); }
.form-err { color: var(--red); font-size: .9rem; min-height: 1.2em; }
.small-print { font-size: .8rem; color: var(--muted); }
.btn.danger { background: transparent; border-color: #5a2430; color: var(--red); }
.btn.danger:hover { border-color: var(--red); }

kbd { background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-family: inherit; font-size: .85em; }
