/* 심해 낚시 */
:root {
  --bg: #04122a; --panel: rgba(6, 22, 48, .88); --line: rgba(125, 211, 252, .25);
  --text: #eaf6ff; --mute: #94b8d6; --gold: #fbbf24; --cyan: #38bdf8; --red: #f87171; --green: #4ade80;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden; user-select: none; -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR", sans-serif;
  touch-action: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
b { font-weight: 800; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.shake #game { animation: shake .3s; }
@keyframes shake { 25% { transform: translate(-4px, 2px); } 50% { transform: translate(4px, -2px); } 75% { transform: translate(-2px, 1px); } }

.topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 6px; z-index: 10; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.back-btn { color: #fff; text-decoration: none; font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 9px; background: rgba(2, 18, 40, .55); border: 1px solid rgba(255, 255, 255, .25); white-space: nowrap; backdrop-filter: blur(4px); }
.back-btn:hover { background: rgba(2, 18, 40, .8); }
.coins { margin: 0 auto; font-size: .95rem; background: rgba(2, 18, 40, .6); border: 1px solid rgba(251, 191, 36, .4); padding: 5px 12px; border-radius: 99px; white-space: nowrap; }
.coins b { color: var(--gold); }
.tools { display: flex; gap: 5px; }
.mini { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 9px; background: rgba(2, 18, 40, .55); border: 1px solid rgba(255, 255, 255, .25); font-size: .9rem; }

.btn { padding: 11px 18px; border-radius: 12px; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .16); font-weight: 700; transition: transform .12s, background .2s; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn small { font-weight: 500; font-size: .7rem; opacity: .7; margin-left: 4px; }
.btn.primary, .btn.cast { background: linear-gradient(135deg, #0ea5e9, #2563eb); border-color: transparent; color: #fff; box-shadow: 0 4px 18px rgba(37, 99, 235, .45); }

/* 항구 시트 */
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100%); max-height: 64dvh; overflow-y: auto; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); backdrop-filter: blur(8px); }
.h-head { text-align: center; margin-bottom: 10px; }
.h-head h1 { font-size: 1.35rem; font-weight: 900; background: linear-gradient(135deg, #7dd3fc, #fde68a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.h-stats { color: var(--mute); font-size: .8rem; margin-top: 3px; }
.btn.cast { width: 100%; font-size: 1.1rem; padding: 14px; margin-bottom: 10px; }
.ups { display: grid; grid-template-columns: 1fr; gap: 6px; }
.up { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); text-align: left; width: 100%; }
.up:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.up .ic { font-size: 1.5rem; width: 34px; text-align: center; }
.up .tx { flex: 1; min-width: 0; }
.up .nm { font-weight: 800; font-size: .92rem; }
.up .lv { font-size: .72rem; color: var(--mute); margin-left: 4px; font-weight: 600; }
.up .ds { font-size: .76rem; color: var(--mute); }
.up .ds b { color: var(--text); }
.up .ds .nx { color: var(--green); }
.up .pr { font-weight: 800; color: var(--gold); white-space: nowrap; font-size: .9rem; }
.up.cant .pr { color: #64748b; }
.up.max .pr { color: var(--green); }
.lvbar { display: flex; gap: 2px; margin-top: 4px; }
.lvbar i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .12); }
.lvbar i.on { background: var(--cyan); }
.h-row { display: flex; gap: 8px; margin-top: 10px; }
.h-row .btn { flex: 1; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.depth { position: absolute; left: 12px; top: calc(54px + env(safe-area-inset-top)); text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.depth b { font-size: 2.4rem; font-variant-numeric: tabular-nums; }
.depth span { font-size: 1rem; margin-left: 2px; font-weight: 700; }
.depth small { display: block; font-size: .78rem; color: #bae6fd; font-weight: 700; }
.hud-r { position: absolute; right: 12px; top: calc(54px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.pill { background: rgba(2, 18, 40, .6); border: 1px solid rgba(255, 255, 255, .2); padding: 4px 10px; border-radius: 99px; font-weight: 800; font-size: .9rem; }
.pill.full { border-color: var(--gold); color: var(--gold); }
.phase { position: absolute; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); text-align: center; font-size: .85rem; font-weight: 700; color: #e0f2fe; text-shadow: 0 2px 6px rgba(0, 0, 0, .8); }
.reel { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); pointer-events: auto; background: rgba(2, 18, 40, .7); border-color: rgba(125, 211, 252, .5); }
.reel[hidden] { display: none; }

.banner { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none; text-align: center; font-weight: 900; font-size: 1.5rem; text-shadow: 0 3px 12px rgba(0, 0, 0, .7); animation: bannerIn 2.2s ease forwards; white-space: nowrap; }
.banner small { display: block; font-size: .85rem; font-weight: 700; color: #bae6fd; }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, -30%); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-50%, -60%); } }

.toss-hint { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; background: rgba(2, 18, 40, .75); border: 1px solid rgba(251, 191, 36, .5); padding: 8px 14px; border-radius: 99px; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.toss-hint b { color: var(--gold); }
.link { text-decoration: underline; color: var(--mute); margin-left: 8px; font-size: .8rem; }

.floaters { position: fixed; inset: 0; pointer-events: none; z-index: 7; overflow: hidden; }
.fl { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: .95rem; text-shadow: 0 2px 6px rgba(0, 0, 0, .8); animation: floatUp 1.1s ease-out forwards; white-space: nowrap; }
.fl.gold { color: var(--gold); } .fl.red { color: var(--red); } .fl.cyan { color: #7dd3fc; } .fl.big { font-size: 1.3rem; }
@keyframes floatUp { 0% { opacity: 0; margin-top: 10px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -50px; } }

/* 모달 */
.modal[hidden], [hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(1, 8, 20, .7); display: flex; align-items: center; justify-content: center; padding: 14px; backdrop-filter: blur(3px); }
.panel { width: min(560px, 100%); max-height: calc(100dvh - 28px); overflow-y: auto; background: #071a36; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.panel h2 { text-align: center; font-size: 1.25rem; margin-bottom: 8px; }
.panel .sub { text-align: center; color: var(--mute); font-size: .82rem; margin-bottom: 10px; }
.panel .row { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.panel .row .btn { flex: 1; max-width: 240px; }
.panel p, .panel li { font-size: .88rem; line-height: 1.55; color: #cfe6f8; }
.panel ul { padding-left: 18px; margin: 6px 0; }
.panel h3 { font-size: .95rem; margin: 12px 0 4px; color: #7dd3fc; }
.panel.err h2 { color: var(--red); }
.panel.err pre { white-space: pre-wrap; font-size: .75rem; color: var(--mute); background: rgba(0, 0, 0, .3); padding: 8px; border-radius: 8px; margin-top: 8px; }

/* 결과 */
.res-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.res-it { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); font-size: .85rem; }
.res-it canvas { width: 54px; height: 30px; flex-shrink: 0; }
.res-it .nm { flex: 1; min-width: 0; }
.res-it .nm small { color: var(--mute); margin-left: 4px; }
.res-it .val { font-weight: 800; color: var(--gold); white-space: nowrap; }
.res-it .val small { color: var(--green); font-weight: 700; margin-left: 3px; }
.tagnew { font-size: .65rem; font-weight: 900; color: #052e16; background: var(--green); border-radius: 5px; padding: 1px 5px; margin-left: 4px; }
.tagrec { font-size: .65rem; font-weight: 900; color: #451a03; background: var(--gold); border-radius: 5px; padding: 1px 5px; margin-left: 4px; }
.tagleg { font-size: .65rem; font-weight: 900; color: #fff; background: linear-gradient(135deg, #f59e0b, #db2777); border-radius: 5px; padding: 1px 5px; margin-left: 4px; }
.res-sum { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: .88rem; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .25); }
.res-sum .tot { font-size: 1.1rem; font-weight: 900; color: var(--gold); }
.res-empty { text-align: center; color: var(--mute); padding: 14px 0; }
.ending { text-align: center; padding: 10px; margin: 8px 0; border-radius: 12px; background: linear-gradient(135deg, rgba(245, 158, 11, .2), rgba(219, 39, 119, .2)); border: 1px solid rgba(251, 191, 36, .5); font-weight: 700; }

/* 도감 */
.cx-tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.cx-tabs button { padding: 5px 10px; border-radius: 99px; background: rgba(255, 255, 255, .06); font-size: .78rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.cx-tabs button.on { background: rgba(56, 189, 248, .2); border-color: var(--cyan); }
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.cx { padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); text-align: center; }
.cx.leg { border-color: rgba(251, 191, 36, .45); background: rgba(251, 191, 36, .07); }
.cx.haz { border-color: rgba(248, 113, 113, .35); }
.cx canvas { width: 100%; height: 56px; display: block; }
.cx .nm { font-weight: 800; font-size: .85rem; }
.cx .meta { font-size: .7rem; color: var(--mute); }
.cx .ds { font-size: .7rem; color: #b6d4ea; margin-top: 3px; line-height: 1.35; }

.toast { position: fixed; left: 50%; top: calc(60px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30; background: rgba(2, 18, 40, .92); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; font-size: .85rem; font-weight: 700; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
.toast.on { opacity: 1; }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

@media (max-width: 420px) {
  .back-txt { display: none; }
  .depth b { font-size: 2rem; }
}
@media (min-width: 700px) and (min-height: 600px) {
  .ups { grid-template-columns: 1fr 1fr; }
  .sheet { max-height: 70dvh; }
}
