:root {
  color-scheme: dark;
  --ink: #e8e8dc;
  --muted: #8e9488;
  --faint: #5e665d;
  --line: rgba(221, 226, 210, 0.12);
  --line-strong: rgba(221, 226, 210, 0.2);
  --surface: rgba(22, 26, 22, 0.94);
  --page: #101516;
  --accent: #96aeb1;
  --accent-bright: #d0e1df;
  --danger: #d47d69;
  font-family: "IBM Plex Mono", Consolas, monospace;
  background: var(--page);
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
/* Ambient battlefield layers and low-contrast faction insignia. */
body {
  position: relative;
  isolation: isolate;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
}
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.ambient-scene { position: fixed; z-index: -1; inset: 0; overflow: hidden; pointer-events: none; }
.ambient-image { position: absolute; inset: -24px; background: url("knightbg.png") center 42% / cover no-repeat; filter: blur(3px) saturate(0.68); opacity: 0.35; transform: translate3d(var(--parallax-x, 0px), var(--parallax-y, 0px), 0) scale(1.045); will-change: transform; }
.ambient-wash { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10, 15, 16, 0.88), rgba(11, 16, 17, 0.68) 48%, rgba(10, 15, 16, 0.82)), linear-gradient(0deg, rgba(11, 15, 16, 0.92), rgba(11, 15, 16, 0.24) 54%, rgba(11, 15, 16, 0.66)); }
.ambient-particles { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.6; }
.faction-mark { position: absolute; display: grid; justify-items: center; gap: 8px; color: rgba(183, 205, 203, 0.1); font-family: "Barlow Condensed", Impact, sans-serif; font-weight: 700; text-align: center; animation: insignia-drift 12s ease-in-out infinite alternate; }
.faction-mark span { display: grid; width: 110px; aspect-ratio: 1; place-items: center; border: 1px solid currentColor; outline: 1px solid rgba(183, 205, 203, 0.045); outline-offset: 8px; font-size: 76px; line-height: 1; }
.faction-mark small { font-family: "IBM Plex Mono", Consolas, monospace; font-size: 8px; font-weight: 400; }
.unheard-mark { top: 19%; right: 7%; transform: rotate(45deg); }
.unheard-mark span { transform: rotate(-45deg); }
.unheard-mark small { transform: rotate(-45deg); }
.goons-mark { bottom: 13%; left: 7%; animation-delay: -5s; }
.goons-mark span { border-style: dashed; font-size: 32px; letter-spacing: 5px; }
.page-frame { position: relative; z-index: 1; width: min(1160px, calc(100% - 64px)); margin: 0 auto; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; width: 35px; aspect-ratio: 1; place-items: center; border: 1px solid var(--accent); color: var(--accent-bright); font-family: "Barlow Condensed", Impact, sans-serif; font-size: 17px; font-weight: 700; }
.brand-name, .topbar-meta, .eyebrow, .record-tag, .page-footer, .item-index, .loading-panel p { font-size: 10px; font-weight: 500; letter-spacing: 0; }
.brand-name { color: var(--ink); }
.brand-name span { color: var(--muted); }
.topbar-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.live-dot, .status-indicator { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #9db9aa; box-shadow: 0 0 10px rgba(157, 185, 170, 0.55); }
main { padding-top: 58px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 28px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 11px; color: var(--accent); }
.eyebrow-rule { width: 22px; height: 1px; background: var(--accent); }
#today-date { margin-left: 7px; color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Barlow Condensed", "Arial Narrow", Impact, sans-serif; font-weight: 700; letter-spacing: 0; }
h1 { margin-bottom: 2px; font-size: clamp(42px, 6vw, 68px); line-height: 0.97; text-transform: uppercase; }
.title-period { color: var(--accent); }
.intro-copy { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.button { min-height: 42px; padding: 0 15px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.025); color: var(--ink); cursor: pointer; font-size: 11px; transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease; }
.button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-bright); background: rgba(150, 174, 177, 0.1); transform: translateY(-2px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.reroll-icon { margin-right: 7px; color: var(--accent); font-size: 17px; vertical-align: -1px; }
.status-strip { min-height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); background: rgba(12, 15, 12, 0.55); color: var(--muted); font-size: 10px; }
.status-strip[data-state="error"] { color: #df9c8c; border-color: rgba(212, 125, 105, 0.32); }
.status-strip[data-state="error"] .status-indicator { background: var(--danger); }
.status-strip[data-state="ready"] .status-indicator { background: #8aa777; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.8fr); gap: 14px; align-items: stretch; margin-top: 14px; }
.item-card, .tracker-panel { min-width: 0; border: 1px solid var(--line-strong); background: rgba(15, 20, 20, 0.91); backdrop-filter: blur(8px); }
.item-card { min-height: 395px; display: grid; grid-template-columns: minmax(210px, 0.82fr) minmax(0, 1fr); overflow: hidden; animation: rise-in 420ms cubic-bezier(0.2, 0.7, 0.25, 1) both; }
/* Dual-scale cell lines evoke small loot slots and larger inventory grids. */
.item-art { position: relative; display: grid; min-height: 100%; place-items: center; overflow: hidden; border-right: 1px solid var(--line); background-color: #141a1a; background-image: linear-gradient(rgba(191, 211, 206, 0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(191, 211, 206, 0.045) 1px, transparent 1px), linear-gradient(rgba(191, 211, 206, 0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(191, 211, 206, 0.018) 1px, transparent 1px), radial-gradient(ellipse at center, rgba(144, 179, 178, 0.16), transparent 57%); background-size: 48px 48px, 48px 48px, 12px 12px, 12px 12px, cover; }
.item-art > img { transition: transform 420ms cubic-bezier(0.2, 0.7, 0.25, 1), filter 420ms ease; }
.item-card:hover .item-art > img { transform: scale(1.055); filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.62)) brightness(1.08); }
.item-art::before, .item-art::after { position: absolute; width: 28px; height: 28px; content: ""; border-color: rgba(201, 166, 107, 0.55); border-style: solid; }
.item-art::before { top: 13px; left: 13px; border-width: 1px 0 0 1px; }
.item-art::after { right: 13px; bottom: 13px; border-width: 0 1px 1px 0; }
.item-art img { z-index: 1; width: min(70%, 250px); max-height: 260px; object-fit: contain; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.5)); }
.item-art-fallback { color: var(--faint); font-family: "Barlow Condensed", sans-serif; font-size: 76px; font-weight: 700; }
.item-index { position: absolute; left: 18px; bottom: 16px; color: var(--faint); }
.item-details { display: flex; flex-direction: column; justify-content: center; padding: 34px clamp(20px, 4vw, 42px); }
.item-category { margin-bottom: 9px; color: var(--accent); font-size: 10px; text-transform: uppercase; }
.item-name { margin-bottom: 24px; overflow-wrap: anywhere; font-size: clamp(30px, 4vw, 44px); line-height: 0.99; text-transform: uppercase; }
.item-description { margin: -13px 0 20px; color: var(--muted); font-size: 11px; }
.item-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.item-fact { min-width: 0; padding: 12px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.item-fact-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.item-fact-value { display: block; overflow-wrap: anywhere; color: var(--ink); font-size: 11px; font-weight: 500; }
.item-fact-value a { color: var(--accent-bright); text-decoration-color: rgba(225, 195, 141, 0.4); text-underline-offset: 3px; }
.tracker-panel { display: flex; flex-direction: column; padding: 24px 22px 17px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.panel-heading .eyebrow { margin-bottom: 4px; font-size: 9px; }
.panel-heading h2 { margin: 0; font-size: 26px; text-transform: uppercase; }
.record-tag { padding: 5px 7px; border: 1px solid rgba(138, 167, 119, 0.35); color: #9bb58a; }
.tracker-region { display: grid; flex: 1; align-content: center; }
.tracker-empty { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.tracker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 66px; border-bottom: 1px solid var(--line); }
.tracker-label { color: var(--ink); font-size: 11px; }
.tracker-controls { display: inline-grid; grid-template-columns: 32px 48px 32px; align-items: center; text-align: center; }
.count-button { width: 30px; height: 30px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.025); color: var(--accent-bright); cursor: pointer; font-size: 17px; line-height: 1; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.count-button:hover:not(:disabled) { border-color: var(--accent); background: rgba(150, 174, 177, 0.12); transform: scale(1.06); }
.count-button:disabled { color: var(--faint); cursor: not-allowed; }
.count-value { color: var(--ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tracker-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 15px; color: var(--faint); font-size: 9px; }
.text-button { padding: 4px 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 9px; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.text-button:hover:not(:disabled) { color: var(--danger); text-decoration-color: var(--danger); }
.text-button:disabled { cursor: not-allowed; opacity: 0.45; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.logout-button { color: var(--muted); font-size: 9px; }
.admin-panel { margin-top: 18px; padding: 24px 22px 20px; border: 1px solid var(--line-strong); background: rgba(15, 20, 20, 0.91); backdrop-filter: blur(8px); animation: rise-in 360ms ease both; }
.admin-panel[hidden] { display: none; }
.admin-panel .panel-heading { align-items: center; }
.admin-create-form { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(130px, 0.8fr) minmax(180px, 1.2fr) auto; align-items: end; gap: 10px; padding-top: 18px; }
.admin-create-form label { display: grid; gap: 7px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.admin-create-form input, .admin-create-form select, .admin-table input, .admin-table select { width: 100%; min-width: 0; min-height: 38px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 0; background: rgba(255, 255, 255, 0.035); color: var(--ink); font: inherit; font-size: 10px; }
.admin-create-form input:focus, .admin-create-form select:focus, .admin-table input:focus, .admin-table select:focus { border-color: var(--accent); outline: 2px solid transparent; }
.admin-create-form option, .admin-table option { background: #111819; }
.admin-hint { margin: 10px 0 0; color: var(--faint); font-size: 9px; line-height: 1.6; }
.admin-message { min-height: 16px; margin: 9px 0; color: #a8c0aa; font-size: 10px; }
.admin-message[data-state="error"] { color: var(--danger); }
.admin-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.admin-table { width: 100%; min-width: 710px; border-collapse: collapse; text-align: left; }
.admin-table th { padding: 11px 8px 8px; color: var(--faint); font-size: 8px; font-weight: 500; text-transform: uppercase; }
.admin-table td { padding: 7px 8px; border-top: 1px solid var(--line); }
.admin-row-actions { white-space: nowrap; text-align: right; }
.admin-row-actions .text-button + .text-button { margin-left: 12px; }
.admin-delete { color: #c78677; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.loading-panel, .error-panel { min-height: 395px; display: grid; place-content: center; justify-items: center; gap: 13px; border: 1px solid var(--line-strong); background: var(--surface); text-align: center; }
.loading-panel p { margin: 0; color: var(--muted); }
.loading-mark { width: 34px; height: 34px; border: 1px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: rotate 900ms linear infinite; }
.error-panel { padding: 28px; }
.error-symbol { display: grid; width: 38px; aspect-ratio: 1; place-items: center; border: 1px solid rgba(212, 125, 105, 0.5); color: var(--danger); font-size: 20px; }
.error-panel h2 { margin: 0; font-size: 25px; text-transform: uppercase; }
.error-panel p { max-width: 440px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.error-panel .button { margin-top: 5px; }
.page-footer { display: flex; justify-content: space-between; gap: 15px; padding: 25px 1px 30px; color: var(--faint); font-size: 9px; }
.page-footer a { color: var(--muted); text-decoration: none; }
.page-footer a:hover { color: var(--accent-bright); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes insignia-drift { from { translate: 0 -4px; opacity: 0.75; } to { translate: 0 8px; opacity: 1; } }

@media (max-width: 800px) {
  .content-grid { grid-template-columns: 1fr; }
  .item-card { min-height: 360px; }
  .tracker-panel { min-height: 360px; }
}

@media (max-width: 560px) {
  .page-frame { width: min(100% - 32px, 440px); }
  .topbar { min-height: 64px; }
  .topbar-meta { font-size: 8px; }
  .topbar-actions { gap: 8px; }
  .logout-button { font-size: 8px; }
  main { padding-top: 39px; }
  .intro { align-items: start; flex-direction: column; margin-bottom: 21px; }
  .intro .button { align-self: stretch; }
  .content-grid { margin-top: 10px; gap: 10px; }
  .item-card { grid-template-columns: 1fr; }
  .item-art { min-height: 230px; border-right: 0; border-bottom: 1px solid var(--line); }
  .item-art img { width: min(46%, 170px); max-height: 165px; }
  .item-details { padding: 24px 20px; }
  .item-name { margin-bottom: 19px; font-size: 36px; }
  .tracker-panel { min-height: 340px; padding: 20px 18px 15px; }
  .admin-panel { padding: 19px 14px 15px; }
  .admin-create-form { grid-template-columns: 1fr 1fr; }
  .admin-create-form label:first-child, .admin-create-form label:nth-child(3) { grid-column: 1 / -1; }
  .admin-create-form .button { grid-column: 1 / -1; }
  .page-footer { align-items: start; flex-direction: column; padding-top: 20px; }
  .faction-mark span { width: 72px; font-size: 52px; }
  .faction-mark small { font-size: 7px; }
  .unheard-mark { top: 13%; right: 2%; }
  .goons-mark { bottom: 6%; left: 2%; }
}

@media (hover: none), (prefers-reduced-motion: reduce) {
  .ambient-image { transform: scale(1.045); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}