:root {
  --bg: #070911;
  --bg-2: #0c101c;
  --panel: rgba(19, 24, 39, .92);
  --panel-2: #171e2f;
  --panel-3: #202a40;
  --line: #303b55;
  --line-bright: #52627f;
  --text: #edf0f7;
  --muted: #9ba7bd;
  --soft: #6f7d96;
  --gold: #e2bd70;
  --gold-2: #9c7131;
  --violet: #9179e6;
  --blue: #5daee6;
  --green: #62d39b;
  --red: #e66a7f;
  --orange: #e99d55;
  --shadow: 0 22px 70px rgba(0, 0, 0, .42);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(82, 64, 142, .2), transparent 34rem),
    radial-gradient(circle at 90% 12%, rgba(34, 94, 128, .18), transparent 36rem),
    linear-gradient(145deg, #090b13, #080a10 55%, #05060a);
}
a { color: #b8d8f1; text-decoration: none; }
a:hover { color: #fff; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
img { max-width: 100%; display: block; }
code { font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; color: #c9d7ee; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 10px max(20px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid rgba(82, 98, 127, .45);
  background: rgba(7, 9, 17, .88);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 240px; }
.brand img { width: 44px; height: 44px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.brand span { display: grid; }
.brand b { font-family: Georgia, serif; letter-spacing: .02em; }
.brand small { color: var(--soft); font-size: 11px; }
.site-nav { display: flex; align-items: center; justify-content: flex-end; gap: 18px; flex-wrap: wrap; }
.site-nav > a, .link-button { color: var(--muted); }
.site-nav > a:hover, .link-button:hover { color: #fff; }
.admin-link { color: #d6c2ff !important; }
.inline-form { display: inline-flex; margin: 0; }
.link-button { appearance: none; border: 0; background: transparent; cursor: pointer; padding: 4px 0; }

.page-shell { width: min(1120px, calc(100% - 32px)); margin: 34px auto 70px; }
.wide-shell { width: min(1420px, calc(100% - 32px)); }
.game-shell { width: min(1480px, calc(100% - 24px)); margin-top: 18px; }
.admin-shell { width: min(1540px, calc(100% - 24px)); margin-top: 20px; }
.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px max(20px, calc((100vw - 1440px) / 2)); color: var(--soft); border-top: 1px solid rgba(82, 98, 127, .28); font-size: 12px; }
.clock-warning { padding: 9px 20px; text-align: center; background: #5b4216; color: #ffe6a6; border-bottom: 1px solid #b68a37; }

.card {
  border: 1px solid rgba(70, 83, 112, .72);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(24, 30, 47, .95), rgba(13, 17, 28, .96));
  box-shadow: var(--shadow);
}
.card h1, .card h2, .card h3 { font-family: Georgia, "Times New Roman", serif; margin-top: 0; }
.card h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.08; }
.card h2 { font-size: 24px; }
.card h3 { font-size: 18px; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--gold); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.full { grid-column: 1 / -1; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 17px;
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  color: var(--text);
  background: linear-gradient(180deg, #26324a, #192235);
  cursor: pointer;
  font-weight: 750;
  transition: transform .14s ease, border-color .14s ease, filter .14s ease;
}
.button:hover { border-color: #7585a4; filter: brightness(1.08); }
.button:active { transform: translateY(1px) scale(.985); }
.button:disabled { opacity: .42; cursor: not-allowed; filter: none; }
.button.primary { color: #141007; border-color: #e4bd70; background: linear-gradient(180deg, #f0ce87, #bd8d3e); }
.button.power { border-color: #9a82ef; background: linear-gradient(180deg, #6551a8, #3d3173); }
.button.danger { border-color: #a94d60; background: linear-gradient(180deg, #89384b, #572331); }
.button.ghost { background: transparent; }
.button.small { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.button.large { min-height: 52px; padding: 14px 24px; font-size: 17px; }
.action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #0d121f;
}
input:focus, select:focus, textarea:focus { border-color: #7a89a8; box-shadow: 0 0 0 3px rgba(93, 174, 230, .1); }
textarea { resize: vertical; }
fieldset { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; }
legend { padding: 0 8px; color: var(--gold); font-family: Georgia, serif; font-size: 18px; }
.stack-form { display: grid; gap: 15px; }

.flash-stack { position: fixed; top: 82px; left: 50%; z-index: 90; width: min(560px, calc(100% - 30px)); transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.flash { padding: 12px 15px; border-radius: 10px; border: 1px solid var(--line); background: #20283a; box-shadow: var(--shadow); }
.flash.error { border-color: #9d4659; color: #ffd4dd; background: #3c1c27; }
.flash.success { border-color: #3d956c; color: #d6ffeb; background: #173c2c; }

.hero-landing { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); gap: 30px; align-items: center; min-height: 560px; }
.hero-copy h1 { max-width: 840px; margin: 0 0 22px; font: 700 clamp(40px, 6vw, 76px)/.98 Georgia, serif; letter-spacing: -.035em; }
.hero-copy > p { max-width: 760px; color: #b8c0cf; font-size: 18px; }
.hero-copy .action-row { margin: 28px 0; }
.feature-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.feature-pills span { padding: 7px 11px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); background: rgba(19, 24, 39, .65); font-size: 12px; }
.hero-art { overflow: hidden; position: relative; min-height: 510px; }
.hero-art > img { width: 100%; height: 510px; object-fit: cover; filter: saturate(.85) brightness(.78); }
.hero-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(4, 5, 9, .95)); pointer-events: none; }
.hero-art-caption { position: absolute; z-index: 2; left: 24px; right: 24px; bottom: 22px; display: grid; }
.hero-art-caption b { font: 700 25px Georgia, serif; }
.hero-art-caption span { color: var(--muted); }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature-grid .card { padding: 22px; }
.feature-grid p { color: var(--muted); }

.auth-card { width: min(480px, 100%); margin: 70px auto; padding: 30px; }
.auth-card h1 { margin-bottom: 26px; }
.auth-card .muted { margin: 18px 0 0; }
.error-card { text-align: center; }
.error-code { display: block; color: var(--gold); font: 800 70px Georgia, serif; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.two-column > .card { padding: 24px; }
.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid rgba(70, 83, 112, .35); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; text-align: right; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading.compact { margin-bottom: 16px; }
.section-heading h1, .section-heading h2 { margin: 0; }
.section-heading p { max-width: 750px; margin: 8px 0 0; color: var(--muted); }
.section-heading > img { border-radius: 14px; border: 1px solid var(--line); object-fit: cover; }

.table-wrap { overflow: auto; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid rgba(70, 83, 112, .4); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #111725; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:hover { background: rgba(93, 174, 230, .045); }
.empty-cell { padding: 35px; text-align: center; color: var(--muted); }
.table-sub { display: block; color: var(--soft); }
.badge, .severity, .job-status { display: inline-flex; padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.badge.success, .severity.info, .job-status.installed { color: #bdf6d7; border-color: #367b5a; background: #173627; }
.badge.warning, .severity.warning, .job-status.processing, .job-status.submitting { color: #ffe4a6; border-color: #846024; background: #3b2d15; }
.badge.danger, .severity.critical, .job-status.failed { color: #ffd1da; border-color: #914356; background: #3b1c25; }

.character-builder { padding: 28px; }
.character-builder .section-heading > img { width: 150px; height: 188px; object-fit: cover; }
.builder-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.choice-card { position: relative; display: block; margin-bottom: 9px; cursor: pointer; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card span { display: grid; gap: 4px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #111827; transition: .15s ease; }
.choice-card small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.choice-card em { color: var(--gold); font-size: 11px; font-style: normal; }
.choice-card input:checked + span { border-color: var(--gold); background: rgba(156, 113, 49, .16); box-shadow: 0 0 0 2px rgba(226, 189, 112, .08); }
.portrait-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.portrait-options label { cursor: pointer; }
.portrait-options input { position: absolute; opacity: 0; }
.portrait-options img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border: 2px solid var(--line); border-radius: 12px; }
.portrait-options input:checked + img { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 189, 112, .16); }

/* Game */
.game-app { display: grid; gap: 12px; }
.game-top { display: flex; align-items: center; gap: 24px; padding: 12px 16px; }
.hero-mini { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.hero-mini img { width: 58px; height: 70px; object-fit: cover; border: 1px solid var(--line-bright); border-radius: 11px; }
.hero-mini div { display: grid; }
.hero-mini strong { font: 700 20px Georgia, serif; }
.hero-mini span { color: var(--muted); font-size: 12px; }
.game-bars { flex: 1; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: auto minmax(140px, 1fr) auto; align-items: center; gap: 10px; }
.bar-row small { color: var(--muted); }
.resource-row { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.resource-row b { color: var(--gold); }
.meter { position: relative; height: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 99px; background: #080b12; }
.meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4c83c4, #78c4f1); transition: width .24s ease; }
.meter.health i { background: linear-gradient(90deg, #27865e, #66d89e); }
.meter.danger i { background: linear-gradient(90deg, #813549, #e26479); }
.meter.energy i { background: linear-gradient(90deg, #5540a7, #a78bfa); }
.game-tabs { display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: #0e1421; }
.game-tabs button { min-height: 48px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; font-weight: 750; }
.game-tabs button:last-child { border-right: 0; }
.game-tabs button.active { color: #171008; background: linear-gradient(180deg, #ebca83, #ba8839); }
.game-panel { display: none; }
.game-panel.active { display: block; }
.adventure-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); gap: 12px; }
.location-card { position: relative; overflow: hidden; min-height: 680px; }
.location-card > img { width: 100%; height: 680px; object-fit: cover; filter: brightness(.72) saturate(.82); }
.location-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(2,3,8,.05) 30%, rgba(3,4,8,.94) 88%); pointer-events: none; }
.location-overlay { position: absolute; z-index: 2; left: 28px; right: 28px; bottom: 78px; }
.location-overlay span { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.location-overlay h1 { margin: 8px 0 7px; font: 700 clamp(32px, 5vw, 58px)/1 Georgia, serif; }
.location-overlay p { max-width: 700px; margin: 0; color: #c0c7d3; }
.location-picker { position: absolute; z-index: 3; left: 28px; bottom: 20px; width: min(430px, calc(100% - 56px)); }
.location-picker select { padding: 8px 10px; }
.battle-card { padding: 20px; min-height: 680px; display: flex; flex-direction: column; }
.battle-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.battle-heading h2 { margin: 2px 0; }
.battle-heading small { color: var(--muted); }
.power-badge { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: #111725; font-size: 11px; }
.power-badge b { color: var(--gold); }
.power-badge.large { padding: 10px 14px; font-size: 14px; }
.enemy-image { width: min(300px, 70%); aspect-ratio: 1; margin: 18px auto; object-fit: cover; border: 1px solid var(--line); border-radius: 18px; background: #0a0e18; }
.combat-meter { display: grid; gap: 5px; margin-top: 10px; }
.combat-meter > div:first-child { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.battle-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 18px; }
.switch-line { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-weight: 400; }
.switch-line input { width: 18px; height: 18px; accent-color: var(--gold); }
.battle-log { flex: 1; min-height: 105px; max-height: 150px; overflow: auto; margin-top: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #0b0f19; }
.battle-log p { margin: 3px 0; color: var(--muted); font-size: 12px; }
.battle-log p.good { color: #9fe4bf; }
.battle-log p.bad { color: #f4a2b1; }
.battle-log p.special { color: #ddc4ff; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dashboard-grid > .card { padding: 22px; }
.dashboard-grid .span-two { grid-column: 1 / -1; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat-grid > div, .resource-admin-grid > div { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #101624; }
.stat-grid span, .resource-admin-grid span { display: block; color: var(--muted); font-size: 11px; }
.stat-grid b, .resource-admin-grid b { font-size: 19px; }
.equipment-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.equipment-slot { min-height: 150px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #0f1522; }
.equipment-slot img { width: 54px; height: 54px; object-fit: cover; border-radius: 9px; }
.equipment-slot b { display: block; margin: 8px 0 3px; }
.equipment-slot small { color: var(--muted); }
.location-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.location-chip { padding: 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #101624; cursor: pointer; }
.location-chip.active { color: #fff; border-color: var(--gold); }
.location-chip.locked { opacity: .35; cursor: not-allowed; }
.inventory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.inventory-item { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; background: #0f1522; }
.inventory-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.inventory-item h3 { margin: 0; font: 700 15px/1.25 Georgia, serif; }
.inventory-item p { margin: 4px 0; color: var(--muted); font-size: 11px; }
.inventory-item .item-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; }
.rarity-common { border-left-color: #aeb7c2; }.rarity-uncommon { border-left-color: #59d98e; }.rarity-rare { border-left-color: #5aa7ff; }.rarity-epic { border-left-color: #b77cff; }.rarity-legendary { border-left-color: #ffbf5e; box-shadow: inset 0 0 25px rgba(255,191,94,.08); }
.skill-tree { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.skill-node { display: flex; flex-direction: column; min-height: 190px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #101624; }
.skill-node.available { border-color: #7d6bc2; box-shadow: 0 0 25px rgba(145,121,230,.1); }
.skill-node.maxed { border-color: var(--gold-2); background: rgba(94,68,29,.18); }
.skill-node h3 { margin: 0 0 8px; font-size: 17px; }
.skill-node p { flex: 1; color: var(--muted); font-size: 12px; }
.skill-node small { color: var(--soft); }
.skill-node .button { margin-top: 10px; }
.quest-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quest-card { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #101624; }
.quest-card header { display: flex; justify-content: space-between; gap: 10px; }
.quest-card p { color: var(--muted); }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: #070a11; }
.progress-track i { display: block; height: 100%; background: linear-gradient(90deg, #7d6534, #e2bd70); }
.expedition-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.expedition-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #101624; }
.story-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.story-entry { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #101624; cursor: pointer; }
.story-entry.seen { opacity: .7; }
.story-entry b { display: block; }
.story-entry small { color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(2,3,7,.86); backdrop-filter: blur(12px); }
.story-modal { position: relative; width: min(720px, 100%); padding: 32px; border-color: #725f3b; }
.story-modal h2 { margin-bottom: 12px; }
.story-modal .speaker { display: inline-flex; padding: 5px 9px; border: 1px solid var(--gold-2); border-radius: 99px; color: var(--gold); font-weight: 800; }
.story-modal p { font: 18px/1.8 Georgia, serif; white-space: pre-line; }
.modal-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #111725; cursor: pointer; font-size: 25px; }
.toast { position: fixed; z-index: 120; left: 50%; bottom: 24px; max-width: min(620px, calc(100% - 28px)); padding: 12px 16px; border: 1px solid var(--line); border-radius: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); background: #1b2435; box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #9d4659; background: #3c1c27; }
.loading-cover { position: fixed; inset: 0; z-index: 95; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(5,7,12,.82); backdrop-filter: blur(8px); }
.loading-cover.hidden { display: none; }
.spinner { width: 42px; height: 42px; border: 3px solid #27334a; border-top-color: var(--gold); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.admin-sidebar { position: sticky; top: 92px; padding: 14px; }
.admin-mark { display: flex; align-items: center; gap: 11px; padding: 8px; margin-bottom: 14px; }
.admin-mark img { border-radius: 11px; border: 1px solid var(--line); }
.admin-mark div { display: grid; }
.admin-mark small { color: var(--muted); }
.admin-sidebar nav { display: grid; gap: 5px; }
.admin-sidebar nav a { padding: 11px 12px; border-radius: 9px; color: var(--muted); }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { color: #fff; background: #222c42; }
.admin-content { min-width: 0; }
.status-dot { display: inline-flex; align-items: center; gap: 8px; color: #bdf6d7; }
.status-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px var(--green); }
.admin-stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.admin-stat-grid article { padding: 16px; }
.admin-stat-grid span { display: block; color: var(--muted); font-size: 11px; }
.admin-stat-grid b { display: block; margin-top: 5px; font-size: 26px; }
.compact-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.admin-columns { margin-bottom: 16px; }
.compact-list { display: grid; }
.compact-list > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid rgba(70,83,112,.35); }
.compact-list small { color: var(--soft); }
.filter-bar { display: flex; align-items: end; gap: 12px; padding: 14px; margin-bottom: 12px; }
.filter-bar label { flex: 1; }
.back-link { display: inline-block; margin-bottom: 10px; color: var(--muted); }
.resource-admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.image-admin-layout { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 16px; }
.generator-panel { position: sticky; top: 92px; padding: 18px; display: grid; gap: 13px; max-height: calc(100vh - 112px); overflow: auto; }
.selected-asset { display: flex; align-items: center; gap: 11px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: #0f1522; }
.selected-asset img { width: 76px; height: 76px; object-fit: cover; border-radius: 9px; }
.selected-asset div { display: grid; min-width: 0; }
.selected-asset small { color: var(--soft); overflow-wrap: anywhere; }
.asset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.asset-card { padding: 10px; display: grid; gap: 9px; }
.asset-card > img { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--line); border-radius: 10px; background: #0a0e17; }
.asset-card div { display: grid; gap: 3px; }
.asset-card b { line-height: 1.25; }
.asset-card small { color: var(--muted); }
.asset-card.generated { border-color: #386e55; }
.api-result { padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #0c111c; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.log-table code { display: block; max-width: 440px; max-height: 100px; overflow: auto; }

@media (max-width: 1180px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .builder-grid { grid-template-columns: repeat(2, 1fr); }
  .adventure-grid { grid-template-columns: 1fr; }
  .location-card, .location-card > img { min-height: 520px; height: 520px; }
  .battle-card { min-height: auto; }
  .admin-stat-grid { grid-template-columns: repeat(3, 1fr); }
  .asset-grid { grid-template-columns: repeat(2, 1fr); }
  .inventory-grid { grid-template-columns: repeat(2, 1fr); }
  .skill-tree { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .site-header { position: relative; align-items: flex-start; flex-direction: column; gap: 8px; padding: 10px 16px; }
  .site-nav { width: 100%; justify-content: flex-start; gap: 12px; overflow-x: auto; flex-wrap: nowrap; }
  .site-nav > * { white-space: nowrap; }
  .hero-landing { grid-template-columns: 1fr; min-height: auto; }
  .hero-copy h1 { font-size: 47px; }
  .hero-art, .hero-art > img { min-height: 390px; height: 390px; }
  .two-column, .dashboard-grid { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .game-top { align-items: flex-start; flex-direction: column; }
  .game-bars { width: 100%; }
  .game-tabs { display: flex; overflow-x: auto; }
  .game-tabs button { min-width: 130px; border-bottom: 0; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .admin-sidebar nav { grid-template-columns: repeat(4, 1fr); }
  .image-admin-layout { grid-template-columns: 1fr; }
  .generator-panel { position: static; max-height: none; }
  .skill-tree { grid-template-columns: repeat(2, 1fr); }
  .admin-stat-grid, .compact-stats { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { align-items: stretch; flex-direction: column; }
}

@media (max-width: 560px) {
  .page-shell, .wide-shell, .game-shell, .admin-shell { width: min(100% - 16px, 100%); margin-top: 12px; }
  .brand { min-width: 0; }
  .brand small { display: none; }
  .hero-copy h1 { font-size: 38px; }
  .feature-grid { grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; }
  .character-builder, .auth-card { padding: 20px; }
  .section-heading { align-items: flex-start; }
  .location-card, .location-card > img { min-height: 430px; height: 430px; }
  .location-overlay { left: 18px; right: 18px; bottom: 88px; }
  .location-picker { left: 18px; width: calc(100% - 36px); }
  .battle-card { padding: 15px; }
  .battle-actions { grid-template-columns: 1fr; }
  .inventory-grid, .equipment-grid, .location-grid, .quest-list, .story-list, .asset-grid, .skill-tree, .expedition-options { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-sidebar nav { grid-template-columns: repeat(2, 1fr); }
  .admin-stat-grid, .compact-stats { grid-template-columns: 1fr 1fr; }
  .resource-row { gap: 8px 13px; }
  .bar-row { grid-template-columns: auto 1fr; }
  .bar-row small { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
.loading-cover .loading-hint { max-width: min(620px, calc(100vw - 36px)); color: var(--muted); text-align: center; line-height: 1.55; }
.loading-cover .button { min-width: 210px; }

/* Expanded RPG systems */
.expanded-tabs { display: flex; overflow-x: auto; scrollbar-width: thin; position: sticky; top: 76px; z-index: 30; }
.expanded-tabs button { min-width: 148px; flex: 0 0 auto; border-right: 1px solid var(--line); white-space: nowrap; }
.compact-stats { display: grid; gap: 8px; margin-bottom: 12px; }
.statline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid rgba(70,83,112,.48); border-radius: 9px; background: #0e1421; }
.statline span { color: var(--muted); }
.inline-actions, .batch-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.social-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.social-card-grid > .card { padding: 14px; }
.social-avatar { width: 84px; height: 104px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.opponent-card { display: grid; align-content: start; gap: 8px; }
.opponent-card h3, .pet-card h3, .mine-card h3, .forge-slot-card h3 { margin: 0; }
.ranking-list { display: grid; gap: 6px; }
.ranking-entry { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 11px; border: 1px solid rgba(70,83,112,.5); border-radius: 9px; background: #0e1421; color: var(--text); text-align: left; }
.ranking-entry small { color: var(--muted); text-align: right; }
button.ranking-entry { cursor: pointer; }
.social-log { max-height: 260px; overflow: auto; }
.world-boss-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font: 700 19px Georgia,serif; }
.world-boss-icon { width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 15px; background: #111827; font-size: 42px; }
.item-icon { background: #090d16; }
.item-info { min-width: 0; }
.item-meta, .item-affixes { overflow-wrap: anywhere; }
.inventory-item { border-color: color-mix(in srgb, var(--rarity-color, var(--line)) 62%, var(--line)); box-shadow: inset 0 0 18px color-mix(in srgb, var(--rarity-color, transparent) 10%, transparent); }
.inventory-item.merge-selected { outline: 2px solid var(--gold); transform: translateY(-1px); }
.equipment-slot { padding: 0; min-height: 0; overflow: hidden; }
.equipment-slot .inventory-item { border: 0; border-radius: 0; min-height: 100%; }
.forge-slot-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.forge-slot-card { padding: 15px; }
.forge-controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 7px; margin-top: 12px; }
.mine-card { display: grid; gap: 9px; }
.mine-icon, .pet-emoji { font-size: 42px; }
.pet-card { display: grid; align-content: start; gap: 8px; }
.pet-card.active { border-color: var(--gold); box-shadow: 0 0 24px rgba(226,189,112,.14); }
.pet-active { padding: 12px; border: 1px solid var(--gold-2); border-radius: 10px; background: rgba(94,68,29,.18); font-weight: 750; }
.story-card { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #101624; color: var(--text); text-align: left; cursor: pointer; }
.story-card:hover { border-color: var(--line-bright); }
.chat-card { padding: 17px; }
.chat-messages { height: min(52vh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: #080d16; }
.chat-line { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: start; padding: 8px 10px; border-radius: 9px; background: #141c2c; }
.chat-line b { color: var(--gold); }
.chat-line small { color: var(--soft); font-size: 10px; }
.chat-compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
#chatPlayerChooser { margin-bottom: 10px; }
.guild-head { display: flex; align-items: center; gap: 13px; margin-bottom: 12px; font: 700 21px Georgia,serif; }
.guild-avatar { width: 92px; height: 92px; object-fit: cover; border-radius: 15px; border: 1px solid var(--line-bright); }
.guild-controls, .guild-create, .guild-avatar-form { display: grid; gap: 9px; margin: 12px 0; }
.guild-skill-tree { margin-bottom: 16px; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Batch image generation */
.image-summary-grid { margin-bottom: 14px; }
.stat-card.compact { padding: 14px; display: grid; gap: 3px; }
.batch-generator-card { padding: 18px; margin-bottom: 14px; }
.batch-control-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-bottom: 11px; }
.large-preview { align-items: flex-start; }
.large-preview img { width: 138px; height: 138px; }
.quick-category-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.asset-card.selected { outline: 2px solid var(--blue); box-shadow: 0 0 0 3px rgba(93,174,230,.1); }
.batch-asset-list { display: block; max-width: 310px; max-height: 68px; overflow: auto; color: var(--muted); }

@media (max-width: 1180px) {
  .social-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .batch-control-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .game-shell { width: min(100% - 12px, 560px); margin-top: 8px; }
  .game-body .site-header { display: none; }
  .expanded-tabs { top: 0; border-radius: 10px; }
  .expanded-tabs button { min-width: 132px; min-height: 44px; font-size: 12px; }
  .social-card-grid, .forge-slot-grid { grid-template-columns: 1fr; }
  .forge-controls { grid-template-columns: 1fr; }
  .chat-line { grid-template-columns: 1fr; gap: 2px; }
  .chat-line small, .ranking-entry small { text-align: left; }
  .chat-compose { grid-template-columns: 1fr; }
  .batch-control-grid { grid-template-columns: 1fr; }
  .large-preview img { width: 104px; height: 104px; }
}
@media (max-width: 480px) {
  .game-shell { width: 100%; margin: 0; }
  .game-app { gap: 7px; }
  .game-top { border-radius: 0; position: sticky; top: 0; z-index: 40; padding: 8px 10px; }
  .hero-mini img { width: 45px; height: 54px; }
  .game-panel > .card, .game-panel .card { border-radius: 12px; }
  .resource-row { font-size: 10px; }
  .inventory-item { grid-template-columns: 56px 1fr; padding: 9px; }
  .inventory-item img { width: 56px; height: 56px; }
  .item-actions .button { flex: 1 1 44%; }
  .section-heading { flex-direction: column; gap: 8px; }
  .social-avatar { width: 72px; height: 90px; }
}

/* Expanded equipment and pet UI */
.inventory-toolbar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.inventory-toolbar label { min-width: 190px; }
.item-power-up { color: #8ff0b3 !important; font-weight: 800; }
.item-power-neutral { color: var(--soft) !important; }
.live-countdown { color: var(--gold); font-variant-numeric: tabular-nums; }
.pet-portrait { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: #0b111c; }
.pet-portrait.active { width: 112px; flex: 0 0 112px; }
.pet-active-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pet-active-detail > div { font: 700 17px/1.25 Georgia, serif; }
.pet-active-detail > p { flex: 1 1 240px; margin: 0; }
.pet-special { padding: 8px; border-left: 3px solid var(--gold); background: rgba(226,189,112,.06); border-radius: 0 8px 8px 0; }
.pet-level { font-weight: 800; margin: 0; }
.pet-expedition-portrait { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; float: left; margin: 0 12px 10px 0; }
.forge-slot-card select { min-width: 0; width: 100%; }

@media (max-width: 560px) {
  .inventory-toolbar { width: 100%; justify-content: stretch; }
  .inventory-toolbar label, .inventory-toolbar button { width: 100%; }
  .pet-portrait.active { width: 88px; flex-basis: 88px; }
}
