:root {
  --paper: #fff4dc;
  --paper2: #f6e3bd;
  --ink: #3b2412;
  --wood: #5a3a1e;
  --gold: #f2c14e;
  --red: #e2533a;
  --blue: #3fa7d6;
  --green: #4cd964;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d2b45; font-family: 'Jua', 'Malgun Gothic', sans-serif; color: var(--ink); user-select: none; }
#game { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; display: block; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.hidden { display: none !important; }
.small { font-size: 13px; opacity: .85; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.panel { position: absolute; background: var(--paper); border: 3px solid var(--wood); border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
#hud-left { position: absolute; top: 14px; left: 14px; width: 270px; display: flex; flex-direction: column; gap: 8px; }
#hud-left > .panel { position: static; }
#hud-left { transition: opacity .4s; }
#hud-left.faded { opacity: .35; }
.badge { background: var(--red); color: #fff; border-radius: 8px; padding: 1px 8px; font-size: 16px; }
.cap-name { font-size: 18px; flex: 1; }
.res { margin-top: 6px; font-size: 15px; }
.bar { position: relative; height: 16px; background: #3b1f10; border-radius: 8px; overflow: hidden; margin-top: 6px; border: 2px solid var(--wood); }
.bar > div { height: 100%; transition: width .15s; }
.bar > span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 13px; color: #fff; text-shadow: 0 1px 2px #000; }
.bar.xp > div { background: linear-gradient(#9be7ff, #3fa7d6); }
.bar.hp > div { background: linear-gradient(#7dff9a, #2fb350); }
.bar.wind { height: 12px; }
.bar.wind > span { line-height: 9px; font-size: 10px; }
.bar.wind > div { background: linear-gradient(#ffffff, #b9e8ff); transition: none; }
.bar.big { height: 22px; }
#hud-ship b { font-size: 17px; }
#hud-ship .small { font-size: 12px; text-align: right; }
#hud-equip { font-size: 14px; line-height: 1.45; }
#hud-equip .eq-title { font-size: 13px; opacity: .7; margin: 2px 0 1px; }
#hud-equip .eq-title:first-child { margin-top: 0; }
#hud-equip .eq-row { display: flex; justify-content: space-between; gap: 8px; }
#hud-equip .eq-row span { opacity: .75; white-space: nowrap; }
#hud-equip .eq-row b { text-align: right; }
#hud-equip .eq-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; }
#hud-quest { top: 14px; right: 14px; width: 230px; line-height: 1.5; }
#hud-quest .q-title { font-size: 15px; opacity: 1; margin-bottom: 2px; }
#hud-quest .done { text-decoration: line-through; opacity: .55; }
#hud-quest .q-sub { margin-top: 4px; }
#minimap { position: absolute; right: 14px; bottom: 14px; width: 200px; height: 200px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.3)); }
#hud-cannons { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 16px; }
.cannon-side { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; text-shadow: 0 2px 2px #000; font-size: 14px; }
.cannon-side .cd { width: 54px; height: 54px; border-radius: 50%; background: rgba(30,20,10,.75); border: 3px solid var(--paper); position: relative; overflow: hidden; }
.cannon-side .cd::after { content: '💣'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; }
.ult-orb { width: 54px; height: 54px; border-radius: 50%; background: rgba(10,30,50,.75); border: 3px solid #5a6b78; position: relative; display: grid; place-items: center; opacity: .85; }
.ult-orb::before { content: '✨'; font-size: 26px; position: relative; z-index: 1; }
.ult-gauge { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
#ult-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, #3f5bd6, #7ef0ff); opacity: .85; transition: height .3s; }
.ult-orb b { position: absolute; right: -6px; bottom: -6px; min-width: 22px; height: 22px; border-radius: 11px; background: #333; color: #fff; font-size: 13px; display: grid; place-items: center; border: 2px solid #fff; }
#ult-slot.ready .ult-orb { filter: none; opacity: 1; border-color: #7ef0ff; background: radial-gradient(circle, #9be7ff, #3f5bd6 60%, #141a4a); animation: ultGlow 1.2s ease-in-out infinite; }
#ult-slot.ready .ult-orb b { background: #ff9f1c; }
#ult-slot.ready span { color: #9be7ff; }
@keyframes ultGlow { 0%,100% { box-shadow: 0 0 6px 2px rgba(126,240,255,.5); } 50% { box-shadow: 0 0 18px 7px rgba(126,240,255,.95); } }
.cannon-side .fill { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(242,193,78,.85); }
.speed { background: var(--paper); border: 3px solid var(--wood); border-radius: 12px; padding: 4px 14px; text-align: center; display: flex; flex-direction: column; line-height: 1.1; margin-bottom: 18px; }
.speed b { font-size: 22px; }
.speed span { font-size: 11px; }
#charge { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: 260px; text-align: center; color: #fff; text-shadow: 0 2px 3px #000; font-size: 15px; }
.charge-track { position: relative; height: 14px; background: rgba(20,20,40,.75); border: 3px solid var(--paper); border-radius: 9px; overflow: hidden; margin-bottom: 3px; }
#charge-fill { height: 100%; background: linear-gradient(90deg, #bfefff, #7ef0ff); }
.charge-track .mark.half { position: absolute; top: 0; bottom: 0; left: 42%; width: 2px; background: rgba(255,255,255,.8); }
#charge.lv1 #charge-fill { background: linear-gradient(90deg, #7ef0ff, #3fa7d6); }
#charge.lv2 #charge-fill { background: linear-gradient(90deg, #ffe066, #ff9f1c); animation: chargeFlash .12s steps(2) infinite; }
#charge.lv2 { color: #ffe066; }
@keyframes chargeFlash { 50% { filter: brightness(1.8); } }
#prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--paper); border: 3px solid var(--wood); border-radius: 12px; padding: 8px 18px; font-size: 18px; box-shadow: 0 4px 0 rgba(0,0,0,.25); animation: bob 1s ease-in-out infinite; white-space: nowrap; }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }
#hud-help { position: absolute; left: 14px; bottom: 10px; color: #fff; font-size: 13px; text-shadow: 0 1px 3px #000; opacity: .85; }
#boss-bar { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); width: min(560px, 60vw); text-align: center; color: #fff; text-shadow: 0 2px 3px #000; font-size: 20px; }
.boss-track { height: 16px; background: rgba(20,0,20,.8); border: 3px solid #f5d76e; border-radius: 10px; overflow: hidden; margin-top: 4px; }
#boss-fill { height: 100%; background: linear-gradient(#d78bff, #8e44ad); transition: width .2s; }

/* ---------- 알림 ---------- */
#toasts { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 6; pointer-events: none; }
.toast { background: rgba(255,244,220,.96); border: 2px solid var(--wood); border-radius: 10px; padding: 6px 14px; font-size: 15px; animation: tin .25s ease-out; transition: opacity .5s, transform .5s; max-width: 80vw; text-align: center; }
.toast.warn { background: #ffe1d6; border-color: #b23a1e; }
.toast.good { background: #e6ffd9; border-color: #3c8d2f; }
.toast.zone { background: #dff2ff; border-color: #1f5f8b; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes tin { from { opacity: 0; transform: translateY(-10px); } }
#banner { position: absolute; top: 32%; left: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 7; pointer-events: none; }
#banner.show { animation: bannerIn 3.2s ease-out forwards; }
.b-title { font-size: 52px; color: var(--gold); -webkit-text-stroke: 2px #3b2412; text-shadow: 0 5px 0 #3b2412; white-space: nowrap; }
.b-sub { font-size: 20px; color: #fff; text-shadow: 0 2px 4px #000; margin-top: 8px; }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 16% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- 모달 ---------- */
#modal { position: absolute; inset: 0; background: rgba(5,20,35,.55); display: grid; place-items: center; z-index: 10; }
#modal-box { background: var(--paper); border: 4px solid var(--wood); border-radius: 18px; padding: 18px 22px; width: min(520px, 92vw); max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 0 rgba(0,0,0,.35); animation: pop .18s ease-out; }
#modal-box.wide { width: min(900px, 94vw); }
#modal-box.map { width: auto; text-align: center; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
#modal-box h2 { margin: 0 0 10px; font-weight: normal; font-size: 28px; }
#modal-box h3 { margin: 14px 0 6px; font-weight: normal; font-size: 19px; border-bottom: 2px dashed #d9bf8f; padding-bottom: 3px; }
#modal-box ul { margin: 6px 0; padding-left: 20px; line-height: 1.6; }
.dlg-body p { margin: 6px 0; line-height: 1.5; }
.dlg-btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.btn { font-family: inherit; font-size: 16px; color: var(--ink); background: linear-gradient(#ffe9a8, var(--gold)); border: 3px solid var(--wood); border-radius: 12px; padding: 7px 16px; cursor: pointer; box-shadow: 0 3px 0 var(--wood); transition: transform .06s; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood); }
.btn:disabled { filter: grayscale(1) opacity(.55); cursor: not-allowed; }
.btn.big { font-size: 20px; padding: 10px 26px; }
.btn.sm { font-size: 14px; padding: 4px 12px; }
.btn.danger { background: linear-gradient(#ffb4a2, #e2533a); color: #fff; }
.btn.good { background: linear-gradient(#c8ffb0, #5cc14a); }
.menu-col { display: flex; flex-direction: column; gap: 8px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin-top: 14px; font-size: 14px; }
.port-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gold-big { font-size: 24px; background: #3b2412; color: var(--gold); padding: 4px 14px; border-radius: 10px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tab { font-family: inherit; font-size: 16px; background: var(--paper2); border: 3px solid var(--wood); border-radius: 10px 10px 4px 4px; padding: 6px 14px; cursor: pointer; color: var(--ink); }
.tab.on { background: var(--wood); color: var(--paper); }
.tab-body { min-height: 260px; }
.shop-row, .item-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.55); margin-bottom: 6px; border: 2px solid transparent; }
.shop-row.equipped, .item-row.equipped { border-color: var(--gold); background: #fff8d8; }
.shop-row > div:last-child, .item-row > *:last-child { flex-shrink: 0; }
.tag { display: inline-block; background: #8e44ad; color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.tag.eq { background: var(--green); color: #123; }
.tag.lock { background: #7a6a5a; }
.pips { color: #c98a00; letter-spacing: 2px; }
.stat-card { background: rgba(255,255,255,.6); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; line-height: 1.7; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.item-list { max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.loot-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.loot { background: rgba(255,255,255,.7); border-radius: 8px; padding: 2px 8px; font-size: 14px; }
.roulette { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.slot-grid { display: grid; grid-template-columns: repeat(3, 64px); gap: 6px; background: #3b2412; padding: 10px; border-radius: 14px; border: 3px solid var(--gold); box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.slot-grid div { width: 64px; height: 64px; display: grid; place-items: center; font-size: 34px; background: var(--paper); border-radius: 10px; }
.slot-grid div.spin { filter: blur(1px); opacity: .75; }
.slot-grid div.win { background: #fff1a8; box-shadow: 0 0 0 3px var(--gold), 0 0 14px #ffe066; animation: winPulse .45s ease-in-out infinite alternate; }
@keyframes winPulse { to { transform: scale(1.08); } }
.slot-side { flex: 1; min-width: 240px; }
#slot-msg { font-size: 17px; margin-bottom: 8px; min-height: 24px; }
#slot-msg.win { color: #b8600a; }
.odds { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0 6px; }
.odds td { padding: 3px 6px; border-bottom: 1px dashed #d9bf8f; }
.odds td:first-child { white-space: nowrap; }
.odds td:last-child { text-align: right; white-space: nowrap; }
#bigmap { border: 4px solid var(--wood); border-radius: 12px; max-width: 80vh; width: 100%; }
.map-legend { font-size: 13px; margin-top: 6px; }

/* ---------- 보물 인양 ---------- */
#salvage { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; pointer-events: none; }
.sv-box { background: var(--paper); border: 4px solid var(--wood); border-radius: 18px; padding: 14px 18px; box-shadow: 0 8px 0 rgba(0,0,0,.35); animation: pop .18s ease-out; }
.sv-title { font-size: 24px; text-align: center; margin-bottom: 10px; }
.sv-main { display: flex; gap: 12px; align-items: stretch; }
.sv-track { position: relative; width: 56px; height: 300px; background: linear-gradient(#1b78b8, #0b3a66); border: 4px solid var(--wood); border-radius: 12px; overflow: hidden; }
#sv-zone { position: absolute; left: 3px; right: 3px; background: rgba(120,220,120,.45); border: 3px solid #4cd964; border-radius: 8px; }
#sv-zone.on { background: rgba(140,255,140,.7); box-shadow: 0 0 12px #7dff9a; }
#sv-fish { position: absolute; left: 0; right: 0; height: 28px; line-height: 28px; text-align: center; font-size: 24px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
.sv-meter { position: relative; width: 14px; background: #3b1f10; border: 3px solid var(--wood); border-radius: 8px; overflow: hidden; }
#sv-rate-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(#ffe066, #ff9f1c); transition: height .1s; }
.sv-info { width: 230px; display: flex; flex-direction: column; gap: 6px; }
#sv-grade { font-size: 26px; min-height: 32px; -webkit-text-stroke: 1px #3b2412; }
#sv-rate { font-size: 18px; }
.sv-time { height: 10px; background: #3b1f10; border-radius: 6px; overflow: hidden; }
#sv-time-fill { height: 100%; background: linear-gradient(90deg, #9be7ff, #3fa7d6); }
#sv-grades { font-size: 14px; line-height: 1.6; margin-top: 4px; border-top: 2px dashed #d9bf8f; padding-top: 4px; }
#salvage.done #sv-grade { animation: svPop .5s ease-in-out infinite alternate; }
@keyframes svPop { to { transform: scale(1.08); } }

/* ---------- 일기토 ---------- */
#duel-overlay { position: absolute; inset: 0; z-index: 8; background: #1a6aa6; }
#duel-canvas { display: block; cursor: crosshair; }

/* ---------- 타이틀 ---------- */
#title-screen { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(10,40,70,.15), rgba(5,20,40,.6)); }
.title-box { text-align: center; }
.title-logo { font-size: clamp(40px, 7vw, 84px); color: var(--gold); -webkit-text-stroke: 3px #3b2412; text-shadow: 0 7px 0 #3b2412; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-1deg); } }
.title-sub { color: #fff; font-size: 22px; text-shadow: 0 2px 4px #000; margin: 10px 0 28px; }
.title-btns { display: flex; gap: 14px; justify-content: center; }
.title-help { margin: 30px auto 0; background: rgba(255,244,220,.92); border: 3px solid var(--wood); border-radius: 14px; padding: 12px 18px; line-height: 1.8; font-size: 15px; text-align: left; max-width: 640px; }

/* ---------- 함대 ---------- */
.ship-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ship-card { background: rgba(255,255,255,.65); border: 3px solid #d9bf8f; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.ship-card.current { border-color: var(--gold); background: #fff8d8; box-shadow: 0 0 0 3px rgba(242,193,78,.35); }
.ship-card.locked { opacity: .55; filter: grayscale(.6); }
.ship-card.compact { margin-top: 8px; }
.sc-head { display: flex; align-items: center; gap: 6px; font-size: 18px; }
.sc-head b { flex: 1; font-weight: normal; }
.sbars { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.sbar { display: grid; grid-template-columns: 34px 1fr 48px; align-items: center; gap: 6px; font-size: 13px; }
.sbar > div { height: 9px; background: #e6d3ad; border-radius: 5px; overflow: hidden; }
.sbar i { display: block; height: 100%; background: linear-gradient(90deg, #3fa7d6, #4cd964); border-radius: 5px; }
.sbar b { font-weight: normal; text-align: right; }
.sc-foot { margin-top: 6px; text-align: right; min-height: 4px; }
