/* styles.css: how Saltfire's menus, HUD, cards and windows look. The voyage
   itself is drawn on the canvas by js/render.js. */

:root {
  --ink: #f4ecdc; --dim: #b9aec4; --bg: #140c1f; --panel: #22163a; --panel2: #2d1f4a; --line: #4a3670;
  --gold: #ffd23b; --red: #ff4a5a; --green: #4be06a; --blue: #46b8ff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: Nunito, system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 2px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 10px 16px; font-weight: 800; transition: transform .08s, background .15s, border-color .15s; }
button:hover:not(:disabled) { border-color: #8a6ac0; background: #3a2860; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: linear-gradient(#ffb03a, #e8641e); border-color: #ffd27a; color: #2a1200; }
button.primary:hover:not(:disabled) { background: linear-gradient(#ffc25a, #f07a2e); border-color: #fff0c0; }
button.danger { background: #6a1a28; border-color: #c43a4a; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, .logo-main, .choice-title, .banner b, .cine-name { font-family: 'Pirata One', Georgia, serif; font-weight: 400; letter-spacing: .02em; }
.hint { color: var(--dim); font-size: .92em; margin: .3em 0 .8em; }
small { display: block; color: var(--dim); }
.coin { display: inline-block; width: .95em; height: .95em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff4b0, #ffd23b 40%, #b8820e); vertical-align: -0.12em; margin-right: .3em; box-shadow: 0 0 0 1px #8a5a0a inset; }

/* Menus sit over the animated sea. */
#app { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#app:empty { pointer-events: none; }
.title-screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 16px calc(24px + var(--safe-b)); text-align: center; }
.logo { line-height: .9; }
.logo-main { filter: drop-shadow(0 5px 0 rgba(0,0,0,.45)); }
.logo-sub { text-shadow: 0 2px 0 rgba(0,0,0,.6); }
.logo-main { font-size: clamp(64px, 15vw, 132px); background: linear-gradient(#fff6c8, #ffb03a 45%, #e83a1e); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 2px #2a0a00; }
.logo-sub { font-weight: 900; letter-spacing: .4em; text-transform: uppercase; font-size: clamp(13px, 2.6vw, 18px); color: #ffe7c0; margin-top: 4px; }
.title-cap { display: flex; align-items: center; gap: 10px; background: rgba(20,10,30,.6); border: 2px solid var(--line); border-radius: 16px; padding: 6px 16px 6px 6px; text-align: left; }
.title-cap b { display: block; font-size: 1.1em; }
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(420px, 100%); }
.menu .big { grid-column: 1 / -1; font-size: 1.5em; padding: 14px; font-family: 'Pirata One', serif; font-weight: 400; letter-spacing: .06em; }
.menu button { background: rgba(34,22,58,.85); }
.menu button.primary { background: linear-gradient(#ffb03a, #e8641e); }
.gold-line { font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 #000; }
.gold-line.small { font-size: .95em; }
.who { color: #e9dcff; text-shadow: 0 1px 0 #000; }
.links { display: flex; gap: 18px; }
.links a { color: #ffe7c0; font-weight: 800; }

.page { min-height: 100%; background: linear-gradient(rgba(20,12,31,.92), rgba(20,12,31,.97)); }
.page-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(20,12,31,.96); border-bottom: 2px solid var(--line); }
.page-top h1 { margin: 0; flex: 1; font-size: 2em; color: #ffd27a; }
.page-body { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(40px + var(--safe-b)); }
.page-body h2 { color: #ffd27a; margin: 18px 0 4px; font-size: 1.7em; }
.back { padding: 8px 12px; }

.sail-cap { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 14px; padding: 8px 14px; border: 2px solid var(--line); }
.islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.island { text-align: left; padding: 10px; display: flex; flex-direction: column; gap: 4px; position: relative; background: var(--panel); }
.island .isl-art { width: 100%; height: auto; border-radius: 8px; }
.island b { font-size: 1.1em; }
.island .boss { color: #ff9a8a; }
.island.locked .isl-art { filter: grayscale(1) brightness(.4); }
.island.beaten { border-color: #4be06a; }
.tag { position: absolute; top: 14px; right: 14px; background: #4be06a; color: #062a10; font-weight: 900; font-size: .75em; padding: 2px 8px; border-radius: 99px; }

/* Captains. */
.cap-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.cap { padding: 6px 4px; display: flex; flex-direction: column; align-items: center; background: var(--panel); }
.cap small { font-size: .78em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--ink); }
.cap.on { border-color: var(--gold); background: #3a2860; }
.cap.chosen::after { content: '★'; position: absolute; margin-left: 52px; color: var(--gold); }
.cap.locked small { color: var(--dim); }
.cap-detail { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 14px; position: sticky; top: 76px; }
.cap-head { display: flex; gap: 12px; align-items: center; }
.cap-head h2 { margin: 0; }
.cap-title { color: #ffb03a; font-weight: 800; }
.cap-detail h3 { margin: 14px 0 6px; color: #ffd27a; }
.tier { color: var(--dim); font-weight: 400; font-size: .85em; }
.lvl { margin: 10px 0; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 8px 0; }
.stat { display: flex; justify-content: space-between; gap: 8px; background: rgba(0,0,0,.25); padding: 6px 10px; border-radius: 8px; }
.stat span { color: var(--dim); }
.stats.small .stat { font-size: .9em; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.ab-row { display: flex; gap: 10px; align-items: flex-start; background: rgba(0,0,0,.22); border-radius: 10px; padding: 6px 8px; margin: 4px 0; text-align: left; }
.ab-row b { display: block; }
.ab-row .lv { color: var(--gold); font-size: .85em; }
.ab-row canvas { flex: none; }

.bar { height: 10px; background: rgba(0,0,0,.45); border-radius: 99px; overflow: hidden; margin: 4px 0; border: 1px solid rgba(255,255,255,.12); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #46b8ff, #8a6aff); border-radius: 99px; }
.bar.boss i { background: linear-gradient(90deg, #ff3a3a, #ff8a3a); }

/* Shipyard. */
.ship-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.ship-row { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.ship-info { flex: 1; }
.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips i { width: 10px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); }
.pips i.on { background: var(--gold); }
.pips i.new { background: #fff; box-shadow: 0 0 6px #fff; }

/* Collection. */
.coll-count { max-width: 400px; font-weight: 800; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.tabs button { padding: 6px 12px; font-size: .9em; }
.tabs button.on { border-color: var(--gold); background: #3a2860; }
.coll-group h3 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 14px 0 6px; color: #ffd27a; }
.coll-group h3 small { display: inline; font-weight: 400; }
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.coll { padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--panel); }
.coll small { color: var(--ink); font-size: .75em; line-height: 1.1; text-align: center; }
.coll.unknown small { color: #5a6472; }
.missions { display: grid; gap: 8px; }
.mission { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px; position: relative; }
.mission.done { border-color: var(--green); }
.mission span { position: absolute; right: 12px; top: 10px; color: var(--green); font-weight: 900; }
.boss-list { display: flex; flex-wrap: wrap; gap: 6px; }
.boss-list span { background: var(--panel); padding: 4px 10px; border-radius: 99px; color: #5a6472; }
.boss-list span.done { color: var(--ink); border: 1px solid var(--green); }
.how p { max-width: 720px; line-height: 1.55; }
.settings { max-width: 640px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-weight: 800; font-size: 1.05em; }
.toggle input { width: 22px; height: 22px; accent-color: #ffb03a; }

/* Windows. */
#modal:empty { display: none; }
.shade { position: fixed; inset: 0; background: rgba(8,4,14,.72); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; overflow-y: auto; touch-action: pan-y; }
.window { background: linear-gradient(#2a1c46, #1c1230); border: 2px solid var(--line); border-radius: 18px; padding: 18px; max-width: min(980px, 100%); max-height: 100%; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.info { text-align: center; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.info h2 { margin: 6px 0 0; font-size: 1.8em; }
.rarity { color: var(--c); font-weight: 900; text-transform: uppercase; letter-spacing: .12em; font-size: .8em; }
.pause { max-width: 640px; }
.pause h2 { margin: 0 0 6px; font-size: 2em; text-align: center; }
.held { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px; }
.evo-hints { margin-top: 8px; }
.evo-hint { color: #ffb22e; }
.results { text-align: center; max-width: 520px; }
.results h2 { font-size: 2.6em; margin: 0; color: #ff9a8a; }
.results.win h2 { color: var(--gold); text-shadow: 0 0 20px rgba(255,210,59,.5); }
.results .actions { justify-content: center; }
.gold-text { color: var(--gold); font-weight: 800; }

/* Level-up cards. */
.choice { text-align: center; }
.choice-title { margin: 0; font-size: clamp(34px, 6vw, 52px); color: var(--gold); text-shadow: 0 3px 0 #6a3a00, 0 0 24px rgba(255,210,59,.4); }
.choice .hint { margin-top: 0; }
.cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.card { width: 230px; min-height: 290px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 12px 10px; border: 3px solid var(--c); background: linear-gradient(170deg, rgba(255,255,255,.06), rgba(0,0,0,.25)), #22163a; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 0 22px -6px var(--c); position: relative; animation: deal .25s ease-out backwards; }
.card:nth-child(2) { animation-delay: .06s; } .card:nth-child(3) { animation-delay: .12s; }
@keyframes deal { from { transform: translateY(30px) rotate(-3deg); opacity: 0; } }
.card:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--c); box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 0 32px -2px var(--c); background: linear-gradient(170deg, rgba(255,255,255,.1), rgba(0,0,0,.2)), #2d1f4a; }
.card-rarity { color: var(--c); font-weight: 900; font-size: .75em; letter-spacing: .14em; text-transform: uppercase; }
.card-name { font-family: 'Pirata One', serif; font-size: 1.55em; line-height: 1; }
.card-kind { color: var(--dim); font-size: .8em; }
.card-what { color: #9affb0; font-weight: 900; font-size: .95em; }
.card-desc { color: #e0d6ee; font-size: .88em; font-weight: 400; }
.card-key { position: absolute; top: 6px; left: 8px; color: var(--dim); font-size: .75em; }
.card.evo { background: linear-gradient(170deg, rgba(255,178,46,.25), rgba(0,0,0,.25)), #2a1a10; }
.card.secret { background: radial-gradient(circle at 50% 30%, rgba(255,79,163,.35), transparent 70%), #2a0f22; animation: deal .25s ease-out backwards, shimmer 1.2s infinite alternate; }
.card.r-divine { background: radial-gradient(circle at 50% 30%, rgba(255,242,168,.4), transparent 70%), #2a2410; }
@keyframes shimmer { to { box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 0 44px 4px var(--c); } }
.reroll { margin-top: 12px; }

/* The HUD during a voyage. */
#hud { position: fixed; inset: 0; pointer-events: none; padding: calc(6px + var(--safe-t)) 10px calc(8px + var(--safe-b)); }
.xpbar { position: relative; height: 18px; background: rgba(0,0,0,.6); border: 2px solid #1a0f28; border-radius: 99px; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2a9aff, #6ad0ff); box-shadow: 0 0 10px #46b8ff; transition: width .15s; }
.xpbar span { position: absolute; inset: 0; text-align: center; font-weight: 900; font-size: 13px; line-height: 14px; text-shadow: 0 1px 2px #000; }
.hud-row { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 6px; }
.hud-left { display: flex; gap: 14px; font-weight: 900; font-size: 18px; text-shadow: 0 2px 2px #000, 0 0 2px #000; }
#timer { font-size: 22px; color: #fff; }
#kills::before { content: '☠ '; color: #ff9a8a; }
#gold::before { content: '● '; color: var(--gold); }
.pause { pointer-events: auto; }
button.pause { padding: 6px 12px; background: rgba(20,10,30,.7); font-size: 14px; letter-spacing: -2px; }
.bossbar { width: min(560px, 92%); margin: 8px auto 0; text-align: center; }
.bossbar b { font-family: 'Pirata One', serif; font-weight: 400; font-size: 20px; color: #ffb0a0; text-shadow: 0 2px 2px #000; }
.bossbar .bar { height: 14px; border: 2px solid #1a0f28; }
.slots { position: fixed; left: 10px; bottom: calc(10px + var(--safe-b)); display: flex; flex-wrap: wrap; gap: 4px; max-width: min(460px, 70vw); }
.slot { background: rgba(10,6,18,.6); border-radius: 8px; padding: 2px; display: flex; flex-direction: column; align-items: center; }
.slot .pips { gap: 1px; margin-top: 1px; }
.slot .pips i { width: 5px; height: 3px; }

/* Touch joystick. */
#stick { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25); pointer-events: none; z-index: 5; }
#knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.6); }

/* Banners, cinematics and toasts. */
#banners { position: fixed; left: 0; right: 0; top: 26%; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 8; }
.banner { text-align: center; animation: slam .35s cubic-bezier(.2,1.6,.4,1); transition: opacity .6s, transform .6s; padding: 0 16px; }
.banner b { display: block; font-size: clamp(30px, 6vw, 56px); color: #fff; text-shadow: 0 3px 0 #000, 0 0 20px rgba(0,0,0,.8); }
.banner small { color: #ffe7c0; font-weight: 800; font-size: 1.05em; text-shadow: 0 2px 0 #000; }
.banner.boss b { color: #ff5a4a; }
.banner.gold b { color: var(--gold); }
.banner.r-mythical b { color: #ff7ac0; text-shadow: 0 3px 0 #4a0030, 0 0 30px #ff4fa3; }
.banner.r-divine b { color: #fff6c8; text-shadow: 0 3px 0 #6a4a00, 0 0 40px #ffe27a; }
.banner.out { opacity: 0; transform: translateY(-20px); }
@keyframes slam { from { transform: scale(2.2); opacity: 0; } }
.cine { position: fixed; inset: 0; pointer-events: none; z-index: 15; display: none; align-items: center; justify-content: center; }
.cine.show { display: flex; background: radial-gradient(circle, rgba(0,0,0,.3), rgba(0,0,0,.85)); animation: fadein .25s; }
.cine.r-mythical.show { background: radial-gradient(circle, rgba(255,79,163,.25), rgba(20,0,14,.92)); }
.cine.r-divine.show { background: radial-gradient(circle, rgba(255,242,168,.45), rgba(30,20,0,.92)); }
.cine-bars::before, .cine-bars::after { content: ''; position: fixed; left: 0; right: 0; height: 12vh; background: #000; animation: bars .3s ease-out; }
.cine-bars::before { top: 0; } .cine-bars::after { bottom: 0; }
@keyframes bars { from { height: 0; } }
@keyframes fadein { from { opacity: 0; } }
.cine-card { text-align: center; animation: slam .5s cubic-bezier(.2,1.6,.4,1); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 16px; }
.cine-card canvas { filter: drop-shadow(0 0 24px rgba(255,255,255,.6)); }
.cine-kind { font-weight: 900; letter-spacing: .4em; color: #ffb22e; }
.cine-card.r-mythical .cine-kind { color: #ff7ac0; }
.cine-card.r-divine .cine-kind { color: #fff2a8; }
.cine-name { font-size: clamp(40px, 9vw, 84px); line-height: 1; color: #fff; text-shadow: 0 4px 0 #000, 0 0 40px var(--c, #ffb22e); }
.cine-card.r-divine .cine-name { color: #fff6c8; text-shadow: 0 4px 0 #6a4a00, 0 0 50px #ffe27a; }
.cine-card.r-mythical .cine-name { color: #ffd0e8; text-shadow: 0 4px 0 #4a0030, 0 0 50px #ff4fa3; }
.cine-desc { color: #f4ecdc; font-weight: 800; max-width: 520px; }
#toasts { position: fixed; top: calc(70px + var(--safe-t)); right: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 30; pointer-events: none; align-items: flex-end; }
.toast { background: rgba(20,10,30,.9); border: 2px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 800; max-width: 300px; transition: opacity .5s, transform .5s; animation: fadein .2s; }
.toast.gold { border-color: var(--gold); }
.toast.warn { border-color: var(--red); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* Phones. */
@media (max-width: 760px) {
  .cap-wrap { grid-template-columns: 1fr; }
  .cap-detail { position: static; }
  .cap-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .card { width: 100%; min-height: 0; flex-direction: row; flex-wrap: wrap; text-align: left; align-items: center; padding: 8px 10px; gap: 2px 10px; }
  .card canvas { order: -1; width: 52px !important; height: 52px !important; }
  .card .card-name { flex: 1; font-size: 1.35em; }
  .card-rarity { width: 100%; order: -2; }
  .card-what, .card-desc, .card-kind { width: 100%; }
  .card .card-pips { width: 100%; }
  .card-key { display: none; }
  .cards { gap: 8px; }
  .window { padding: 12px; }
  .hud-left { gap: 10px; font-size: 15px; }
  #timer { font-size: 18px; }
  .ship-list { grid-template-columns: 1fr; }
  .slot canvas { width: 26px !important; height: 26px !important; }
  .page-top h1 { font-size: 1.5em; }
}
@media (max-height: 520px) {
  .title-screen { gap: 8px; padding-top: 10px; }
  .logo-main { font-size: 56px; }
  .title-cap { display: none; }
  .menu { grid-template-columns: repeat(3, 1fr); width: min(620px, 100%); }
}
