/* Tervia Admin Kit: the game's brown UI for the owner/admin panels.
   Same palette, borders and buttons as the in-game windows. No framework, no external fonts. */
:root {
  --night: #17110d; --night2: #231a14;
  --wood: #4a3d30; --wood-light: #5a5047; --wood-dark: #332c26; --ink: #1c1713;
  --cream: #f6ecd9; --muted: #b9ad9c; --dim: #8f8576;
  --gold: #f2c878; --gold-deep: #c9983f;
  --green: #6fa253; --green-deep: #4d7a38; --red: #c4554a; --red-deep: #8f3a32; --blue: #5b9bd5; --orange: #e08a3c;
  --slot: #392c23; --slot-edge: #5e5349;
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--cream); font: 700 14px/1.4 var(--font); -webkit-font-smoothing: antialiased;
  background: var(--night);
  background-image:
    linear-gradient(180deg, rgba(23,17,13,.0) 0%, rgba(23,17,13,.92) 55%),
    url("/assets/hub/dirt.png");
  background-size: auto, 64px 64px; image-rendering: pixelated; background-attachment: fixed;
}
body::before { /* drifting embers, like the lava world */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(circle, #ff9a4a 0 1px, transparent 2px), radial-gradient(circle, #ffd27a 0 1px, transparent 2px);
  background-size: 140px 140px, 220px 220px; background-position: 0 0, 70px 90px;
  animation: tv-embers 40s linear infinite;
}
@keyframes tv-embers { to { background-position: 0 -280px, 70px -130px; } }
.tv-app { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 14px 16px 40px; }
[hidden], .tv-hidden { display: none !important; }

/* ----- Top bar (like the game HUD) ----- */
.tv-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tv-logo { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.tv-logo-mark {
  width: 42px; height: 42px; display: grid; place-items: center; color: #3a2a12; font: 900 24px/1 var(--font);
  background: linear-gradient(#f6d58a, var(--gold-deep)); border: 3px solid var(--ink); border-radius: 9px;
  box-shadow: 0 3px 0 rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.45);
}
.tv-logo-title { font: 900 20px/1.1 var(--font); letter-spacing: .02em; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.tv-logo-sub { color: var(--muted); font-size: 12px; font-weight: 700; }
.tv-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; min-height: 34px;
  background: var(--ink); border: 2px solid var(--slot-edge); border-radius: 999px; color: var(--cream); font-weight: 800; font-size: 13px;
}
.tv-pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.tv-pill.live::before { background: #8be36a; box-shadow: 0 0 8px #8be36a; animation: tv-pulse 1.6s infinite; }
.tv-pill.warn::before { background: var(--orange); }
.tv-pill.bad::before { background: var(--red); }
@keyframes tv-pulse { 50% { opacity: .35; } }
.tv-nav { display: flex; gap: 6px; }
.tv-nav a {
  padding: 7px 12px; color: var(--muted); text-decoration: none; font-weight: 800; border-radius: 8px; border: 2px solid transparent;
}
.tv-nav a:hover { color: var(--cream); background: rgba(0,0,0,.25); }
.tv-nav a.here { color: var(--gold); border-color: var(--gold); background: rgba(0,0,0,.3); }
/* The six areas (kit.js AREAS): a button that opens its pages. */
.tv-area { position: relative; }
.tv-area-btn { padding: 7px 12px; color: var(--muted); font: 800 14px/1.2 var(--font); border-radius: 8px; border: 2px solid transparent; background: none; cursor: pointer; }
.tv-area-btn:hover, .tv-area.open .tv-area-btn { color: var(--cream); background: rgba(0,0,0,.25); }
.tv-area-btn.here { color: var(--gold); border-color: var(--gold); background: rgba(0,0,0,.3); }
.tv-area-list { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 500; min-width: 250px; padding: 6px; border-radius: 10px; background: #1d1a17; border: 2px solid var(--ink); box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.tv-area.open .tv-area-list { display: grid; gap: 2px; }
.tv-area-list a { padding: 8px 10px; border-radius: 6px; color: var(--cream); text-decoration: none; font-weight: 700; white-space: nowrap; border: 0; }
.tv-area-list a:hover { background: #3a2c1c; }
.tv-area-list a.here { color: var(--gold); }
/* Pages that read as one: a tab strip under the menu (kit.js ROOMS). */
.tv-room { display: flex; gap: 4px; flex-wrap: wrap; margin: -6px 0 14px; padding: 4px; border-radius: 10px; background: rgba(0,0,0,.25); width: fit-content; }
.tv-room a { padding: 6px 12px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 800; }
.tv-room a:hover { color: var(--cream); background: rgba(0,0,0,.25); }
.tv-room a.here { color: #3a2a12; background: var(--gold); }

/* ----- Windows (panels) ----- */
.tv-window {
  position: relative; color: var(--cream); background: var(--wood); border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.12), inset 0 -3px 0 rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.45);
}
.tv-window > .tv-window-title {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; font: 900 15px/1.2 var(--font); color: var(--gold); letter-spacing: .03em;
  background: linear-gradient(var(--wood-light), var(--wood)); border-bottom: 3px solid var(--ink); border-radius: 7px 7px 0 0; text-shadow: 0 2px 0 var(--ink);
}
.tv-window-title small { margin-left: auto; color: var(--dim); font-weight: 700; text-shadow: none; }
.tv-window-body { padding: 12px 14px 14px; }
.tv-sunk { background: rgba(0,0,0,.28); border: 2px solid rgba(0,0,0,.35); border-radius: 8px; box-shadow: inset 0 2px 4px rgba(0,0,0,.35); }
.tv-hint { color: var(--muted); font-weight: 600; font-size: 13px; }
.tv-h { margin: 0 0 8px; font: 900 18px/1.2 var(--font); color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.tv-grid { display: grid; gap: 12px; }
.tv-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tv-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tv-grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
@media (max-width: 820px) { .tv-grid.cols-2, .tv-grid.cols-3 { grid-template-columns: 1fr; } }

/* ----- Buttons ----- */
.tv-btn {
  min-height: 38px; padding: 0 16px; cursor: pointer; color: var(--cream); background: var(--wood-light);
  font: 800 14px/1 var(--font); border: 2px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.16), inset 0 -3px 0 rgba(0,0,0,.28), 0 2px 0 rgba(0,0,0,.4);
}
.tv-btn:hover { filter: brightness(1.1); }
.tv-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(0,0,0,.2); }
.tv-btn:disabled { opacity: .5; cursor: default; transform: none; filter: none; }
.tv-btn.primary { color: #fff; background: var(--green); }
.tv-btn.gold { color: #3a2a12; background: var(--gold); }
.tv-btn.danger { color: #fff; background: var(--red); }
.tv-btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }

/* ----- Tabs: look like hotbar / inventory slots ----- */
.tv-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.tv-tab {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; color: var(--cream); font: 800 14px/1 var(--font);
  background: var(--slot); border: 3px solid var(--slot-edge); border-radius: 9px; box-shadow: 0 3px 0 rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
}
.tv-tab:hover { border-color: #7a6c5f; }
.tv-tab.on { border-color: #e7c683; box-shadow: 0 0 0 2px rgba(231,198,131,.4), 0 3px 0 rgba(0,0,0,.28); color: var(--gold); }
.tv-tab canvas { width: 24px; height: 24px; image-rendering: pixelated; }

/* ----- Segmented picker (time range etc.) ----- */
.tv-seg { display: inline-flex; background: var(--ink); border: 2px solid var(--slot-edge); border-radius: 9px; overflow: hidden; }
.tv-seg button { min-height: 32px; padding: 0 12px; cursor: pointer; color: var(--muted); background: transparent; border: 0; font: 800 13px/1 var(--font); }
.tv-seg button.on { color: #3a2a12; background: var(--gold); }

/* ----- Form fields: inset like game text boxes ----- */
.tv-field { display: flex; flex-direction: column; gap: 4px; }
.tv-field > span { color: var(--muted); font: 800 11px/1.2 var(--font); text-transform: uppercase; letter-spacing: .05em; }
.tv-field small { color: var(--dim); font-weight: 600; font-size: 12px; }
.tv-input, .tv-select, .tv-textarea {
  width: 100%; min-height: 38px; padding: 0 10px; color: var(--cream); background: var(--wood-dark); font: 700 15px/1.2 var(--font);
  border: 2px solid rgba(255,232,190,.28); border-radius: 6px; outline: none; box-shadow: inset 0 2px 3px rgba(0,0,0,.3);
}
.tv-textarea { min-height: 80px; padding: 8px 10px; resize: vertical; }
.tv-input:focus, .tv-select:focus, .tv-textarea:focus { border-color: var(--gold); }
.tv-input::placeholder { color: rgba(246,236,217,.35); }
.tv-input[type="color"] { padding: 2px; height: 38px; }

/* ----- Toggle (lever) ----- */
.tv-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 800; }
.tv-toggle input { display: none; }
.tv-toggle i { position: relative; width: 46px; height: 24px; background: var(--ink); border: 2px solid var(--slot-edge); border-radius: 12px; transition: background .12s; }
.tv-toggle i::after { content: ""; position: absolute; top: 1px; left: 1px; width: 18px; height: 18px; border-radius: 50%; background: var(--wood-light); border: 2px solid var(--ink); transition: transform .12s, background .12s; }
.tv-toggle input:checked + i { background: var(--green-deep); }
.tv-toggle input:checked + i::after { transform: translateX(22px); background: #d8f0c8; }

/* ----- Stat tiles + bars (the HUD look) ----- */
.tv-stat { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--slot); border: 3px solid var(--slot-edge); border-radius: 9px; box-shadow: 0 3px 0 rgba(0,0,0,.28); }
.tv-stat.good { border-left-color: #6fa253; } .tv-stat.warn { border-left-color: var(--orange); } .tv-stat.bad { border-left-color: var(--red); }
.tv-stat canvas { flex: 0 0 auto; width: 36px; height: 36px; image-rendering: pixelated; }
.tv-stat-body { min-width: 0; }
.tv-stat-label { color: var(--muted); font: 800 11px/1.2 var(--font); text-transform: uppercase; letter-spacing: .05em; }
.tv-stat-value { font: 900 22px/1.15 var(--font); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tv-stat-note { color: var(--dim); font-size: 12px; font-weight: 600; }
.tv-bar { position: relative; height: 22px; background: var(--ink); border: 2px solid var(--slot-edge); border-radius: 999px; overflow: hidden; }
.tv-bar > i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#7fe0c9, #2fa093); transition: width .5s; }
.tv-bar.good > i { background: linear-gradient(#8fd06f, #4d8f35); }
.tv-bar.warn > i { background: linear-gradient(#f2b45c, #c9792a); }
.tv-bar.bad > i { background: linear-gradient(#e8786b, #a8382f); }
.tv-bar > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; font: 900 12px/1 var(--font); text-shadow: 0 1px 0 rgba(0,0,0,.7); }
.tv-meter { display: grid; gap: 4px; }
.tv-meter-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 10px; font-weight: 800; }
.tv-meter-label small { color: var(--dim); font-weight: 600; }

/* ----- Tables: a ledger on wood ----- */
.tv-table-wrap { overflow: auto; max-height: 60vh; border-radius: 8px; }
.tv-table { width: 100%; border-collapse: collapse; font-weight: 600; }
.tv-table th { position: sticky; top: 0; text-align: left; padding: 8px 10px; color: var(--gold); background: var(--wood-light); border-bottom: 3px solid var(--ink); font: 900 12px/1 var(--font); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.tv-table td { padding: 8px 10px; border-bottom: 1px solid rgba(0,0,0,.3); vertical-align: top; }
.tv-table tbody tr:nth-child(odd) { background: rgba(0,0,0,.12); }
.tv-table tbody tr:hover { background: rgba(231,198,131,.1); }

/* ----- Sign-in: like the game's welcome screen ----- */
.tv-login { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index: 1; }
.tv-login-card { width: min(380px, 100%); text-align: center; }
.tv-login-card .tv-logo-mark { width: 64px; height: 64px; font-size: 38px; margin: 0 auto 10px; }
.tv-login-card form { display: grid; gap: 10px; margin-top: 12px; text-align: left; }
.tv-error { min-height: 18px; color: #ff9a8a; font-weight: 700; font-size: 13px; }

/* ----- Dialog + toast ----- */
.tv-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10,8,6,.62); }
.tv-dialog { width: min(420px, 100%); }
.tv-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.tv-toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; max-width: min(520px, calc(100vw - 24px));
  padding: 10px 16px; color: var(--cream); background: var(--wood); border: 3px solid var(--ink); border-radius: 9px; font-weight: 800;
  box-shadow: 0 8px 20px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.14);
}
.tv-toast.bad { border-color: var(--red); } .tv-toast.good { border-color: var(--green); }

/* ----- Notice strip ----- */
.tv-notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 12px; border-radius: 9px; border: 3px solid var(--ink); background: var(--wood-dark); font-weight: 700; }
.tv-notice.warn { border-color: var(--orange); } .tv-notice.bad { border-color: var(--red); } .tv-notice.good { border-color: var(--green); }
.tv-chart { display: block; width: 100%; height: 190px; image-rendering: auto; }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } .tv-pill.live::before { animation: none; } }
.tv-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--orange, #e0913b); color: #1c1713; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* "How to" help box at the top of admin pages (TV.howTo). */
.tv-howto { margin: 0 0 14px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 10px; background: var(--wood-dark); }
.tv-howto-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tv-howto-head b { font-size: 15px; }
.tv-howto-body { margin-top: 6px; font-weight: 600; line-height: 1.45; }
.tv-howto-body p { margin: 0 0 6px; }
.tv-howto-body ol { margin: 0; padding-left: 22px; }
.tv-howto-body li { margin: 2px 0; }
.tv-howto.closed .tv-howto-body { display: none; }
.tv-nav { flex-wrap: wrap; }

/* Scrollbars: thin, wood and gold, on every admin page. */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #1f1813; border-radius: 8px; }
::-webkit-scrollbar-thumb { background: #5e5349; border: 3px solid #1f1813; border-radius: 8px; min-height: 40px; }
::-webkit-scrollbar-thumb:hover { background: #c9983f; }
::-webkit-scrollbar-thumb:active { background: #f2c878; }
::-webkit-scrollbar-corner { background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: #5e5349 #1f1813; }
}
