:root {
  --bg0: #05060a;
  --bg1: #071126;
  --bg2: #0d1e3d;
  --frame: #1d2a4a;
  --frame-hi: #2d4a7a;
  --text: #d6e2ff;
  --muted: #89a0c7;
  --panel: rgba(7, 17, 38, 0.76);
  --panel-hi: rgba(16, 34, 71, 0.84);
  --line: rgba(168, 230, 255, 0.12);
  --glow: rgba(51, 106, 170, 0.26);
  --fish: #6ddc8f;
  --food: #ffe66d;
  --energy: #f08a4b;
  --danger: #d64545;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 70% 18%, rgba(18, 38, 79, 0.95) 0%, transparent 60%),
    radial-gradient(900px 600px at 14% 84%, rgba(14, 26, 51, 0.92) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg0));
  overflow-x: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 24px, 24px 100%;
  opacity: 0.22;
}

#wrap {
  min-height: 100vh;
  padding: 18px clamp(14px, 2vw, 28px) 24px;
  display: flex;
  justify-content: center;
}

#shell {
  width: min(1780px, 100%);
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "topbar"
    "tank-panel"
    "bottom-dock";
  align-items: stretch;
  gap: 16px;
}

.panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(23, 43, 79, 0.20), transparent 38%),
    linear-gradient(180deg, var(--panel-hi), var(--panel));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.38),
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 -1px 0 rgba(0, 0, 0, 0.25) inset;
  backdrop-filter: blur(14px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 26%, transparent 72%, rgba(255, 255, 255, 0.02));
}

.eyebrow,
.panel-kicker,
.metric-label {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.72rem;
  color: rgba(168, 230, 255, 0.76);
}

#topbar {
  grid-area: topbar;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(260px, 0.92fr) minmax(520px, 1.28fr);
  gap: 14px;
  align-items: center;
}

.title-block h1,
.panel-head h2,
.card-head h2 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.28rem, 2.1vw, 2.1rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: #fbfdff;
}

.lede,
.panel-head p,
.card-head p,
.card-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.lede {
  margin-top: 0.55rem;
  max-width: 44ch;
  font-size: 0.94rem;
  line-height: 1.45;
}

#status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-width: 0;
  min-height: 84px;
  padding: 11px 13px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    radial-gradient(circle at 100% 0%, rgba(109, 220, 143, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(9, 18, 38, 0.82), rgba(5, 10, 20, 0.62));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 0 0 1px rgba(7, 17, 38, 0.55) inset;
}

.metric-card strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(1.08rem, 1.55vw, 1.55rem);
  line-height: 1.05;
  color: #ffffff;
}

.metric-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.32;
  font-size: 0.84rem;
}

#tank-panel,
.dock-card {
  padding: 18px;
}

#tank-panel {
  grid-area: tank-panel;
  min-width: 0;
  display: grid;
  gap: 16px;
  align-self: start;
}

#control-panel,
#history-panel,
#insight-panel {
  grid-area: auto;
}

.panel-head,
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.compact-head h2 {
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
}

#top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.seed-actions {
  min-width: min(100%, 300px);
  display: flex;
  flex: 1 1 320px;
  justify-content: flex-end;
  align-items: stretch;
  gap: 10px;
}

#tank-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

#tank-observation {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(260px, 340px);
  gap: 10px;
  align-items: stretch;
}

.observation-pill {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(17, 31, 58, 0.72), rgba(6, 12, 23, 0.58));
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.observation-pill.compact {
  max-width: 280px;
}

.observation-pill.observation-wide {
  min-width: 0;
}

.music-pill {
  min-width: 0;
}

.music-controls {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.music-volume {
  min-width: 0;
  padding: 7px 10px;
  display: grid;
  gap: 5px;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 10px;
  background: rgba(7, 17, 38, 0.56);
}

.music-volume span {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.64rem;
  color: rgba(168, 230, 255, 0.72);
}

.music-volume input[type='range'] {
  height: 10px;
}

#music-toggle[data-state='active'] {
  border-color: rgba(109, 220, 143, 0.34);
  background:
    linear-gradient(180deg, rgba(34, 73, 53, 0.82), rgba(10, 32, 22, 0.96));
}

#music-toggle[data-state='loading'] {
  border-color: rgba(168, 230, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(53, 78, 110, 0.82), rgba(16, 29, 49, 0.96));
}

.chrome-button {
  appearance: none;
  border: 1px solid rgba(168, 230, 255, 0.18);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(42, 74, 122, 0.72), rgba(18, 34, 59, 0.96));
  font: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.chrome-button:hover,
.chrome-button:focus-visible {
  border-color: rgba(168, 230, 255, 0.32);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(109, 220, 143, 0.28);
  transform: translateY(-1px);
  outline: none;
}

.chrome-button:active {
  transform: translateY(0);
}

.chrome-button:disabled {
  opacity: 0.48;
  cursor: default;
  transform: none;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.chrome-button[data-state='paused'] {
  border-color: rgba(109, 220, 143, 0.38);
  background:
    linear-gradient(180deg, rgba(50, 95, 65, 0.78), rgba(18, 49, 33, 0.96));
}

.chrome-button[data-state='active'] {
  border-color: rgba(168, 230, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(66, 92, 128, 0.82), rgba(20, 38, 66, 0.96));
}

.chrome-button.chrome-subtle {
  padding: 9px 12px;
  background:
    linear-gradient(180deg, rgba(21, 35, 59, 0.86), rgba(8, 15, 28, 0.94));
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.seed-control {
  min-width: 138px;
  flex: 1 1 170px;
  max-width: 220px;
  padding: 8px 11px;
  display: grid;
  gap: 5px;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 12px;
  background: rgba(7, 17, 38, 0.72);
}

#apply-seed {
  flex: 0 0 auto;
  white-space: nowrap;
}

.seed-control span {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  color: rgba(168, 230, 255, 0.72);
}

.seed-control input {
  width: 100%;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 8px;
  padding: 7px 8px;
  color: #ffffff;
  background: rgba(4, 10, 21, 0.92);
  font: inherit;
}

.seed-control input:focus-visible {
  outline: 1px solid rgba(109, 220, 143, 0.46);
  outline-offset: 0;
}

.seed-control input::-webkit-outer-spin-button,
.seed-control input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.seed-control input[type='number'] {
  -moz-appearance: textfield;
}

#tank-stage {
  position: relative;
  min-height: clamp(600px, 78vh, 1120px);
  padding: 22px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% -12%, rgba(168, 230, 255, 0.10), transparent 42%),
    radial-gradient(circle at 14% 50%, rgba(109, 220, 143, 0.06), transparent 28%),
    radial-gradient(circle at 88% 50%, rgba(240, 138, 75, 0.05), transparent 30%),
    linear-gradient(180deg, rgba(7, 17, 38, 0.72), rgba(3, 7, 14, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(168, 230, 255, 0.06),
    inset 0 18px 36px rgba(109, 220, 143, 0.04),
    inset 0 -32px 46px rgba(0, 0, 0, 0.30);
}

#tank-replay-bar {
  margin: 0 0 14px;
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(12, 22, 44, 0.88), rgba(5, 10, 21, 0.76));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 20px 48px rgba(0, 0, 0, 0.18);
}

#tank-replay-bar #replay-note {
  margin: 0;
}

#tank-stage::before,
#tank-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#tank-stage::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 24px, 24px 100%;
  opacity: 0.18;
}

#tank-stage::after {
  background:
    radial-gradient(circle at 50% 110%, rgba(242, 209, 107, 0.10), transparent 38%),
    radial-gradient(circle at 0% 50%, rgba(168, 230, 255, 0.06), transparent 26%),
    radial-gradient(circle at 100% 50%, rgba(168, 230, 255, 0.06), transparent 26%);
}

#mobile-titlebar {
  display: none;
}

#mobile-titlebar strong {
  display: block;
  margin-top: 4px;
  font-size: 1.02rem;
  line-height: 1.05;
  color: #ffffff;
}


.overlay-chip {
  min-width: 0;
  max-width: none;
  padding: 10px 12px;
  border: 1px solid rgba(168, 230, 255, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(17, 31, 58, 0.88), rgba(6, 12, 23, 0.72));
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
}

.overlay-chip.compact {
  min-width: 0;
}

.overlay-label {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.66rem;
  color: rgba(168, 230, 255, 0.76);
}

.overlay-chip strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1rem, 1.3vw, 1.3rem);
  line-height: 1.05;
  color: #ffffff;
}

.overlay-chip small {
  display: block;
  margin-top: 7px;
  line-height: 1.4;
  color: var(--muted);
}

.observation-pill strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(0.98rem, 1.2vw, 1.18rem);
  line-height: 1.05;
  color: #ffffff;
}

.observation-pill small {
  display: block;
  margin-top: 5px;
  line-height: 1.35;
  color: var(--muted);
}

#game {
  display: block;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 12px;
  outline: 1px solid rgba(255, 255, 255, 0.08);
  background: #000;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(168, 230, 255, 0.06),
    0 0 50px rgba(51, 106, 170, 0.16);
}

#bottom-dock {
  grid-area: bottom-dock;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: stretch;
}

.dock-card {
  min-width: 0;
  display: grid;
  gap: 16px;
}

#history-panel {
  grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
  min-height: 0;
  align-content: stretch;
}

#shell[data-cinematic='true'] {
  grid-template-columns: 1fr !important;
  grid-template-areas: "tank-panel" !important;
}

#shell[data-cinematic='true'] #topbar,
#shell[data-cinematic='true'] #bottom-dock {
  display: none !important;
}

#shell[data-cinematic='true'] #tank-panel {
  min-height: calc(100vh - 36px);
}

#shell[data-cinematic='true'] #tank-stage {
  min-height: calc(100vh - 92px);
}

#shell[data-cinematic='true'][data-controls='open'] #control-panel {
  opacity: 0;
  pointer-events: none;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.92), rgba(5, 10, 20, 0.70));
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  color: rgba(168, 230, 255, 0.86);
}

.control strong {
  color: #ffffff;
  font-size: 1rem;
}

.control small {
  color: var(--muted);
  line-height: 1.45;
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.scenario-row {
  margin-top: 2px;
}

.preset-tag {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: rgba(168, 230, 255, 0.74);
}

.preset-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-button {
  appearance: none;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(7, 17, 38, 0.76);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease,
    transform 120ms ease;
}

.preset-button:hover,
.preset-button:focus-visible {
  border-color: rgba(168, 230, 255, 0.28);
  color: #ffffff;
  transform: translateY(-1px);
  outline: none;
}

.preset-button[data-active='true'] {
  border-color: rgba(109, 220, 143, 0.28);
  background:
    linear-gradient(180deg, rgba(26, 61, 43, 0.92), rgba(9, 30, 21, 0.92));
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(109, 220, 143, 0.12);
}

input[type='range'] {
  width: 100%;
  margin: 0;
  appearance: none;
  height: 12px;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(109, 220, 143, 0.28), rgba(168, 230, 255, 0.26) 50%, rgba(240, 138, 75, 0.22));
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.32);
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(246, 242, 255, 0.94);
  background:
    radial-gradient(circle at 35% 35%, #ffffff, #b7d6ff 34%, #6ddc8f 58%, #1d2a4a 100%);
  box-shadow:
    0 0 0 4px rgba(109, 220, 143, 0.12),
    0 8px 18px rgba(0, 0, 0, 0.28);
}

input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(246, 242, 255, 0.94);
  background:
    radial-gradient(circle at 35% 35%, #ffffff, #b7d6ff 34%, #6ddc8f 58%, #1d2a4a 100%);
  box-shadow:
    0 0 0 4px rgba(109, 220, 143, 0.12),
    0 8px 18px rgba(0, 0, 0, 0.28);
}

.shortcut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 14px;
  border: 1px dashed rgba(168, 230, 255, 0.14);
  border-radius: 12px;
  color: rgba(168, 230, 255, 0.78);
  font-size: 0.84rem;
  line-height: 1.45;
}

.chart-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.chart-key-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#history {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(168, 230, 255, 0.12);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.94), rgba(4, 10, 21, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chart-key-item::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.chart-key-item.fish {
  color: var(--fish);
}

.chart-key-item.food {
  color: var(--food);
}

.chart-key-item.energy {
  color: var(--energy);
}

#history-note {
  font-size: 0.92rem;
}

.replay-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.replay-scrubber {
  display: grid;
  gap: 8px;
}

.replay-scrub-meta,
.replay-scrub-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.replay-scrub-meta span,
.replay-scrub-scale span {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#replay-scrub-label {
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

#replay-scrubber {
  width: 100%;
  margin: 0;
  accent-color: rgba(109, 220, 143, 0.92);
}

#bookmark-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.bookmark-chip {
  min-width: 190px;
  max-width: 240px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.90), rgba(5, 10, 20, 0.72));
  color: var(--text);
  text-align: left;
}

button.bookmark-chip {
  appearance: none;
  cursor: pointer;
  font: inherit;
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

button.bookmark-chip:hover,
button.bookmark-chip:focus-visible {
  border-color: rgba(168, 230, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(109, 220, 143, 0.18);
  transform: translateY(-1px);
  outline: none;
}

button.bookmark-chip[data-active='true'] {
  border-color: rgba(109, 220, 143, 0.28);
  box-shadow: 0 0 0 1px rgba(109, 220, 143, 0.16);
}

.bookmark-chip strong {
  font-size: 0.82rem;
  line-height: 1.35;
}

.bookmark-chip small {
  color: var(--muted);
  line-height: 1.45;
}

.bookmark-empty {
  min-width: 100%;
}

#event-stream {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.event-item {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.90), rgba(5, 10, 20, 0.70));
}

.event-item[data-kind='birth'] {
  box-shadow: inset 0 0 0 1px rgba(109, 220, 143, 0.10);
}

.event-item[data-kind='death'] {
  box-shadow: inset 0 0 0 1px rgba(214, 69, 69, 0.10);
}

.event-item[data-kind='predation'] {
  box-shadow: inset 0 0 0 1px rgba(240, 138, 75, 0.12);
}

.event-item[data-kind='disturbance'] {
  box-shadow: inset 0 0 0 1px rgba(168, 230, 255, 0.12);
}

.event-item[data-kind='reseed'] {
  box-shadow: inset 0 0 0 1px rgba(255, 230, 109, 0.12);
}

.event-item[data-kind='bookmark'] {
  box-shadow: inset 0 0 0 1px rgba(123, 217, 255, 0.12);
}

.event-item[data-kind='immigrant'] {
  box-shadow: inset 0 0 0 1px rgba(203, 182, 255, 0.12);
}

.event-time {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: rgba(168, 230, 255, 0.72);
}

.event-item strong {
  color: #ffffff;
  font-size: 0.96rem;
  line-height: 1.2;
}

.event-item small {
  color: var(--muted);
  line-height: 1.45;
}

.callout-stack {
  display: grid;
  gap: 10px;
}

.callout {
  min-width: 0;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.92), rgba(5, 10, 20, 0.68));
  line-height: 1.5;
  color: #e8f2ff;
}

#inspector-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(12, 24, 48, 0.92), rgba(5, 10, 20, 0.74));
  box-shadow: inset 0 0 0 1px rgba(7, 17, 38, 0.52);
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.inspector-head h3 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.1rem, 1.7vw, 1.45rem);
  line-height: 1.08;
  color: #ffffff;
}

.inspector-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#watch-panel {
  display: grid;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid rgba(168, 230, 255, 0.10);
}

#watch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}

.watch-chip strong {
  font-size: 1rem;
}

#watch-feed {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

#watch-feed .event-item {
  padding: 10px 12px;
}

#watch-feed .event-item strong {
  font-size: 0.92rem;
}

#watch-feed .event-item small {
  font-size: 0.78rem;
}

#inspect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inspect-chip {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.92), rgba(5, 10, 20, 0.72));
}

.inspect-chip span {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: rgba(168, 230, 255, 0.72);
}

.inspect-chip strong {
  font-size: 1.15rem;
  line-height: 1.05;
  color: #ffffff;
}

#archetype-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#split-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.archetype-chip {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.90), rgba(5, 10, 20, 0.68));
}

.archetype-chip span {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: rgba(168, 230, 255, 0.78);
}

.archetype-chip strong {
  font-size: 1.55rem;
  color: #ffffff;
}

.archetype-chip.grazer {
  box-shadow: inset 0 0 0 1px rgba(109, 220, 143, 0.14);
}

.archetype-chip.shoaler {
  box-shadow: inset 0 0 0 1px rgba(255, 230, 109, 0.14);
}

.archetype-chip.opportunist {
  box-shadow: inset 0 0 0 1px rgba(240, 138, 75, 0.16);
}

.archetype-chip.hunter {
  box-shadow: inset 0 0 0 1px rgba(214, 69, 69, 0.14);
}

.split-chip {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid rgba(168, 230, 255, 0.10);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(9, 18, 38, 0.90), rgba(5, 10, 20, 0.68));
  box-shadow: inset 0 0 0 1px rgba(168, 230, 255, 0.05);
}

.split-chip span {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: rgba(168, 230, 255, 0.74);
}

.split-chip strong {
  font-size: 1.22rem;
  line-height: 1;
  color: #ffffff;
}

#control-panel {
  position: fixed;
  top: 18px;
  right: clamp(12px, 2vw, 28px);
  width: min(430px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 28px));
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

#shell[data-controls='open'] #control-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

#control-panel .control-grid {
  grid-template-columns: 1fr;
}

#control-scrim {
  position: fixed;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background:
    radial-gradient(circle at 68% 18%, rgba(16, 34, 71, 0.14), transparent 26%),
    rgba(2, 6, 14, 0.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 24;
}

#shell[data-controls='open'] + #control-scrim {
  opacity: 1;
  pointer-events: auto;
}

#shell[data-handheld='true'] {
  grid-template-areas:
    "tank-panel"
    "bottom-dock";
  gap: 12px;
}

#shell[data-handheld='true'] #topbar {
  display: none;
}

#shell[data-handheld='true'] #tank-panel,
#shell[data-handheld='true'] .dock-card {
  padding: 14px;
}

#shell[data-handheld='true'] #tank-panel {
  gap: 12px;
}

#shell[data-handheld='true'] #tank-panel > .panel-head {
  display: none;
}

#shell[data-handheld='true'] #mobile-titlebar {
  display: grid;
  gap: 2px;
}

#shell[data-handheld='true'] #tank-toolbar {
  order: 1;
  gap: 8px;
}

#shell[data-handheld='true'] #top-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#shell[data-handheld='true'] #focus-mode,
#shell[data-handheld='true'] #music-prev,
#shell[data-handheld='true'] #music-next,
#shell[data-handheld='true'] .seed-actions {
  display: none;
}

#shell[data-handheld='true'] #tank-observation {
  display: none;
}

#shell[data-handheld='true'] #tank-stage {
  order: 2;
  min-height: 0;
  aspect-ratio: 1.72 / 1;
  padding: 12px;
}

#shell[data-handheld='true'] #tank-replay-bar {
  order: 3;
  margin-bottom: 0;
  padding: 12px 14px;
}

#shell[data-handheld='true'] #bottom-dock {
  grid-template-columns: 1fr;
  gap: 12px;
}

#shell[data-handheld='true'] #bookmark-list {
  flex-direction: column;
  overflow-x: visible;
}

#shell[data-handheld='true'] .bookmark-chip {
  min-width: 0;
  max-width: none;
}

#shell[data-handheld='true'] .shortcut-row {
  display: none;
}

#shell[data-handheld='true'] #control-panel {
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-height: min(84vh, 760px);
  border-radius: 20px 20px 0 0;
  transform: translateY(calc(100% + 20px));
}

#shell[data-handheld='true'][data-controls='open'] #control-panel {
  transform: translateY(0);
}

#shell[data-handheld='true'] + #control-scrim {
  background:
    linear-gradient(180deg, rgba(2, 6, 14, 0.12), rgba(2, 6, 14, 0.62)),
    radial-gradient(circle at 50% 100%, rgba(16, 34, 71, 0.18), transparent 34%);
}

#shell[data-handheld='true'][data-fullscreen='true'] {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  min-height: 100dvh;
  grid-template-areas:
    "tank-panel"
    "bottom-dock";
  grid-template-rows: 1fr 0;
  justify-items: center;
  gap: 0;
}

#shell[data-handheld='true'][data-fullscreen='true'] #tank-panel {
  min-height: 100dvh;
  width: min(100%, calc((100dvh - 76px) * 1.72 + 16px));
  padding: 8px;
  gap: 8px;
  border-radius: 0;
  border-color: rgba(168, 230, 255, 0.08);
  box-shadow: none;
  align-content: start;
  justify-self: center;
}

#shell[data-handheld='true'][data-fullscreen='true'] #top-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#shell[data-handheld='true'][data-fullscreen='true'] #reset-sim {
  display: none;
}

#shell[data-handheld='true'][data-fullscreen='true'] #mobile-titlebar {
  display: none;
}

#shell[data-handheld='true'][data-fullscreen='true'] #tank-observation,
#shell[data-handheld='true'][data-fullscreen='true'] #tank-replay-bar,
#shell[data-handheld='true'][data-fullscreen='true'] #history-panel,
#shell[data-handheld='true'][data-fullscreen='true'] #insight-panel {
  display: none;
}

#shell[data-handheld='true'][data-fullscreen='true'] #bottom-dock {
  height: 0;
  min-height: 0;
  overflow: visible;
  gap: 0;
}

#shell[data-handheld='true'][data-fullscreen='true'] #control-panel {
  position: absolute;
  top: 76px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  width: auto;
  max-height: none;
  border-radius: 18px;
  border-color: rgba(168, 230, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(20, 42, 82, 0.94), rgba(6, 14, 28, 0.96));
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.56),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28);
  transform: translateY(calc(100% + 24px));
  z-index: 80;
}

#shell[data-handheld='true'][data-fullscreen='true'][data-controls='open'] #control-panel {
  transform: translateY(0);
}

#shell[data-handheld='true'][data-fullscreen='true'][data-controls='open'] #tank-stage {
  opacity: 0.34;
  filter: saturate(0.8) blur(1px);
}

#shell[data-handheld='true'][data-fullscreen='true'] #tank-stage {
  min-height: 0;
  max-height: calc(100dvh - 76px);
  width: 100%;
  aspect-ratio: 1.72 / 1;
  padding: 8px;
  border-radius: 16px;
  place-items: center;
  transition:
    opacity 160ms ease,
    filter 160ms ease;
}

#noscript {
  position: fixed;
  inset: auto 18px 18px 18px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border-radius: 8px;
}

@media (max-width: 1220px) {
  #topbar {
    grid-template-columns: 1fr;
  }

  #status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tank-toolbar {
    grid-template-columns: 1fr;
  }

  .seed-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1200px) {
  #bottom-dock {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  #split-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #inspect-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tank-observation {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #music-panel {
    grid-column: 1 / -1;
  }

  #control-panel {
    top: auto;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: min(78vh, 760px);
    transform: translateY(calc(100% + 18px));
  }

  #shell[data-controls='open'] #control-panel {
    transform: translateY(0);
  }
}

@media (max-width: 980px), (max-height: 540px) {
  #wrap {
    padding: 12px;
  }
}

@media (max-height: 540px) {
  #shell[data-handheld='true'] #top-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #shell[data-handheld='true'] #tank-stage {
    min-height: 300px;
  }

  #shell[data-handheld='true'] #tank-replay-bar {
    padding: 10px 12px;
  }

}

@media (max-width: 780px) {
  #wrap {
    display: block;
    width: 100%;
    padding: 12px;
  }

  #shell {
    width: 100%;
  }

  #wrap {
    justify-content: stretch;
  }

  #status-strip,
  #archetype-grid {
    grid-template-columns: 1fr;
  }

  #inspect-grid {
    grid-template-columns: 1fr;
  }

  #split-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #bookmark-list {
    flex-direction: column;
    overflow-x: visible;
  }

  .bookmark-chip {
    min-width: 0;
    max-width: none;
  }

  #status-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  #topbar {
    padding: 14px;
  }

  #bottom-dock {
    gap: 16px;
  }

  #tank-panel,
  .dock-card {
    padding: 14px;
  }

  #tank-stage {
    min-height: 420px;
    padding: 12px;
  }

  #top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tank-observation {
    grid-template-columns: 1fr;
  }

  .music-controls {
    grid-template-columns: 1fr;
  }

  .chrome-button,
  .seed-actions,
  .seed-control {
    width: 100%;
    min-width: 0;
  }

  .seed-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
  }

  .seed-control {
    grid-column: auto;
    max-width: none;
  }

  #control-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-height: min(84vh, 720px);
  }
}
