:root {
    font-family: "Segoe UI", Arial, sans-serif;
    --accent: #f5c518;
    --accent-2: #b88900;
    --text: #f4f6fb;
    --muted: rgba(244, 246, 251, .58);
    --line: rgba(255, 255, 255, .08);
    --card: rgba(18, 21, 32, .72);
    --card-2: rgba(255, 255, 255, .04);
    --good: #2ecc71;
    --bad: #ff4d6d;
    --warn: #ffb547;
    --ease: cubic-bezier(.2, .9, .25, 1.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: transparent; overflow: hidden; user-select: none; color: var(--text); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#root { position: fixed; inset: 0; background: rgba(5, 8, 15, 0); transition: background .3s ease; }
#root.open { background: radial-gradient(ellipse at 50% 60%, rgba(5, 8, 15, .2), rgba(5, 8, 15, .65)); }
.stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.scaler { flex-shrink: 0; zoom: var(--scale, 1); }

.tablet {
    position: relative;
    width: 1180px;
    height: 740px;
    padding: 20px;
    border-radius: 40px;
    background: linear-gradient(160deg, #3a3f4b 0%, #16181e 18%, #0b0c10 60%, #22252d 100%);
    box-shadow: 0 0 0 1.5px #5b606c, 0 0 0 4px #15171c, inset 0 1px 1px rgba(255, 255, 255, .18), 0 30px 60px -10px rgba(0, 0, 0, .7);
    opacity: 0;
    transform: translateY(40%) scale(.92);
    transition: opacity .25s ease, transform .45s var(--ease);
}
#root.open .tablet { opacity: 1; transform: none; }
.camera {
    position: absolute; top: 7px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #4a5a7a, #0a0c12 60%); box-shadow: 0 0 0 2px #1b1e25;
}
.screen {
    position: relative; height: 100%; display: flex; overflow: hidden; border-radius: 22px;
    background: #0b0d14; box-shadow: 0 0 0 2px #000;
}
.screen::before { content: ""; position: absolute; inset: 0; background: url("background-blur.jpg") center / cover no-repeat; opacity: .55; }
.screen::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(8, 10, 18, .92), rgba(12, 10, 26, .82)); }
.glare {
    position: absolute; inset: 0; z-index: 30; pointer-events: none; border-radius: inherit;
    background: linear-gradient(115deg, rgba(255, 255, 255, .06) 0%, rgba(255, 255, 255, .02) 28%, transparent 29%);
}

/* Sidebar */
.sidebar {
    position: relative; z-index: 1; width: 220px; flex-shrink: 0; display: flex; flex-direction: column;
    padding: 18px 12px; border-right: 1px solid var(--line); background: rgba(0, 0, 0, .22);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand strong { display: block; font-size: 15px; }
.brand span { font-size: 11px; color: var(--muted); letter-spacing: .4px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav button {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
    font-size: 13.5px; color: var(--muted); text-align: left; transition: background .15s, color .15s;
}
.nav button:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.nav button.active { background: linear-gradient(90deg, rgba(245, 197, 24, .28), rgba(184, 137, 0, .12)); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav .badge { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, .08); }
.me { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); }
.avatar {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
    font-weight: 700; font-size: 14px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.me-text { min-width: 0; }
.me-text strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main */
.main { position: relative; z-index: 1; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px 12px; }
.crumbs { display: flex; align-items: center; gap: 10px; }
.crumbs h1 { margin: 0; font-size: 21px; font-weight: 650; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.clock { font-size: 13px; color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.icon-btn {
    width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
    background: var(--card-2); border: 1px solid var(--line); transition: background .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); }
.icon-btn.danger:hover { background: rgba(255, 77, 109, .3); }
.content { flex: 1; overflow-y: auto; padding: 4px 22px 22px; }
.content::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 3px; }

/* Building blocks */
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card { padding: 14px 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: flex; align-items: center; gap: 8px; }
.card h3 .spacer { flex: 1; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat.accent { background: linear-gradient(135deg, rgba(245, 197, 24, .3), rgba(184, 137, 0, .12)); }
.section-title { margin: 18px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px;
    border-radius: 11px; font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, .07);
    border: 1px solid var(--line); transition: background .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .13); }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(255, 77, 109, .16); color: #ff8aa0; border-color: rgba(255, 77, 109, .3); }
.btn.danger:hover { background: rgba(255, 77, 109, .3); }
.btn.good { background: rgba(46, 204, 113, .14); color: #6ee7a4; border-color: rgba(46, 204, 113, .3); }
.btn.warn { background: rgba(255, 181, 71, .14); color: #ffcd7f; border-color: rgba(255, 181, 71, .3); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 9px; }
.btn.on { background: linear-gradient(135deg, rgba(46, 204, 113, .35), rgba(46, 204, 113, .15)); border-color: rgba(46, 204, 113, .5); }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.btn-grid .btn { flex-direction: column; padding: 12px 8px; gap: 6px; font-size: 12px; }
.btn-grid .btn svg { width: 20px; height: 20px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

input, select, textarea {
    width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
    background: rgba(0, 0, 0, .3); outline: none; font-size: 13px; user-select: text;
}
input:focus, select:focus, textarea:focus { border-color: rgba(245, 197, 24, .7); }
select option { background: #14161f; }
textarea { resize: none; min-height: 80px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, .04); vertical-align: middle; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover td { background: rgba(255, 255, 255, .04); }
td.muted, .muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, .08); white-space: nowrap; }
.tag .dot, .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.tag.bad { background: rgba(255, 77, 109, .18); color: #ff8aa0; }
.tag.warn { background: rgba(255, 181, 71, .18); color: #ffcd7f; }
.tag.good { background: rgba(46, 204, 113, .16); color: #6ee7a4; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { cursor: pointer; }
.copy:hover { color: var(--accent); }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.list { display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--card-2); font-size: 13px; }

.player-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.player-head .avatar { width: 52px; height: 52px; font-size: 20px; border-radius: 15px; }
.player-head h2 { margin: 0; font-size: 20px; }
.player-head .sub { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }

/* Roles */
.roles-layout { display: grid; grid-template-columns: 250px 1fr; gap: 12px; }
.role-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 11px; font-size: 13px; text-align: left; transition: background .12s; }
.role-item:hover { background: rgba(255, 255, 255, .05); }
.role-item.active { background: rgba(245, 197, 24, .2); }
.role-item small { margin-left: auto; color: var(--muted); }
.perm-group { margin-bottom: 12px; }
.perm-group h4 { margin: 0 0 7px; font-size: 12px; color: var(--muted); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.check { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 10px; background: var(--card-2); font-size: 12.5px; cursor: pointer; border: 1px solid transparent; }
.check:hover { border-color: var(--line); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.check.disabled { opacity: .45; cursor: not-allowed; }
input[type="color"] { padding: 2px; height: 38px; cursor: pointer; }

/* Modal */
.modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(4, 6, 12, .6); }
.modal-card { width: 420px; max-height: 90%; overflow-y: auto; padding: 22px; border-radius: 20px; background: #141724; border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.modal-card h2 { margin: 0 0 14px; font-size: 17px; }
.modal-fields { display: flex; flex-direction: column; gap: 11px; }
.modal-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Toast */
.toast {
    position: absolute; left: 50%; bottom: 22px; z-index: 25; transform: translate(-50%, 20px); opacity: 0;
    padding: 10px 18px; border-radius: 12px; font-size: 13px; background: #1b1f2e; border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transition: opacity .2s, transform .25s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(46, 204, 113, .5); }
.toast.err { border-color: rgba(255, 77, 109, .6); }

/* Announcement (shown to everyone, no focus) */
.announce {
    position: fixed; top: 4.5vh; left: 50%; width: 560px; max-width: 90vw; transform: translateX(-50%);
    display: flex; gap: 14px; padding: 16px 18px 20px; border-radius: 18px; overflow: hidden;
    background: linear-gradient(135deg, rgba(20, 16, 40, .94), rgba(14, 18, 34, .94));
    border: 1px solid rgba(245, 197, 24, .45); box-shadow: 0 16px 40px rgba(0, 0, 0, .45), 0 0 30px rgba(245, 197, 24, .2);
    animation: drop .5s var(--ease);
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -30px); } to { opacity: 1; transform: translate(-50%, 0); } }
.announce.leave { opacity: 0; transform: translate(-50%, -20px); transition: opacity .3s, transform .3s; }
.announce-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.announce-icon svg { width: 22px; height: 22px; }
.announce-title { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 15px; }
.announce-title span:last-child { font-weight: 500; font-size: 12px; color: var(--muted); }
.announce-text { margin-top: 4px; font-size: 14px; line-height: 1.45; word-break: break-word; }
.announce-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .06); }
.announce-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); animation: shrink linear forwards; animation-duration: var(--duration, 12s); }
@keyframes shrink { from { width: 100%; } to { width: 0; } }

/* Web mode (browser + Discord sign-in) */
body.web {
    background: #07090f url('background-blur.jpg') center / cover no-repeat;
    user-select: text;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
body.web #root.open { background: radial-gradient(ellipse at 50% 60%, rgba(5, 8, 15, .15), rgba(5, 8, 15, .55)); }
img.avatar { object-fit: cover; padding: 0; }
.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, rgba(5, 8, 15, .25), rgba(5, 8, 15, .75)); }
.login-card {
    width: min(380px, calc(100vw - 32px)); padding: 34px 30px 22px; border-radius: 26px; text-align: center;
    background: rgba(14, 16, 24, .82); border: 1px solid var(--line);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, .75); display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.login-card img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 6px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login-card small { margin-top: 18px; color: var(--muted); font-size: 11px; letter-spacing: .4px; }
.btn.discord { width: 100%; padding: 12px 16px; font-size: 14px; color: #fff; text-decoration: none; background: #5865f2; border-color: transparent; }
.btn.discord:hover { background: #4752c4; }
.btn.discord svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.login-error { width: 100%; margin-top: 12px; padding: 9px 12px; border-radius: 10px; font-size: 13px; background: rgba(255, 77, 109, .14); border: 1px solid rgba(255, 77, 109, .3); color: #ff9fb1; }
.login-error.info { background: rgba(46, 204, 113, .12); border-color: rgba(46, 204, 113, .3); color: #8ef0b8; }

.shot-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(5, 6, 12, .88); }
.shot-box { width: min(92vw, 1100px); background: #121520; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.shot-box img { width: 100%; border-radius: 10px; display: block; }
