:root {
  --bg: #0f1316;
  --panel: rgba(18, 26, 30, 0.78);
  --panel-solid: #172126;
  --line: rgba(190, 230, 225, 0.16);
  --text: #eef6f3;
  --muted: #9fb7b2;
  --accent: #7fe0b8;
  --accent2: #ffd27a;
  --warn: #ffb35c;
  --bad: #ff6b6b;
  --good: #7fe0b8;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { -webkit-touch-callout: none; margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none; overscroll-behavior: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#c.pixel { image-rendering: pixelated; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 18px; z-index: 100; transition: opacity .5s; }
#boot.hide { opacity: 0; pointer-events: none; }

/* ---------- top: test kit ---------- */
#topbar { position: absolute; top: calc(8px + var(--safe-top)); left: 8px; right: 8px; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
#topbar > * { pointer-events: auto; }
#kit { flex: 1; max-width: 560px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; cursor: pointer; }
.row1 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.row1 .spacer { flex: 1; }
#money { color: var(--accent2); font-variant-numeric: tabular-nums; }
#clock, #temp { font-variant-numeric: tabular-nums; }
#temp { color: var(--muted); font-weight: 500; }
.chips { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; line-height: 1; padding: 5px 7px; border-radius: 999px; background: rgba(255,255,255,0.07); white-space: nowrap; font-variant-numeric: tabular-nums; border: 1px solid transparent; }
.chip b { font-weight: 700; margin-left: 3px; }
.chip.g { border-color: rgba(127,224,184,.45); }
.chip.y { border-color: rgba(255,224,120,.6); background: rgba(255,224,120,.12); }
.chip.o { border-color: rgba(255,170,80,.75); background: rgba(255,170,80,.18); }
.chip.r { border-color: rgba(255,100,100,.9); background: rgba(255,90,90,.25); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { background: rgba(255,90,90,.45); } }
.pop { margin-top: 6px; font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.iconbtn { width: 48px; height: 48px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-size: 22px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: grid; place-items: center; flex: none; }

/* ---------- toasts ---------- */
#toasts { position: absolute; top: calc(122px + var(--safe-top)); left: 50%; transform: translateX(-50%); width: min(92vw, 460px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: rgba(14, 22, 26, 0.88); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 14px; line-height: 1.4; animation: tin .25s ease-out; transition: opacity .4s, transform .4s; }
.toast.death { border-color: rgba(255,107,107,.6); }
.toast.birth, .toast.good { border-color: rgba(127,224,184,.6); }
.toast.warn { border-color: rgba(255,179,92,.7); }
.toast.out { opacity: 0; transform: translateY(-6px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- mode bar ---------- */
#modebar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-bot)); background: rgba(30, 60, 50, .92); border: 1px solid var(--accent); border-radius: 999px; padding: 6px 6px 6px 16px; display: flex; gap: 10px; align-items: center; font-size: 14px; max-width: 94vw; }
#modebar button { background: var(--accent); color: #0b1a14; font-weight: 700; padding: 0 16px; height: 40px; border-radius: 999px; }

/* ---------- bottom ---------- */
#bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 8px calc(8px + var(--safe-bot)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#bottom > * { pointer-events: auto; }
#speeds { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#speeds button { min-width: 62px; height: 46px; border-radius: 999px; color: var(--muted); padding: 0 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
#speeds button b { font-size: 12px; letter-spacing: -2px; font-weight: 700; }
#speeds button small { font-size: 10.5px; margin-top: 2px; }
#speeds button.on { background: var(--accent); color: #0b1a14; font-weight: 700; }
#actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; max-width: 560px; }
#actions button { position: relative; height: 62px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#actions button i { font-style: normal; font-size: 22px; line-height: 1; }
#actions button span { font-size: 13px; }
#actions button:active, .btn:active, #speeds button:active { transform: scale(.96); }
.badge { position: absolute; top: 4px; right: 8px; background: var(--bad); color: white; border-radius: 999px; font-size: 11px; padding: 1px 6px; }

/* ---------- info card ---------- */
#info { position: absolute; left: 8px; right: 8px; bottom: calc(126px + var(--safe-bot)); margin: 0 auto; max-width: 440px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
#info h3 { margin: 0 0 4px; font-size: 17px; display: flex; gap: 8px; align-items: center; }
#info h3 .x { margin-left: auto; width: 40px; height: 40px; font-size: 18px; border-radius: 12px; background: rgba(255,255,255,.06); }
#info .meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.bars { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; font-size: 13px; margin-bottom: 10px; }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 14px; border-radius: 12px; background: rgba(255,255,255,.09); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.btn.primary { background: var(--accent); color: #0b1a14; border-color: transparent; }
.btn.gold { background: var(--accent2); color: #2a1d00; border-color: transparent; }
.btn.danger { background: rgba(255,107,107,.2); border-color: rgba(255,107,107,.5); }
.btn[disabled] { opacity: .4; }

/* ---------- sheet ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 620px; max-height: 78vh; background: var(--panel-solid); border-radius: 22px 22px 0 0; border: 1px solid var(--line); display: flex; flex-direction: column; padding-bottom: var(--safe-bot); animation: sup .22s ease-out; }
@keyframes sup { from { transform: translateY(40px); opacity: .5; } }
.sheet-head { display: flex; align-items: center; padding: 10px 10px 6px 18px; }
.sheet-head h2 { margin: 0; font-size: 19px; flex: 1; }
.tabs { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; flex: none; }
.tabs button { flex: none; height: 40px; padding: 0 14px; border-radius: 999px; background: rgba(255,255,255,.07); font-size: 14px; }
.tabs button.on { background: var(--accent); color: #0b1a14; font-weight: 700; }
.sheet-body { overflow-y: auto; padding: 4px 12px 16px; -webkit-overflow-scrolling: touch; touch-action: pan-y; user-select: text; -webkit-user-select: text; }
.card { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.card h4 { margin: 0 0 2px; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.card h4 .price { margin-left: auto; color: var(--accent2); font-size: 15px; }
.card .note { color: var(--muted); font-size: 13px; line-height: 1.45; margin-bottom: 8px; }
.card .latin { color: var(--muted); font-size: 12px; font-style: italic; font-weight: 400; }
.tip { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 6px 2px 10px; }
.shopbrand { display: flex; align-items: center; gap: 10px; margin: 0 2px 10px; padding: 10px 12px; border-radius: 14px; background: linear-gradient(120deg, rgba(80,170,200,.25), rgba(127,224,184,.18)); border: 1px solid var(--line); }
.shopbrand b { font-size: 16px; }
.shopbrand small { color: var(--muted); display: block; font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 6px 0 12px; }
.kv span:nth-child(odd) { color: var(--muted); }
canvas.chart { width: 100%; height: 150px; background: rgba(0,0,0,.25); border-radius: 12px; display: block; margin: 8px 0; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.loglist { font-size: 13px; line-height: 1.5; }
.loglist div { padding: 4px 0; border-bottom: 1px solid var(--line); }
.loglist small { color: var(--muted); margin-right: 6px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .btn.on { background: var(--accent); color: #0b1a14; }

#overlay { position: fixed; inset: 0; z-index: 30; background: rgba(5,10,12,.7); display: grid; place-items: center; padding: 20px; }
.ov-card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 18px; max-width: 420px; width: 100%; max-height: 80vh; overflow-y: auto; line-height: 1.55; font-size: 15px; }
.ov-card h3 { margin: 0 0 8px; }

@media (min-width: 800px) {
  #topbar { left: 16px; right: 16px; top: 16px; }
  #toasts { top: 130px; }
  #info { left: auto; right: 16px; bottom: 140px; width: 380px; }
}

.sidebtns { display: flex; flex-direction: column; gap: 8px; }
#btnEye { font-size: 18px; }
body.viewing #kit, body.viewing #bottom, body.viewing #toasts, body.viewing #info, body.viewing #btnMore, body.viewing #modebar { opacity: 0; pointer-events: none; transition: opacity .4s; }
body.viewing #btnEye { opacity: .45; }
#kit, #bottom, #toasts, #btnMore { transition: opacity .4s; }
/* shrimp genetics: phenotype swatch + pedigree block in the info card */
#info .meta + .meta { margin-top: -4px; }
#info .swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border: 1px solid rgba(255,255,255,.35); }
#info .genes { font-size: 12px; color: var(--muted); background: rgba(255,255,255,.05); border-radius: 10px; padding: 6px 8px; margin: -2px 0 8px; line-height: 1.55; }
#info .genes .mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; opacity: .85; word-break: break-all; }
.warncard { border: 1px solid var(--warn); }
#info h3 .genesbtn { margin-left: auto; }
#info h3 .genesbtn + .x { margin-left: 0; }
#info h3 .genesbtn.on { background: rgba(127,224,184,.25); }
#info .meta b.grade { color: var(--text, #fff); }
