:root {
  --bg: #1b1740;
  --bg2: #272160;
  --card: #322a78;
  --accent: #ffcc4d;
  --accent2: #5ad1ff;
  --text: #f3f1ff;
  --muted: #b3aee0;
  --danger: #ff6b6b;
  /* Surfaces promoted to variables so the theme picker can retint them. These :root values ARE
     the default "Plum" theme; the [data-rp-theme="…"] overlays at the bottom of this file
     redefine the whole set for the other themes. */
  --field-bg: #221c54;
  --field-border: #4b419c;
  --chip-bg: #2a2363;
  --hover: #372f80;
  --btn-text: #2a2350;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 30% 0%, var(--bg2), var(--bg) 70%);
  color: var(--text);
  min-height: 100%;
}
.boot, .pad { padding: 2rem; color: var(--muted); }
a { color: var(--accent2); text-decoration: none; }

/* layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.8rem 1.4rem; background: rgba(0,0,0,0.25);
}
.brand { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.topbar .spacer { margin-left: auto; }
.topbar .who { color: var(--muted); text-decoration: none; cursor: pointer; }
.topbar .who:hover { color: var(--text); }
.bell { position: relative; font-size: 1.25rem; text-decoration: none; }
.badge {
  position: absolute; top: -7px; right: -11px; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: .68rem; font-weight: 800; padding: 0 5px; line-height: 1.5;
}
.content { flex: 1; padding: 1.5rem; max-width: 1100px; width: 100%; margin: 0 auto; }
.centered { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
.subtle { color: var(--muted); }

/* cards / tiles */
.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.tile {
  background: var(--card); border: 2px solid transparent; border-radius: 16px;
  padding: 1.4rem; cursor: pointer; text-align: center; color: var(--text);
  transition: transform .12s, border-color .12s; font: inherit;
}
.tile:hover, .tile:focus { transform: translateY(-3px); border-color: var(--accent); outline: none; }
.tile .emoji { font-size: 3rem; display: block; margin-bottom: .5rem; }
.tile .name { font-weight: 700; font-size: 1.1rem; }
.tile.add { border: 2px dashed var(--muted); background: transparent; }

/* game tiles with real cover art: image fills the top, title caption beneath */
.grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.game-tile { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.game-tile .cover { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #000; }
.game-tile .cover-fallback { font-size: 3rem; display: grid; place-items: center; aspect-ratio: 4 / 3; margin: 0; }
.game-tile .name { padding: .7rem .5rem; }
/* small cover thumbnail in the parent's enable-games picker */
.cover-thumb { width: 40px; height: 30px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: .1rem; }

/* rotating cover slideshow: each keyed <img> fades in as it swaps */
.cover-rotator { width: 100%; aspect-ratio: 4 / 3; background: #000; overflow: hidden; }
.cover-rotator .cover { width: 100%; height: 100%; object-fit: cover; display: block; animation: cover-fade .7s ease; }
@keyframes cover-fade { from { opacity: .15; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cover-rotator .cover { animation: none; } }

/* auth card */
.auth { background: var(--card); padding: 2rem; border-radius: 18px; width: min(380px, 92vw); }
.auth h1 { text-align: center; }
label { display: block; margin: .8rem 0 .3rem; color: var(--muted); }
/* Custom-styled form controls (the app uses its own CSS, not Bootstrap) */
input, select, textarea {
  width: 100%; padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--field-border);
  background: var(--field-bg); color: var(--text); font: inherit;
}
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b3aee0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
select option { background: var(--field-bg); color: var(--text); }
textarea { resize: vertical; }
/* checkboxes/radios shouldn't be full-width — keep them inline with their label */
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; margin: 0 .45rem 0 0; vertical-align: middle; accent-color: var(--accent); }

/* inline action buttons that read as buttons (bezel + hover/active) */
.btn-chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .7rem; margin: .15rem;
  border: 1px solid var(--field-border); border-radius: 8px; background: var(--chip-bg); color: var(--accent2);
  font: inherit; font-size: .9rem; cursor: pointer; transition: background .12s, border-color .12s, transform .05s;
}
.btn-chip:hover { background: var(--hover); border-color: var(--accent2); }
.btn-chip:active { transform: translateY(1px); background: var(--field-bg); }
.btn-chip.danger { color: #ffb3b3; }
.btn-chip.danger:hover { border-color: var(--danger); background: #3a2440; }
/* larger variant for primary header actions (Add Parent, Send notice) */
.btn-chip.lg { padding: .55rem 1.2rem; font-size: 1rem; font-weight: 700; }

/* notification bell dropdown */
.bell-wrap { position: relative; }
.bell-btn { background: none; border: none; cursor: pointer; font-size: 1.25rem; color: var(--text); position: relative; padding: 0; }
.notif-panel {
  position: absolute; right: 0; top: 150%; width: min(360px, 92vw); background: var(--card);
  border: 1px solid var(--field-border); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.45);
  z-index: 60; max-height: 72vh; overflow: auto;
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem .85rem; border-bottom: 1px solid #3b347e; }
.notif-item { padding: .55rem .85rem; border-bottom: 1px solid #2c2768; text-align: left; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(90,209,255,.08); }
.notif-actions { display: flex; gap: .9rem; margin-top: .3rem; }
.notif-empty { padding: 1.4rem; color: var(--muted); text-align: center; }

/* nav dropdown (Admin ▾) */
.nav-menu {
  position: absolute; left: 0; top: 160%; min-width: 190px; background: var(--card);
  border: 1px solid var(--field-border); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.45);
  z-index: 60; overflow: hidden;
}
.nav-item { display: block; padding: .6rem .9rem; color: var(--text); text-decoration: none; }
.nav-item:hover { background: var(--hover); }

/* modal + scalable game-access grid */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-card { background: var(--card); border-radius: 16px; padding: 1.4rem; width: min(680px, 94vw); max-height: 86vh; overflow: auto; }
.modal-card h3 { margin: 0 0 1rem; }
.game-grid { display: grid; gap: .3rem .8rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); max-height: 52vh; overflow: auto; }
.game-check { display: flex; align-items: center; gap: .2rem; padding: .35rem .4rem; border-radius: 8px; cursor: pointer; }
.game-check:hover { background: rgba(255,255,255,.06); }
.toolbar { display: flex; gap: 1rem; align-items: center; margin-bottom: .6rem; }
.btn {
  display: inline-block; width: 100%; margin-top: 1.2rem; padding: .7rem;
  border: none; border-radius: 12px; background: var(--accent); color: var(--btn-text);
  font-weight: 800; font-size: 1rem; cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-secondary { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); }
.btn-link { background: none; border: none; color: var(--accent2); cursor: pointer; font: inherit; }
.alert { margin-top: 1rem; padding: .6rem .8rem; border-radius: 10px; }
.alert-error { background: rgba(255,107,107,.18); color: #ffb3b3; }
.alert-info { background: rgba(90,209,255,.15); color: var(--accent2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* play / stream */
.player-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.player-head .spacer { margin-left: auto; }
/* Size the 4:3 stage to whichever of width/height fits, so the player never overflows the
   viewport (no page scrollbar). ~140px reserves the nav + header + page padding. */
.stage {
  background: #000; border-radius: 14px; overflow: hidden;
  aspect-ratio: 4 / 3;
  width: min(100%, calc((100vh - 140px) * 4 / 3));
  max-width: 1024px; margin: 0 auto;
  display: grid; place-items: center;
}
.stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.loader { text-align: center; color: var(--muted); }
.spinner {
  width: 54px; height: 54px; margin: 0 auto 1rem; border-radius: 50%;
  border: 6px solid #3b347e; border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: #ffd; color: #600; padding: .6rem 1rem;
}

/* ── Color themes ──────────────────────────────────────────────────────────
   The ThemeSwitcher sets data-rp-theme on <html>; each block below retints the whole app by
   redefining the CSS variables. The default (no attribute, or "plum") is the original purple in
   :root above. Order in the picker: the light-base themes first, then the darker themes
   (Dark, Oak, Plum). theme.js applies the saved choice before Blazor boots, so there's no flash. */
html, body { transition: background-color .25s ease, color .25s ease; }

[data-rp-theme="light"] {
  --bg: #e9eaf0; --bg2: #ffffff; --card: #ffffff;
  --accent: #2563eb; --accent2: #0e7490; --text: #1f2433; --muted: #5b6273; --danger: #dc2626;
  --field-bg: #f4f5f9; --field-border: #d3d7e2; --chip-bg: #eef1f8; --hover: #e6eaf4; --btn-text: #ffffff;
}
[data-rp-theme="forest"] {
  --bg: #e7f0e7; --bg2: #f4f8f4; --card: #f9fcf8;
  --accent: #047857; --accent2: #0e7490; --text: #1f3a2e; --muted: #41614e; --danger: #b91c1c;
  --field-bg: #eef5ee; --field-border: #cfe0cf; --chip-bg: #e3eee3; --hover: #d9e8d9; --btn-text: #ffffff;
}
[data-rp-theme="magma"] {
  --bg: #f7e4e0; --bg2: #fdf3f1; --card: #fffaf9;
  --accent: #b91c1c; --accent2: #9a3412; --text: #5a1f17; --muted: #9c4a3f; --danger: #b91c1c;
  --field-bg: #fbeae6; --field-border: #f0cfc8; --chip-bg: #fbddd7; --hover: #f6d3cb; --btn-text: #ffffff;
}
[data-rp-theme="sandy"] {
  --bg: #efe4cf; --bg2: #faf6ee; --card: #fffdf8;
  --accent: #b45309; --accent2: #92400e; --text: #44382a; --muted: #7a6a55; --danger: #b91c1c;
  --field-bg: #f3ead9; --field-border: #e2d7c2; --chip-bg: #efe4cf; --hover: #e7d9bf; --btn-text: #ffffff;
}
[data-rp-theme="solar"] {
  --bg: #f2e9bf; --bg2: #fdfbed; --card: #fffdf3;
  --accent: #a16207; --accent2: #7a6108; --text: #4a4310; --muted: #6b6020; --danger: #b91c1c;
  --field-bg: #f7f0cf; --field-border: #e9dfb0; --chip-bg: #f2e9bf; --hover: #ebe0ac; --btn-text: #ffffff;
}
[data-rp-theme="water"] {
  --bg: #d4ecfb; --bg2: #f0f9ff; --card: #f8fdff;
  --accent: #0e7490; --accent2: #0369a1; --text: #0c3a52; --muted: #4a6675; --danger: #dc2626;
  --field-bg: #e0f2fe; --field-border: #cfe6f5; --chip-bg: #daeffb; --hover: #cce7f7; --btn-text: #ffffff;
}
[data-rp-theme="dark"] {
  --bg: #1a1d21; --bg2: #212529; --card: #2b3035;
  --accent: #0d6efd; --accent2: #4dabf7; --text: #e9ecef; --muted: #adb5bd; --danger: #ff6b6b;
  --field-bg: #2b3035; --field-border: #444b52; --chip-bg: #2b3035; --hover: #343a40; --btn-text: #ffffff;
}
[data-rp-theme="oak"] {
  --bg: #1a1410; --bg2: #241c16; --card: #2a211a;
  --accent: #d9a441; --accent2: #e6b85c; --text: #e8ddcf; --muted: #b9a890; --danger: #ff6b6b;
  --field-bg: #2a211a; --field-border: #3d3025; --chip-bg: #332820; --hover: #3d3025; --btn-text: #2a2012;
}
/* Plum — the original RetroPlay purple (same as :root); kept explicit so picking it always resets. */
[data-rp-theme="plum"] {
  --bg: #1b1740; --bg2: #272160; --card: #322a78;
  --accent: #ffcc4d; --accent2: #5ad1ff; --text: #f3f1ff; --muted: #b3aee0; --danger: #ff6b6b;
  --field-bg: #221c54; --field-border: #4b419c; --chip-bg: #2a2363; --hover: #372f80; --btn-text: #2a2350;
}

/* theme switcher (reuses the .bell-wrap / .nav-menu dropdown idiom in the topbar) */
.theme-toggle { display: inline-flex; align-items: center; }
.theme-dot {
  display: inline-block; width: .8rem; height: .8rem; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.25); vertical-align: -1px; margin-right: .4rem;
}
.theme-menu { left: auto; right: 0; min-width: 170px; padding: .3rem 0; }
.theme-item {
  display: flex; align-items: center; width: 100%; background: none; border: none;
  font: inherit; text-align: left; cursor: pointer;
}
.theme-item.active { background: var(--hover); }
.theme-divider { height: 1px; margin: .3rem 0; background: var(--field-border); }

/* selected state for inline chip buttons (clock-style picker on the profile page) */
.btn-chip.active { background: var(--hover); border-color: var(--accent2); color: var(--text); }

/* navbar clock */
.nav-clock { vertical-align: middle; }
.nav-clock-digital {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text); font-variant-numeric: tabular-nums; font-size: .95rem; white-space: nowrap;
}
/* the chime on/off row on the profile page (inline checkbox + wrapping label text) */
.chime-toggle { display: flex; align-items: flex-start; gap: .5rem; color: var(--text); cursor: pointer; }
.chime-toggle input { width: auto; margin: .2rem 0 0; }

/* ── chat bubble + panel (floating overlay) ── */
.chat-bubble-btn {
  position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--btn-text); font-size: 1.6rem; border: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 80; display: grid; place-items: center;
}
.chat-bubble-btn:hover { filter: brightness(1.06); }
.chat-badge {
  position: absolute; top: 8px; right: 10px; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: .66rem; font-weight: 800; padding: 0 5px; line-height: 1.5;
}
.chat-badge.inline { position: static; margin-left: .35rem; }
/* online presence dot */
.online-dot {
  display: inline-block; width: .55rem; height: .55rem; border-radius: 50%;
  background: #22c55e; border: 1px solid rgba(0,0,0,.25); margin-right: .35rem; vertical-align: middle;
}
.chat-panel {
  position: fixed; right: 18px; bottom: 18px; width: min(370px, 94vw); height: min(540px, 76vh);
  background: var(--card); border: 1px solid var(--field-border); border-radius: 16px;
  box-shadow: 0 16px 44px rgba(0,0,0,.5); z-index: 81; display: flex; flex-direction: column; overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border-bottom: 1px solid var(--field-border); }
.chat-head .spacer { margin-left: auto; }
.chat-list { flex: 1; overflow: auto; }
.chat-contact {
  display: flex; gap: .6rem; align-items: center; width: 100%; text-align: left; background: none;
  border: none; border-bottom: 1px solid var(--field-border); padding: .6rem .8rem; cursor: pointer;
  color: var(--text); font: inherit;
}
.chat-contact:hover { background: var(--hover); }
.chat-ava { font-size: 1.6rem; line-height: 1; }
.chat-contact-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-contact-name { font-weight: 700; }
.chat-contact-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; }
.chat-msgs { flex: 1; overflow: auto; padding: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.chat-msg { max-width: 80%; padding: .4rem .6rem; border-radius: 12px; font-size: .92rem; overflow-wrap: anywhere; }
.chat-msg.mine { align-self: flex-end; background: var(--accent); color: var(--btn-text); }
.chat-msg.theirs { align-self: flex-start; background: var(--field-bg); color: var(--text); }
.chat-time { display: block; font-size: .62rem; opacity: .7; text-align: right; margin-top: .1rem; }
.chat-quick { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0 .5rem .4rem; }
.chat-input-row { display: flex; gap: .4rem; padding: .5rem; border-top: 1px solid var(--field-border); }
.chat-input-row input { flex: 1; width: auto; margin: 0; }
.chat-err { color: var(--danger); font-size: .8rem; padding: .2rem .8rem; }
.chat-empty { padding: 1.4rem; text-align: center; color: var(--muted); }

/* role title chips — Owner rainbow+sparkle, Admin gold, Partial Admin teal, others plain */
.role-badge { display: inline-block; padding: .04rem .42rem; margin: 0 .12rem; border-radius: 999px;
  font-size: .72rem; font-weight: 800; vertical-align: middle; line-height: 1.5; letter-spacing: .01em; }
.role-plain { background: var(--field-bg); color: var(--muted); }
.role-admin { color: #4a3500; background: linear-gradient(135deg, #ffe082, #ffb300 55%, #ffd54f);
  box-shadow: 0 0 6px rgba(255,179,0,.5); text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.role-partial { color: #fff; background: linear-gradient(135deg, #0ea5a5, #14b8a6); box-shadow: 0 0 5px rgba(20,184,166,.45); }
.role-owner { background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.14); }
.role-owner-text {
  background: linear-gradient(90deg, #ff004c, #ff8a00, #ffe600, #00d26a, #00b3ff, #7a5cff, #ff004c);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent; font-weight: 900;
  animation: role-rainbow 4s linear infinite;
}
.role-spark { margin-left: .18rem; display: inline-block; animation: role-sparkle 1.4s ease-in-out infinite; }
@keyframes role-rainbow { to { background-position: 300% 0; } }
@keyframes role-sparkle { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) {
  .role-owner-text { animation: none; background-position: 0 0; }
  .role-spark { animation: none; }
}

/* group chat: sender labels, the new-chat picker, members panel */
.chat-sender { display: block; font-size: .66rem; font-weight: 800; opacity: .8; margin-bottom: .05rem; }
.chat-iconbtn { background: none; border: none; cursor: pointer; color: var(--text); font-size: 1.1rem; line-height: 1; padding: .1rem .25rem; }
.chat-iconbtn:hover { filter: brightness(1.15); }
.chat-contact.selected { background: var(--hover); }
.chat-check { font-size: 1.2rem; width: 1.4rem; text-align: center; }
.chat-toggle { display: flex; gap: .3rem; padding: .5rem .6rem 0; }
.chat-toggle button { flex: 1; }
.chat-toggle .seg { background: var(--field-bg); border: 1px solid var(--field-border); color: var(--text);
  border-radius: 999px; padding: .3rem .6rem; cursor: pointer; font: inherit; font-weight: 700; }
.chat-toggle .seg.on { background: var(--accent); color: var(--btn-text); border-color: var(--accent); }
.chat-namerow { display: flex; gap: .4rem; padding: .5rem; border-top: 1px solid var(--field-border); }
.chat-namerow input { flex: 1; width: auto; margin: 0; }
.chat-memchip { display: inline-flex; align-items: center; gap: .25rem; background: var(--field-bg);
  border: 1px solid var(--field-border); border-radius: 999px; padding: .1rem .5rem; font-size: .8rem; margin: .15rem; }
.chat-members { padding: .4rem .6rem; border-bottom: 1px solid var(--field-border); }
.chat-subhead { font-size: .72rem; font-weight: 800; opacity: .7; padding: .5rem .7rem .2rem; text-transform: uppercase; }
/* pinned messages: a strip above the thread + a per-message pin toggle */
.chat-pinned { border-bottom: 1px solid var(--field-border); background: rgba(255,193,7,.08); max-height: 28%; overflow: auto; }
.chat-pinrow { display: flex; gap: .4rem; align-items: center; padding: .3rem .6rem; font-size: .82rem; }
.chat-pin-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-msg.pinned { box-shadow: inset 3px 0 0 #ffc107; }
.chat-pinbtn { background: none; border: none; cursor: pointer; font-size: .7rem; opacity: .55; padding: 0 .2rem 0 0; }
.chat-pinbtn:hover { opacity: 1; }

/* read-only chat-review modal: bounded, framed message/contact list */
.review-box {
  max-height: 60vh; overflow: auto; border: 1px solid var(--field-border);
  border-radius: 12px; background: var(--bg2); margin-top: .4rem;
}
.review-box.chat-msgs { padding: .7rem; }

/* Immersive in-game fullscreen: we fullscreen the whole .app (so the chat bubble stays usable), then
   hide the nav header and let the stage fill the screen. Esc exits. */
.app:fullscreen { background: #000; }
.app:fullscreen .topbar { display: none; }
.app:fullscreen .content { max-width: none; padding: .4rem 1rem; }
.app:fullscreen .stage { width: min(100%, calc((100vh - 64px) * 4 / 3)); max-width: none; }
