:root {
  color-scheme: dark;
  --surface: #211e1a;
  --surface-raised: #2b2722;
  --line: #433b32;
  --accent: #ddad7c;
  --text: #f3ece3;
  --muted: #bcb0a1;
  --water: #a4cdc6;
  --danger: #f4aaa1;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
html, body { min-height: 100%; }
body {
  background: radial-gradient(ellipse at 45% 42%, #2b2118, #17130f 66%);
  color: var(--text);
  font: 14px/1.5 'Segoe UI', sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .5; }
button, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
::selection { background: #ddad7c; color: #17130f; }
* { scrollbar-width: thin; scrollbar-color: #706151 var(--surface); }
h2, h3, h4, p { margin: 0; }
h2 { font-size: 18px; font-weight: 600; }
h3, h4 { font-size: 14px; font-weight: 600; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }

#app-shell {
  width: 100%;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  gap: 12px;
}
.top-nav-wrap { width: 100%; max-width: 1760px; }
.top-pill-bar { display: flex; align-items: center; gap: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.brand-badge { margin-right: auto; color: var(--accent); font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.nav-actions { display: flex; gap: 8px; }
.nav-pill-btn { color: var(--muted); background: transparent; border: 0; padding: 8px 12px; border-radius: 8px; min-height: 40px; }
.nav-pill-btn:hover { color: var(--text); background: var(--surface-raised); }
.nav-pill-btn.active { color: var(--text); background: var(--surface-raised); }
.guide-count { margin-left: 4px; font-size: 12px; color: var(--muted); }
.guide-count:empty, .guide-count[data-empty="true"] { display: none; }
.balance { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.telemetry-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 16px; font-size: 12px; }
.telemetry-box { display: flex; gap: 24px; }
.stat-metric { display: grid; grid-template-columns: auto auto; column-gap: 8px; row-gap: 5px; font-variant-numeric: tabular-nums; }
.stat-label, .tank-summary { color: var(--muted); }
#clock-pill { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mini-progress { grid-column: 1 / -1; height: 2px; background: var(--line); overflow: hidden; }
.mini-progress-fill { height: 100%; background: var(--water); }
#stat-hunger-bar { background: var(--accent); }

.aquarium-stage { width: 100%; max-width: 1760px; flex: 1; display: flex; align-items: center; justify-content: center; gap: 24px; padding: 8px; }
.tank-center-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.lamp-hood { width: 68%; height: 12px; margin-bottom: 7px; border-radius: 10px 10px 3px 3px; background: linear-gradient(#3d342b, #1b1712); position: relative; }
.lamp-hood::after { content: ''; position: absolute; left: 8%; right: 8%; bottom: -1px; height: 3px; border-radius: 4px; background: #eee7d1; box-shadow: 0 8px 22px 5px rgb(233 222 185 / 20%); }
.lamp-hood.marine-glow::after { background: #c2e5ea; box-shadow: 0 8px 22px 5px rgb(172 219 232 / 23%); }
#tank-glass-box { width: 100%; height: clamp(320px, calc(100svh - 240px), 900px); position: relative; overflow: hidden; border-radius: 12px 12px 3px 3px; border: 4px solid #8badaf; border-bottom-color: #4d6262; background: #103c50; box-shadow: 0 28px 50px rgb(0 0 0 / 35%); }
#aquarium-canvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: manipulation; }
.wood-stand { width: calc(100% + 20px); height: 18px; border-radius: 3px 3px 9px 9px; background: linear-gradient(#a77950, #6a4428); box-shadow: 0 20px 30px rgb(0 0 0 / 30%); }
.floating-fish-card { width: 208px; flex-shrink: 0; display: flex; flex-direction: column; gap: 20px; }
.ffc-header { display: flex; align-items: center; gap: 12px; }
.ffc-photo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface); flex-shrink: 0; }
.ffc-photo-button { flex-shrink: 0; border: 0; padding: 0; border-radius: 8px; background: none; }
.ffc-photo-button .ffc-photo { width: 68px; height: 56px; object-fit: contain; border-radius: 8px; }
.ffc-title-wrap { min-width: 0; flex: 1; }
.ffc-name { font-size: 14px; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.ffc-sub { font-size: 12px; color: var(--muted); }
.ffc-close { width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 22px; }
.ffc-close:hover { color: var(--text); background: var(--surface-raised); }
.fish-vitals { display: flex; gap: 20px; font-size: 12px; }
.fish-vitals span { color: var(--muted); }
.fish-vitals strong { display: block; color: var(--text); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ffc-diag-box { font-size: 12px; line-height: 1.5; }
.ffc-diag-ok { color: var(--water); }
.ffc-diag-warn { color: var(--danger); }
details summary { cursor: pointer; color: var(--muted); padding: 8px 0; font-size: 12px; }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 8px; }
.care-specs { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 12px; }
.care-specs dt { color: var(--muted); }
.care-specs dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.care-specs dd:last-child { text-align: left; grid-column: 1 / -1; }
.science-name { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

.bottom-dock-wrap { width: 100%; max-width: 1760px; display: flex; justify-content: center; padding-bottom: 4px; }
.bottom-dock-wrap { flex-wrap: wrap; gap: 8px; }
.asset-status { width: 100%; text-align: center; color: var(--muted); font-size: 12px; }
.asset-status button { margin-left: 12px; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
.dock-buttons { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; }
.empty-inventory { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }
.dock-item { min-height: 44px; color: var(--muted); background: var(--surface); border: 1px solid transparent; border-radius: 8px; padding: 8px 12px; display: inline-flex; align-items: center; gap: 8px; }
.dock-item:hover { background: var(--surface-raised); color: var(--text); }
.dock-item.active { border-color: var(--accent); color: var(--text); }
.dock-count { color: var(--accent); font-variant-numeric: tabular-nums; }
.feeding-hint { width: 100%; text-align: center; color: var(--muted); font-size: 12px; margin-top: 4px; }
#alert-banner { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
#alert-banner:empty { display: none; }
.alert-item { color: var(--danger); font-size: 12px; }
#notice-banner { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(600px, calc(100% - 32px)); pointer-events: none; z-index: 120; }
.notice { background: var(--surface-raised); color: var(--text); padding: 12px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 30%); font-size: 12px; }

.engineering-drawer { display: none; position: fixed; right: 20px; top: 20px; bottom: 20px; width: 340px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: 12px; z-index: 100; box-shadow: 0 20px 80px rgb(0 0 0 / 55%); flex-direction: column; }
.engineering-drawer.open { display: flex; }
body.panel-open::before { content: ''; position: fixed; inset: 0; z-index: 90; background: rgb(0 0 0 / 45%); }
.eng-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.settings-body { display: flex; flex-direction: column; gap: 24px; overflow-y: auto; padding: 24px 20px; }
.control-row { display: flex; flex-direction: column; gap: 12px; }
.control-label { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.control-val { color: var(--text); font-variant-numeric: tabular-nums; }
.toggle-group { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-btn { flex: 1; color: var(--muted); min-height: 40px; padding: 8px; background: var(--surface-raised); border: 1px solid transparent; border-radius: 8px; font-size: 12px; }
.mini-btn:hover { color: var(--text); }
.mini-btn.active { border-color: var(--accent); color: var(--text); }
input[type="range"] { width: 100%; margin: 0; height: 24px; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.water-readings { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.water-readings strong { display: block; font-weight: 500; color: var(--text); }
.settings-details { border-top: 1px solid var(--line); padding-top: 8px; }
.settings-details .toggle-group { margin: 8px 0 16px; }
.settings-details > span { font-size: 12px; }

.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; background: rgb(0 0 0 / 60%); padding: 24px; }
.modal-backdrop.open { display: flex; }
.modal-box { width: 100%; max-width: 960px; max-height: 86svh; background: var(--surface); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgb(0 0 0 / 40%); }
.modal-header { padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.modal-header-actions { display: flex; align-items: center; gap: 16px; }
.modal-header-actions .balance { order: 0; }
.shop-tabs { display: flex; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.shop-tabs .nav-pill-btn { border-radius: 0; padding: 14px 0; border-bottom: 2px solid transparent; }
.shop-tabs .nav-pill-btn.active { background: transparent; color: var(--accent); border-bottom-color: var(--accent); }
.catalog-tools { display: flex; align-items: center; gap: 12px; padding: 16px 24px 0; }
.catalog-tools input, .catalog-tools select { background: #171612; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 10px 12px; min-width: 0; min-height: 44px; }
.catalog-tools input { flex: 1; }
.catalog-tools input::placeholder { color: var(--muted); }
.catalog-tools select { max-width: 180px; }
#catalog-count { white-space: nowrap; font-size: 12px; }
.modal-body { padding: 24px; overflow-y: auto; overscroll-behavior: contain; }
.supply-list { display: flex; flex-direction: column; }
.supply-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.supply-row:first-child { padding-top: 0; }
.supply-row:last-child { border-bottom: 0; padding-bottom: 0; }
.supply-info { min-width: 0; }
.supply-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.supply-info details { max-width: 55ch; }
.supply-info details p { font-size: 12px; color: var(--muted); }
.supply-actions { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 32px 24px; }
.species-card { display: flex; flex-direction: column; min-width: 0; gap: 16px; }
.species-photo-banner { display: block; width: 100%; padding: 0; border: 0; aspect-ratio: 4 / 3; background: #151612; border-radius: 8px; overflow: hidden; position: relative; }
.species-photo-banner img { width: 100%; height: 100%; object-fit: contain; }
.photo-expand { position: absolute; right: 8px; bottom: 8px; background: rgb(0 0 0 / 75%); color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 4px; opacity: 0; }
.species-photo-banner:hover .photo-expand, .species-photo-banner:focus-visible .photo-expand { opacity: 1; }
.photo-viewer { max-width: 1100px; }
.photo-viewer .modal-body { padding: 16px; }
#photo-full { width: 100%; margin: auto; max-height: 66svh; object-fit: contain; background: #11130f; }
.photo-credit { font-size: 12px; color: var(--muted); margin-top: 12px; overflow-wrap: anywhere; }
.photo-credit a { color: var(--muted); text-underline-offset: 3px; }
.species-card-body { display: flex; flex-direction: column; gap: 8px; }
.species-card-body .care-specs { padding: 8px 0; }
.species-card-body .guide-option { margin: 12px 0; }
.species-description { font-size: 12px; color: var(--muted); }
.species-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.species-heading h4 { overflow-wrap: anywhere; }
.species-price { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.species-card-footer { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.purchase-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.guide-option { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; }
.btn-buy, .btn-buy-secondary { min-height: 40px; padding: 8px 12px; border-radius: 8px; font-size: 12px; }
.btn-buy { background: var(--accent); color: #24180c; border: 0; font-weight: 600; }
.btn-buy:hover { background: #eabd90; }
.btn-buy-secondary { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-buy-secondary:hover { background: var(--surface-raised); }
.purchase-actions .btn-buy { flex: 1; }
.empty-guides { padding: 32px 0; display: flex; align-items: flex-start; flex-direction: column; gap: 16px; color: var(--muted); }
.guide-count-label { color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.guide-risks { color: var(--danger); font-size: 12px; padding-top: 16px; }
.care-guide section { margin-top: 16px; }
.care-guide h4 { font-size: 12px; margin-bottom: 4px; }
.care-guide p, .care-sources { font-size: 12px; color: var(--muted); line-height: 1.6; }
.care-sources { margin-top: 16px; }
.care-sources a { color: inherit; text-underline-offset: 3px; }

body.mobile-mode #app-shell { max-width: 430px; margin: 0 auto; }
@media (min-width: 761px) and (max-width: 1100px) {
  .aquarium-stage { flex-direction: column; gap: 24px; }
  .tank-center-col { width: 100%; flex: none; }
  #tank-glass-box { height: clamp(360px, calc(100svh - 300px), 720px); }
  .floating-fish-card { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 16px 24px; }
  .ffc-header { flex: 1 1 300px; }
}
@media (max-width: 760px) {
  #app-shell { padding: 12px; gap: 16px; }
  .top-pill-bar { gap: 12px; flex-wrap: wrap; }
  .brand-badge { flex: 1; }
  .balance { order: 1; }
  .nav-actions { order: 2; width: 100%; justify-content: flex-start; gap: 8px; }
  .nav-pill-btn { padding: 8px 12px; }
  .telemetry-row { align-items: flex-start; flex-direction: column; gap: 12px; }
  .telemetry-box { width: 100%; justify-content: space-between; gap: 16px; }
  .tank-summary { font-size: 12px; }
  .aquarium-stage { flex-direction: column; gap: 24px; padding: 0 4px; }
  .tank-center-col { width: 100%; flex: none; }
  #tank-glass-box { height: clamp(340px, 52svh, 560px); }
  .floating-fish-card { width: 100%; max-width: 420px; gap: 16px; }
  .ffc-header { width: 100%; }
  .ffc-name { font-size: 14px; }
  .fish-vitals { gap: 32px; }
  .modal-backdrop { padding: 12px; }
  .modal-box { max-height: calc(100svh - 24px); }
  .modal-header, .modal-body { padding: 16px; }
  .shop-tabs { padding: 0 16px; gap: 24px; }
  .catalog-tools { padding: 16px 16px 0; flex-wrap: wrap; gap: 8px; }
  .catalog-tools input { flex-basis: 100%; }
  .catalog-tools select { flex: 1; max-width: none; }
  .photo-expand { opacity: 1; }
  .supply-row { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
  .supply-info { flex: 1 1 180px; }
  .supply-actions { gap: 12px; }
}
body.mobile-mode .aquarium-stage { flex-direction: column; }
body.mobile-mode .tank-center-col { width: 100%; flex: none; }
body.mobile-mode #tank-glass-box { height: 340px; }
body.mobile-mode .floating-fish-card { width: 100%; }
body.mobile-mode .telemetry-row { flex-direction: column; align-items: stretch; }
body.mobile-mode .top-pill-bar { flex-wrap: wrap; }
body.mobile-mode .nav-actions { order: 2; width: 100%; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

.settings-section { display: flex; flex-direction: column; gap: 20px; }
.settings-section h3 { color: var(--text); font-size: 14px; }
.settings-group { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; }
.settings-group > summary { font-size: 14px; color: var(--text); }
.settings-group[open] > .settings-section { padding-top: 12px; }
