/* =====================================================================
   Admin — dark theme (black + neon green). Shared by the main admin shell
   and by games' own admin pages (e.g. games/precision-shot/admin.html).
   ===================================================================== */
:root {
    --bg: #0d1117;
    --bg2: #11161d;
    --card: #161b22;
    --card2: #1c222b;
    --ink: #e8edf2;
    --muted: #8b97a6;
    --line: #262d37;
    --accent: #39ff14;
    --accent-ink: #0a1a05;
    --blue: #39ff14;                 /* legacy name used by some components */
    --green: #39ff14;
    --red: #ff5a6a;
    --amber: #ffc24d;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; padding-bottom: 90px; }
a { color: var(--accent); }
code { background: #0b0f14; border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 12px; color: #b6f5a8; }
h1 { margin: 0; font-size: 30px; letter-spacing: -0.01em; }
h2 { margin: 0 0 4px; font-size: 18px; }
h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ------------------------------------------------------------- shell */
body.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto; background: #0a0e13; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 22px 14px 90px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 18px; font-weight: 900; box-shadow: 0 0 18px rgba(57, 255, 20, 0.35); }
.brand strong { display: block; font-size: 18px; letter-spacing: 0.04em; }
.brand small { color: var(--muted); letter-spacing: 0.18em; font-size: 11px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-main { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav-main:hover { background: var(--card); }
.nav-main.active { background: linear-gradient(90deg, rgba(57, 255, 20, 0.22), rgba(57, 255, 20, 0.06)); box-shadow: inset 3px 0 0 var(--accent); }
.nav-main .ico { width: 22px; text-align: center; }
.nav-sub { display: flex; flex-direction: column; margin: 2px 0 8px 34px; border-left: 1px solid var(--line); }
.nav-sub a { padding: 7px 12px; color: var(--muted); text-decoration: none; font-size: 14px; border-radius: 0 8px 8px 0; }
.nav-sub a:hover { color: var(--ink); }
.nav-sub a.active { color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.nav-sub a.off { opacity: 0.55; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.content { padding: 30px 36px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .muted { font-size: 15px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; flex-wrap: wrap; }
.crumbs a { color: var(--ink); text-decoration: none; font-weight: 600; }
.crumbs a:first-child { margin-right: 14px; }
.crumbs b { color: var(--ink); }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.search span { color: var(--muted); font-size: 18px; }
.search input { background: transparent; border: none; color: var(--ink); padding: 11px 0; width: 220px; outline: none; }

/* ---------------------------------------------------------- game grid */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.game-tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.game-tile:hover { border-color: rgba(57, 255, 20, 0.6); box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.35), 0 0 26px rgba(57, 255, 20, 0.15); }
.game-tile.off .tile-thumb { filter: grayscale(0.8) brightness(0.6); }
.game-tile.dragging { opacity: 0.4; }
.game-tile.drop { transform: scale(1.02); border-color: var(--accent); }
.tile-thumb {
    --tile-color: #1b6fd1; height: 150px; cursor: pointer; display: grid; place-items: center;
    background: linear-gradient(145deg, var(--tile-color), color-mix(in srgb, var(--tile-color) 45%, #000)) center / cover;
}
.tile-icon { font-size: 56px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4)); }
.tile-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.tile-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile-name { font-size: 18px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; }
.tile-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tile-meta .order { background: var(--card2); border-radius: 6px; padding: 1px 7px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.game-tile.off .status-dot { background: #58616d; box-shadow: none; }

/* ----------------------------------------------------------- game page */
.game-head { margin-bottom: 18px; }
.game-head-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.game-thumb-lg { --tile-color: #1b6fd1; width: 190px; height: 110px; border-radius: 12px; display: grid; place-items: center; font-size: 46px; border: 1px solid var(--line); background: linear-gradient(145deg, var(--tile-color), color-mix(in srgb, var(--tile-color) 45%, #000)) center / cover; }
.game-title-block { flex: 1; min-width: 240px; }
.title-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title-line h1 { text-transform: uppercase; }
.state-text { color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; margin-bottom: 18px; }
.tabs button {
    display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid transparent; color: var(--ink);
    font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 9px; cursor: pointer;
}
.tabs button:hover { background: var(--card); }
.tabs button.active { border-color: var(--accent); background: rgba(57, 255, 20, 0.1); color: var(--accent); }
.tab-icon { opacity: 0.9; }
.tab-body { display: grid; gap: 18px; }
.game-admin-frame { width: 100%; height: calc(100vh - 250px); min-height: 640px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }

/* ------------------------------------------------------------- cards */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 32px; background: #0a0e13; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
body.embedded .topbar { display: none; }
body.embedded main { margin-top: 0; }
main:not(.content) { max-width: 1040px; margin: 24px auto; padding: 0 16px; display: grid; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.note { border-radius: 10px; padding: 11px 14px; font-size: 14px; background: rgba(57, 255, 20, 0.07); border: 1px solid rgba(57, 255, 20, 0.25); color: #cfe9c8; }
.note-warn { background: rgba(255, 194, 77, 0.08); border-color: rgba(255, 194, 77, 0.35); color: var(--amber); }
.warning { background: rgba(255, 194, 77, 0.08); color: var(--amber); border: 1px solid rgba(255, 194, 77, 0.35); border-radius: 8px; padding: 8px 12px; margin-top: 10px; font-size: 13px; font-weight: 600; }

/* ------------------------------------------------------------ fields */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 14px 0 6px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: #c9d3de; }
.field small { font-weight: 400; }
select, input[type=text], input[type=number], input[type=search], textarea {
    font: inherit; color: var(--ink); padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #0b0f14;
}
select:focus, input:focus, textarea:focus { outline: 2px solid rgba(57, 255, 20, 0.35); border-color: var(--accent); }
input[readonly] { color: var(--muted); background: #10151b; }
input.bad, textarea.bad { border-color: var(--red) !important; background: #2a1116; }
.num { width: 90px; }
.color-wrap { display: flex; align-items: center; gap: 10px; }
.color-wrap input[type=color] { width: 46px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #0b0f14; cursor: pointer; }
.color-wrap code { font-size: 12px; }
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap input[type=range] { width: 100%; min-width: 140px; accent-color: var(--accent); }
.range-wrap output { font-weight: 700; white-space: nowrap; font-size: 13px; color: var(--ink); }
.row, .toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.toggle-row:first-of-type { border-top: none; }
.row-text { display: flex; flex-direction: column; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; margin-top: 12px; }
.error { color: var(--red); font-size: 13px; margin: 6px 0 0; }

/* switch */
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #39424e; border-radius: 26px; cursor: pointer; transition: background 0.15s; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
.switch input:checked + .slider { background: var(--accent); box-shadow: 0 0 12px rgba(57, 255, 20, 0.45); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons list */
.btn-row { border-top: 1px solid var(--line); padding: 14px 0 10px; }
.btn-row.off .btn-title { color: var(--muted); text-decoration: line-through; }
.btn-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.btn-title { font-size: 16px; letter-spacing: 0.03em; }
.btn-controls { display: flex; align-items: center; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.state { font-size: 12px; font-weight: 800; width: 30px; color: var(--muted); }
.state.on { color: var(--accent); }
.text-field { position: relative; flex: 1; min-width: 220px; }
.text-field input { width: 100%; padding-right: 58px; font-weight: 700; letter-spacing: 0.03em; }
.counter { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); }
.mini { font: inherit; border: 1px solid var(--line); background: var(--card2); color: var(--ink); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; }
.list-heading { margin: 18px 0 2px; font-size: 13px; letter-spacing: 0.06em; color: var(--accent); text-transform: uppercase; }

/* images */
.image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin: 12px 0; }
.image-field { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #11161d; }
.img-preview {
    width: 96px; height: 96px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
    background: repeating-conic-gradient(#1b2129 0 25%, #141920 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line);
}
.img-preview.round { border-radius: 50%; }
.img-preview img, .img-preview video { width: 100%; height: 100%; object-fit: contain; }
.img-preview.round img { object-fit: cover; }
.img-preview span { font-size: 11px; text-align: center; }
.img-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.img-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.img-error { color: var(--red); font-weight: 600; }

/* buttons */
.btn { font: inherit; font-weight: 700; border-radius: 10px; padding: 10px 18px; cursor: pointer; border: 1px solid transparent; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 18px rgba(57, 255, 20, 0.3); }
.btn.primary:disabled { background: #2b3a2a; color: #6f8a6b; box-shadow: none; cursor: default; }
.btn.ghost { background: var(--card2); border-color: var(--line); color: var(--ink); }
.btn.ghost:disabled { color: #56606c; cursor: default; }
.btn.outline { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn.outline:hover { background: rgba(57, 255, 20, 0.1); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn:disabled.danger { color: #6d4a50; cursor: default; }
label.btn { display: inline-flex; }
.link-btn { color: var(--accent); font-weight: 700; text-decoration: none; border: 1px solid var(--line); padding: 8px 14px; border-radius: 9px; white-space: nowrap; background: var(--card); }
.link-btn:hover { border-color: var(--accent); }
.link-btn.small { padding: 5px 10px; font-size: 13px; }

/* save bar */
.savebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 14px 32px; background: rgba(10, 14, 19, 0.95); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
body.admin-shell .savebar { left: 250px; }
.status { margin-right: auto; font-weight: 600; font-size: 14px; color: var(--muted); }
.status.ok { color: var(--accent); }
.status.warn { color: var(--amber); }
.status.error { color: var(--red); }
.storage { margin-top: 16px; }
.warn-text { color: var(--amber); font-weight: 700; }

@media (max-width: 900px) {
    body.admin-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding-bottom: 14px; }
    body.admin-shell .savebar { left: 0; }
    .content { padding: 20px 16px; }
}

/* accordion sections: tap the title to open / close */
section.card.acc > h2 { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 10px; }
section.card.acc > h2::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 0.15s; font-size: 16px; }
section.card.acc.closed > h2::after { transform: rotate(-90deg); }
section.card.acc.closed { padding-top: 16px; padding-bottom: 16px; }
section.card.acc.closed > :not(h2) { display: none !important; }
section.card.acc:not(.closed) { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
/* bigger, touch-friendly tabs and game cards */
.tabs button { min-height: 48px; font-size: 15px; }
.game-tile .btn { min-height: 46px; }
.game-head-row .game-thumb-lg { width: 150px; height: 88px; }
/* a game's own panel (iframe) has its own GUARDAR: the shell's bar only shows when the menu card changed */
body.on-embedded .savebar:has(#btn-save:disabled) { display: none; }

/* ---------------------------------------------------------------- simple admin: card tabs + one section at a time */
.tabs.card-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; border: 0; }
.tabs.card-tabs button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel, #141a24); font-weight: 700; }
.tabs.card-tabs button .tab-icon { font-size: 26px; }
.tabs.card-tabs button.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.sec-chips { display: flex; flex-wrap: wrap; gap: 8px; position: sticky; top: 0; z-index: 3; padding: 8px 0; background: var(--bg, #0b0f17); }
.sec-chips button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; font: 600 13px/1.2 inherit; font-family: inherit; }
.sec-chips button.active { background: var(--accent); border-color: var(--accent); color: #06130a; }
