* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #04121f; --panel: #0b2235; --panel2: #103047;
  --line: #1d445e; --txt: #dceaf4; --mut: #7fa3bd; --acc: #36c6ff; --acc2: #2bd9a8;
  --gold: #ffce4a; --danger: #ff5b6e; --oxy: #4fc3ff; --hp: #ff7a8a;
}
html, body {
  height: 100%; background: var(--bg); color: var(--txt);
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', system-ui, sans-serif;
  overflow: hidden; overscroll-behavior: none; touch-action: none;
}
body { display: flex; flex-direction: column; height: 100dvh; user-select: none; }

/* ===== 상단바 ===== */
#topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #0a2335, #071a28);
  border-bottom: 1px solid var(--line); z-index: 30;
}
#topbar .back { color: var(--mut); text-decoration: none; font-size: 13px; font-weight: 600; }
#topbar .brand { font-weight: 800; font-size: 16px; letter-spacing: .3px; }
#topbar .spacer { flex: 1; }
.hud.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700;
  background: #0d2c42; border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px;
}
.hud.chip i { font-style: normal; }
.hud.chip.gold b { color: var(--gold); }
.hud.chip.day b { color: var(--acc); }
.iconbtn {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: #0d2c42; color: var(--txt); font-weight: 800; cursor: pointer; font-size: 15px;
}

/* ===== 스테이지 ===== */
#stage { position: relative; flex: 1; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ===== 다이브 HUD ===== */
#diveHud { position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px; z-index: 12; pointer-events: none; }
#diveHud .bars { display: flex; flex-direction: column; gap: 6px; max-width: 320px; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar .lbl { font-size: 11px; color: var(--mut); width: 28px; font-weight: 700; }
.bar .track { flex: 1; height: 12px; background: #0a2030; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar .track i { display: block; height: 100%; width: 100%; border-radius: 999px; transition: width .12s linear; }
.bar.oxy .track i { background: linear-gradient(90deg, #2c8fd6, var(--oxy)); }
.bar.hp .track i { background: linear-gradient(90deg, #d23a4d, var(--hp)); }
.diveinfo { display: flex; gap: 14px; margin-top: 8px; font-size: 14px; font-weight: 700; text-shadow: 0 1px 4px #000; }
.diveinfo .depth b { color: var(--acc); }
.diveinfo .catchval b { color: var(--gold); }
#surfaceBtn {
  position: absolute; right: 12px; top: 10px; pointer-events: auto;
  background: rgba(10,40,60,.75); border: 1px solid var(--acc); color: var(--acc);
  font-weight: 800; font-size: 13px; padding: 7px 12px; border-radius: 10px; cursor: pointer;
  backdrop-filter: blur(3px);
}

/* ===== 식당 HUD ===== */
#restHud { position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px; z-index: 12; pointer-events: none; }
.resttop { display: flex; gap: 8px; flex-wrap: wrap; }
.rchip {
  font-size: 13px; font-weight: 700; background: rgba(10,40,60,.7); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(3px);
}
.rchip b { color: var(--gold); }

/* ===== 토스트 ===== */
#toast {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%,-50%);
  background: rgba(6,20,32,.92); border: 1px solid var(--acc); color: var(--txt);
  padding: 14px 22px; border-radius: 14px; font-weight: 800; font-size: 17px; text-align: center;
  z-index: 20; box-shadow: 0 10px 40px rgba(0,0,0,.5); max-width: 80%; line-height: 1.5;
}

/* ===== 작살 버튼 ===== */
#fireBtn {
  position: absolute; right: 18px; bottom: max(18px, env(safe-area-inset-bottom));
  width: 84px; height: 84px; border-radius: 50%; z-index: 15;
  background: radial-gradient(circle at 38% 34%, #2a9fd6, #0d3a55);
  border: 2px solid #5fd0ff; color: #eaffff; font-weight: 800; font-size: 14px; cursor: pointer;
  box-shadow: 0 6px 22px rgba(0,0,0,.5); touch-action: none;
}
#fireBtn:active { transform: scale(.93); }

/* ===== 오버레이 ===== */
.overlay {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: radial-gradient(ellipse at 50% 24%, rgba(10,40,64,.86), rgba(3,10,18,.96));
  backdrop-filter: blur(4px); overflow: auto;
}
.panel {
  background: linear-gradient(180deg, var(--panel), #081826);
  border: 1px solid var(--line); border-radius: 18px; padding: 22px;
  max-width: 440px; width: 100%; text-align: center; box-shadow: 0 18px 60px rgba(0,0,0,.55);
}
.panel.wide { max-width: 540px; text-align: left; }
.panel h1 { font-size: 30px; margin-bottom: 6px; letter-spacing: .5px; }
.panel h2 { font-size: 21px; margin-bottom: 10px; }
.tagline { color: var(--acc); font-weight: 700; font-size: 13px; margin-bottom: 14px; }
.lead { color: var(--txt); font-size: 14px; line-height: 1.65; margin-bottom: 14px; }
.lead b { color: var(--acc2); }
.howto { list-style: none; text-align: left; margin: 0 auto 18px; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.howto li { font-size: 13px; color: var(--mut); line-height: 1.5; padding-left: 20px; position: relative; }
.howto li::before { content: "▹"; position: absolute; left: 2px; color: var(--acc); }
.howto b { color: var(--txt); }
.bigbtn {
  display: block; width: 100%; margin-top: 8px; padding: 14px; border: none; border-radius: 12px;
  background: linear-gradient(180deg, #2fb6e6, #1f7fb8); color: #062130; font-weight: 800; font-size: 17px;
  cursor: pointer; box-shadow: 0 6px 18px rgba(31,127,184,.4);
}
.bigbtn:active { transform: translateY(1px); }
.linkbtn { background: none; border: none; color: var(--mut); margin-top: 12px; font-size: 14px; cursor: pointer; font-weight: 700; }

/* ===== 상점 ===== */
.shophead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; gap: 6px; }
.shophead h2 { margin: 0; font-size: 18px; }
.balance { font-size: 15px; font-weight: 700; }
.balance b { color: var(--gold); }
.ledger {
  background: #07192700; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px;
  font-size: 13px; color: var(--mut); margin-bottom: 14px; line-height: 1.7;
}
.ledger .pos { color: var(--acc2); font-weight: 700; }
.ledger .neg { color: var(--danger); font-weight: 700; }
.ledger b { color: var(--txt); }
.shopgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.upg {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 11px;
  cursor: pointer; transition: border-color .12s, transform .06s; position: relative;
}
.upg:active { transform: scale(.98); }
.upg.max { opacity: .55; cursor: default; }
.upg.cant { opacity: .8; }
.upg .uname { font-size: 13.5px; font-weight: 800; display: flex; align-items: center; gap: 5px; }
.upg .ulv { font-size: 11px; color: var(--acc); font-weight: 700; }
.upg .udesc { font-size: 11.5px; color: var(--mut); margin: 5px 0 8px; line-height: 1.4; min-height: 32px; }
.upg .ucost {
  font-size: 13px; font-weight: 800; color: var(--gold); display: inline-flex; align-items: center;
  background: #0a2333; border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px;
}
.upg.cant .ucost { color: var(--danger); }
.upg .lvdots { position: absolute; right: 10px; top: 10px; display: flex; gap: 3px; }
.upg .lvdots span { width: 6px; height: 6px; border-radius: 50%; background: #234055; }
.upg .lvdots span.on { background: var(--acc); }

.helpbody { text-align: left; }
.helpbody p { font-size: 13px; color: var(--mut); line-height: 1.6; margin-bottom: 12px; }
.helpbody b { color: var(--txt); }
.finalstat { display: flex; justify-content: center; gap: 14px; margin: 16px 0; }
.finalstat > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 86px; }
.finalstat span { display: block; font-size: 11px; color: var(--mut); margin-bottom: 4px; }
.finalstat b { font-size: 22px; color: var(--gold); }

@media (max-width: 380px) {
  .shopgrid { grid-template-columns: 1fr; }
  .panel h1 { font-size: 26px; }
}
