/* Глибина — інтерфейс */
:root {
    --bg: #04101f;
    --glass: rgba(6, 22, 40, 0.88);
    --glass2: rgba(8, 26, 46, 0.97);
    --line: rgba(56, 189, 248, 0.3);
    --line2: rgba(148, 163, 184, 0.16);
    --txt: #e6f4fb;
    --dim: #8fb0c6;
    --cyan: #38bdf8;
    --teal: #2dd4bf;
    --pearl: #fde68a;
    --green: #4ade80;
    --red: #f87171;
    --r: 14px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    color-scheme: dark;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: rgba(56, 189, 248, 0.45) rgba(255, 255, 255, 0.04); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); border-radius: 8px; }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.45); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
html, body { margin: 0; height: 100%; }
body { position: fixed; inset: 0; overflow: hidden; background: var(--bg); color: var(--txt); font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.off { display: none !important; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.glass { background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: var(--r); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5); }
.ib { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); color: #e0f2fe; }
.ib svg { width: 22px; height: 22px; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--green); color: #052e16; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #061628; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 13px; border-radius: 10px; font-weight: 700; font-size: 13px; background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.5); color: #e0f2fe; white-space: nowrap; }
.btn:active { transform: scale(0.97); }
.btn.gold { background: linear-gradient(180deg, #fde68a, #f59e0b); color: #2a1803; border-color: #fcd34d; }
.btn.teal { background: linear-gradient(180deg, #5eead4, #0d9488); color: #022c22; border-color: #5eead4; }
.btn.green { background: rgba(74, 222, 128, 0.14); border-color: rgba(74, 222, 128, 0.5); color: #bbf7d0; }
.btn.red { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.5); color: #fecaca; }
.btn.dim, .btn:disabled { background: rgba(148, 163, 184, 0.06); border-color: rgba(148, 163, 184, 0.2); color: #7a93a6; }
.btn:disabled { cursor: not-allowed; }
.btn.sm { padding: 6px 9px; font-size: 12px; }
.btn.xs { padding: 3px 7px; font-size: 11px; border-radius: 7px; }
.muted { color: var(--dim); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.bar { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.25s; }
.pearl { color: var(--pearl); font-weight: 800; white-space: nowrap; }
.pearl::before { content: ''; display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.25em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 18%, #fde68a 40%, #d4a54a 100%); vertical-align: -0.05em; box-shadow: 0 0 6px rgba(253, 230, 138, 0.6); }

/* ---------- верх ---------- */
#top { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; z-index: 20; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
#top > * { pointer-events: auto; }
.spacer { flex: 1; }
.stat { display: flex; flex-direction: column; align-items: flex-end; padding: 5px 12px; min-width: 80px; }
.stat small { font-size: 9px; letter-spacing: 0.14em; color: var(--dim); font-weight: 700; text-transform: uppercase; }
.stat b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { font-size: 10.5px; font-weight: 700; color: #86efac; }
#moneyStat b { font-size: 19px; }

/* ---------- панель закиду ---------- */
#castPanel { position: absolute; z-index: 19; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); width: min(440px, calc(100% - 16px)); padding: 10px 12px 12px; text-align: center; }
#castPanel .gearline { display: flex; justify-content: center; gap: 12px; font-size: 12px; font-weight: 700; color: var(--dim); margin-bottom: 8px; flex-wrap: wrap; }
#castPanel .gearline b { color: #e0f2fe; }
.zchips { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.zchips button { flex: none; padding: 6px 10px; border-radius: 9px; font-size: 11.5px; font-weight: 700; border: 1px solid var(--line2); color: var(--dim); }
.zchips button.on { color: #fff; border-color: var(--teal); background: rgba(45, 212, 191, 0.15); }
#castBtn { width: 100%; padding: 14px; font-size: 18px; font-weight: 900; border-radius: 14px; letter-spacing: 0.02em; box-shadow: 0 0 24px rgba(253, 230, 138, 0.3); }
#pendingBtn { margin-top: 8px; width: 100%; }

/* ---------- HUD закиду ---------- */
#runHud { position: absolute; z-index: 19; top: calc(60px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: none; }
#runHud .glass { padding: 6px 12px; display: flex; flex-direction: column; align-items: center; min-width: 78px; }
#runHud small { font-size: 9px; font-weight: 800; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; }
#runHud b { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
#zoneTag { position: absolute; z-index: 18; left: 50%; transform: translateX(-50%); top: calc(122px + var(--safe-t)); font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(224, 242, 254, 0.85); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); pointer-events: none; transition: opacity 0.4s; }
#depthBar { position: absolute; z-index: 18; right: 10px; top: 25%; bottom: 25%; width: 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); pointer-events: none; }
#depthBar i { position: absolute; left: -4px; right: -4px; height: 6px; border-radius: 3px; background: var(--pearl); box-shadow: 0 0 8px var(--pearl); }
#depthBar u { position: absolute; left: 0; right: 0; top: 0; border-radius: 6px; background: linear-gradient(180deg, #7fe0f5, #0c2c58, #1c0a24); opacity: 0.6; }
#runTip { position: absolute; z-index: 18; left: 50%; transform: translateX(-50%); bottom: calc(30px + var(--safe-b)); font-size: 13px; font-weight: 700; color: #e0f2fe; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); pointer-events: none; text-align: center; width: 90%; }

/* ---------- низ ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 8px calc(8px + var(--safe-b)); display: flex; justify-content: center; pointer-events: none; }
#nav { display: flex; gap: 4px; padding: 6px; pointer-events: auto; overflow-x: auto; max-width: 100%; }
.nb { flex: none; width: 76px; height: 58px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 700; color: #dbeafe; position: relative; }
.nb svg { width: 23px; height: 23px; color: var(--cyan); }
.nb.on { background: rgba(56, 189, 248, 0.14); }
.nb.on svg { color: var(--pearl); }
.nb:active { transform: scale(0.95); }

/* ---------- картка акваріума ---------- */
#card { position: absolute; z-index: 25; left: 8px; right: 8px; bottom: calc(84px + var(--safe-b)); max-width: 440px; margin: 0 auto; padding: 12px; max-height: 60vh; overflow-y: auto; }
#card h3 { margin: 0; font-size: 16px; }
#card .x { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; color: var(--dim); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed rgba(148, 163, 184, 0.12); }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.fishrow { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 11px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.03); margin-bottom: 5px; }
.fishrow img { width: 46px; height: 46px; flex: none; border-radius: 10px; background: radial-gradient(circle, rgba(56, 189, 248, 0.18), rgba(0, 0, 0, 0.25)); }
.fishrow .nm { font-size: 13px; font-weight: 700; }
.fishrow small { display: block; font-size: 11px; color: var(--dim); }
.new { font-size: 9.5px; font-weight: 900; padding: 1px 5px; border-radius: 5px; background: var(--pearl); color: #2a1803; margin-left: 5px; vertical-align: 1px; }

/* ---------- панелі ---------- */
#sheet { position: absolute; inset: 0; z-index: 40; background: rgba(2, 8, 16, 0.6); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safe-t)) 10px calc(10px + var(--safe-b)); }
.sheet-box { width: min(700px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--glass2); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7); animation: pop 0.18s ease-out; overflow: hidden; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.sheet-box > header { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line2); }
.sheet-box > header h2 { margin: 0; font-size: 17px; flex: 1; font-weight: 800; }
.sheet-box > header svg { width: 22px; height: 22px; color: var(--pearl); }
.sheet-box > header .x { width: 34px; height: 34px; border-radius: 10px; color: var(--dim); font-size: 18px; }
#sheetBody { padding: 12px 14px 16px; overflow-y: auto; min-height: 0; }
.subtabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.subtabs button { padding: 6px 11px; border-radius: 9px; font-size: 12px; font-weight: 700; color: var(--dim); border: 1px solid var(--line2); }
.subtabs button.on { color: #fff; border-color: var(--cyan); background: rgba(56, 189, 248, 0.14); }
.card { position: relative; padding: 10px 12px; border-radius: 13px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line2); margin-bottom: 8px; }
.card h4 { margin: 0; font-size: 14px; }
.card p { margin: 3px 0 0; font-size: 12px; color: var(--dim); line-height: 1.35; }
.gear { display: flex; gap: 10px; align-items: center; }
.gear .ic { width: 42px; height: 42px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: rgba(56, 189, 248, 0.1); border: 1px solid var(--line2); }
.pips { display: flex; gap: 3px; margin-top: 5px; }
.pips i { flex: 1; max-width: 22px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); }
.pips i.on { background: var(--teal); box-shadow: 0 0 6px rgba(45, 212, 191, 0.6); }
.step { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; color: var(--pearl); text-transform: uppercase; margin: 12px 0 6px; }
.enc { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 7px; }
.enc > div { padding: 8px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.03); text-align: center; position: relative; }
.enc img { width: 92px; height: 92px; display: block; margin: 0 auto; }
.enc b { display: block; font-size: 12px; margin-top: 2px; }
.enc small { display: block; font-size: 10.5px; color: var(--dim); }
.enc .rar { position: absolute; top: 6px; left: 8px; width: 8px; height: 8px; border-radius: 50%; }
.enc > div.unk b { color: #64748b; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list button, .menu-list a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.03); font-weight: 700; font-size: 14px; text-align: left; }
.menu-list svg { width: 20px; height: 20px; color: var(--cyan); flex: none; }
.menu-list .danger { color: #fca5a5; }
.ach { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 11px; border: 1px solid var(--line2); margin-bottom: 6px; opacity: 0.45; }
.ach.got { opacity: 1; border-color: rgba(253, 230, 138, 0.5); background: rgba(253, 230, 138, 0.06); }
.ach b { font-size: 13px; } .ach small { display: block; font-size: 11.5px; color: var(--dim); }
.help p { font-size: 13px; line-height: 1.5; margin: 0 0 9px; color: #d6e6f0; }
.help b { color: var(--pearl); }
.help h4 { margin: 14px 0 6px; font-size: 14px; color: var(--cyan); }

.modal { position: absolute; inset: 0; z-index: 60; background: rgba(2, 8, 16, 0.72); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { width: min(500px, 100%); max-height: 100%; overflow-y: auto; padding: 18px; text-align: center; border-radius: 18px; background: var(--glass2); border: 1px solid rgba(253, 230, 138, 0.45); box-shadow: 0 0 60px rgba(56, 189, 248, 0.15); animation: pop 0.2s ease-out; }
.modal h2 { margin: 4px 0; font-size: 20px; font-weight: 900; }
.modal .btn.wide { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
.modal .list { text-align: left; margin: 10px 0; max-height: 46vh; overflow-y: auto; }
.sumrow { display: flex; justify-content: space-between; padding: 6px 2px; font-size: 14px; border-bottom: 1px dashed rgba(148, 163, 184, 0.12); }
#toasts { position: absolute; z-index: 70; left: 50%; transform: translateX(-50%); top: calc(64px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: min(460px, 92vw); }
.toast { padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 600; background: rgba(6, 22, 40, 0.96); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); animation: tin 0.2s ease-out; transition: opacity 0.3s, transform 0.3s; text-align: center; }
.toast.err { border-color: rgba(239, 68, 68, 0.6); color: #fecaca; }
.toast.good { border-color: rgba(74, 222, 128, 0.6); color: #bbf7d0; }
.toast.gold { border-color: rgba(253, 230, 138, 0.7); color: #fde68a; }
.toast.hide { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
body.running #dock, body.running #castPanel, body.running #top .hideRun { display: none !important; }

@media (min-width: 900px) { #card { left: auto; right: 12px; bottom: auto; top: calc(70px + var(--safe-t)); margin: 0; width: 380px; } }
@media (max-width: 520px) {
    .stat { min-width: 0; padding: 4px 8px; } .stat b { font-size: 14px; } #moneyStat b { font-size: 16px; }
    .nb { width: 64px; font-size: 9.5px; }
    .enc { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); } .enc img { width: 76px; height: 76px; }
}
