/* Euler's Cove — hand-drawn nautical parchment & deep-ocean cartography. */
:root {
  --navy: #0b253a;
  --navy-2: #133a57;
  --navy-3: #1d4f73;
  --parch: #fdf6e3;
  --parch-2: #f3e5c2;
  --parch-3: #e6d2a3;
  --ink: #3b2613;
  --ink-soft: #6b4b2a;
  --emerald: #15803d;
  --crimson: #b91c1c;
  --gold: #eab308;
  --gold-d: #a16207;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(3, 12, 20, 0.35);
  --font-title: 'Cinzel Decorative', 'Georgia', serif;
  --font-body: 'Crimson Pro', 'Georgia', serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--navy);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.katex { font-size: 1.08em; }
[hidden] { display: none !important; }

/* ---------- buttons & badges ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.5em 1.1em; font-family: var(--font-ui); font-weight: 600; font-size: 0.86rem;
  background: var(--parch); transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s;
  position: relative; white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 0 rgba(59, 38, 19, 0.25); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.5; }
.btn-gold { background: linear-gradient(#facc15, var(--gold)); color: #2a1a08; border-color: var(--gold-d); }
.btn-primary { background: var(--navy-2); color: var(--parch); border-color: var(--navy); }
.btn-ghost { background: transparent; }
.btn-ghost-dark { background: transparent; color: var(--parch); border-color: rgba(253, 246, 227, 0.6); }
.btn-danger { background: transparent; color: var(--crimson); border-color: var(--crimson); }
.btn.small { padding: 0.3em 0.75em; font-size: 0.78rem; }
.icon-btn { border: none; background: transparent; font-size: 1.3rem; padding: 0.25em 0.4em; border-radius: 8px; }
.icon-btn.dark { color: var(--parch); }
.icon-btn:hover { background: rgba(59, 38, 19, 0.1); }
.icon-btn.dark:hover { background: rgba(253, 246, 227, 0.12); }

.badge {
  display: inline-block; padding: 0.15em 0.65em; border-radius: 999px;
  font-family: var(--font-ui); font-size: 0.75rem; font-weight: 600;
  background: var(--navy-2); color: var(--parch);
}
.badge.ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--parch-3); }
.badge.gold { background: var(--gold); color: #2a1a08; }
.rank-badge {
  display: inline-block; padding: 0.1em 0.6em; border-radius: 6px;
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  background: linear-gradient(#facc15, var(--gold)); color: #2a1a08; border: 1px solid var(--gold-d);
}
.rank-badge.small { font-size: 0.66rem; }
.rank-badge:empty { display: none; }
.small-note { font-size: 0.85rem; color: var(--ink-soft); font-style: italic; }

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #071a2a, var(--navy));
  border-bottom: 3px solid var(--gold-d);
  color: var(--parch); z-index: 5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.hud-pirate { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-avatar {
  border: 2px solid var(--gold); border-radius: 50%; padding: 0; background: var(--parch);
  width: 54px; height: 54px; overflow: hidden; display: grid; place-items: center; flex-shrink: 0;
}
.hud-avatar svg { margin-top: 6px; }
.hud-id { display: flex; flex-direction: column; min-width: 0; }
.hud-name { font-family: var(--font-title); font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.hud-sub { display: flex; align-items: center; gap: 8px; }
.hud-progress { font-family: var(--font-ui); font-size: 0.72rem; opacity: 0.8; }
.ocean-jump { display: flex; gap: 4px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.ocean-jump::-webkit-scrollbar { display: none; }
.ocean-jump button {
  border: 1.5px solid rgba(253, 246, 227, 0.25); background: rgba(253, 246, 227, 0.06); color: var(--parch);
  border-radius: 999px; padding: 0.35em 0.85em; font-family: var(--font-ui); font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}
.ocean-jump button:hover { background: rgba(234, 179, 8, 0.2); border-color: var(--gold); }
.hud-actions { display: flex; align-items: center; gap: 8px; }
.notif {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--crimson); color: #fff; font-size: 0.7rem; display: grid; place-items: center; padding: 0 5px;
  border: 2px solid var(--navy); animation: bounce 1.4s infinite;
}

/* ---------- map ---------- */
.map-frame {
  flex: 1; min-height: 0; position: relative;
  padding: 12px;
  background:
    radial-gradient(ellipse at center, transparent 60%, rgba(59, 38, 19, 0.35)),
    linear-gradient(135deg, var(--parch-2), var(--parch-3));
}
.map-scroller {
  height: 100%; overflow: auto; border-radius: 10px;
  border: 4px double var(--ink);
  background: #0b253a;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}
.map { display: block; margin: 0 auto; height: auto; user-select: none; }
.map text { pointer-events: none; }
.map-title { font-family: var(--font-title); font-weight: 700; font-size: 38px; fill: var(--ink); }
.map-title.small { font-size: 26px; fill: var(--crimson); }
.map-compass-letter { font-family: var(--font-title); font-weight: 700; font-size: 18px; fill: var(--parch); paint-order: stroke; stroke: var(--ink); stroke-width: 3px; }
.ocean-title { font-family: var(--font-title); font-weight: 700; font-size: 19px; fill: var(--ink); }
.ocean-sub { font-family: var(--font-body); font-style: italic; font-size: 15px; fill: var(--ink-soft); }
.map-footer { font-family: var(--font-body); font-style: italic; font-size: 22px; fill: rgba(253, 246, 227, 0.55); }
.island { cursor: pointer; outline: none; }
/* Cinzel Decorative draws "1" like a Roman "I", so digits use the body face */
.island-num { font-family: var(--font-body); font-weight: 700; font-size: 21px; fill: var(--ink); }
.num { font-family: var(--font-body); font-weight: 700; }
.island-name { font-family: var(--font-title); font-weight: 700; font-size: 18px; fill: var(--parch); paint-order: stroke; stroke: #071a2a; stroke-width: 4.5px; stroke-linejoin: round; }
.island-topic { font-family: var(--font-body); font-style: italic; font-weight: 600; font-size: 14.5px; fill: #e0f2fe; paint-order: stroke; stroke: #071a2a; stroke-width: 3.5px; stroke-linejoin: round; }
.island.locked { filter: grayscale(0.85) brightness(0.8); opacity: 0.72; }
.island.unlocked:hover, .island.unlocked:focus-visible { filter: drop-shadow(0 0 10px rgba(234, 179, 8, 0.9)); }
.island.locked:hover { opacity: 0.85; }
.island .dock { cursor: pointer; }
.island .dock:hover circle:first-of-type, .island .dock:focus-visible circle:first-of-type { fill: var(--gold); }
.island.locked .dock { filter: none; }
.frontier-ring { animation: ring-spin 6s linear infinite; transform-box: fill-box; transform-origin: center; }
.player-ship { animation: bob 3s ease-in-out infinite; pointer-events: none; }
.monster { pointer-events: none; animation: bob 5s ease-in-out infinite; }
.monster .lure { animation: glow 2s ease-in-out infinite; }

.zoom-controls {
  position: absolute; right: 26px; bottom: 26px; display: flex; flex-direction: column;
  border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  background: var(--parch);
}
.zoom-controls button { border: none; background: transparent; width: 52px; height: 40px; font-family: var(--font-ui); font-weight: 700; font-size: 1.1rem; }
.zoom-controls button + button { border-top: 1px solid var(--parch-3); }
.zoom-controls button:hover { background: var(--parch-2); }
#zoom-level { font-size: 0.7rem; }

/* ---------- modals ---------- */
#modal-root { position: relative; z-index: 50; }
.modal-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(3, 12, 20, 0.66); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.16s ease;
}
.modal-backdrop.open { opacity: 1; }
.modal-backdrop.closing { opacity: 0; }
.parchment {
  background:
    radial-gradient(ellipse at top left, rgba(255, 255, 255, 0.6), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(161, 98, 7, 0.12), transparent 60%),
    linear-gradient(var(--parch), var(--parch-2));
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 5px var(--parch), inset 0 0 0 7px var(--parch-3), var(--shadow);
}
.modal {
  width: min(780px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  border-radius: var(--radius); padding: 18px 24px 22px;
  transform: translateY(10px) scale(0.98); transition: transform 0.16s ease;
}
.modal-backdrop.open .modal { transform: none; }
.training-modal { width: min(940px, 100%); }
.cabin-modal { width: min(980px, 100%); }
.accounts-modal { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-family: var(--font-title); font-size: 1.45rem; line-height: 1.2; }
.isl-num {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--gold); font-size: 0.85em; vertical-align: middle; margin-right: 4px;
  font-family: var(--font-body); font-weight: 700;
}
.modal h3 { font-family: var(--font-title); font-size: 1.05rem; margin: 0 0 8px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.modal-actions.end { justify-content: flex-end; }
.card {
  background: rgba(255, 255, 255, 0.45); border: 2px solid var(--parch-3); border-radius: 12px; padding: 14px 16px;
}
.isl-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* ---------- streak gems ---------- */
.streak-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 6px 0 4px; }
.streak-caption { margin: 0; font-size: 1rem; color: var(--ink-soft); }
.streak-gems { display: flex; align-items: center; gap: 2px; }
.gem-link { color: var(--parch-3); font-weight: 700; }
.gem .gem-body { fill: rgba(255, 255, 255, 0.55); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; transition: fill 0.2s; }
.gem .gem-facets { fill: none; stroke: rgba(59, 38, 19, 0.35); stroke-width: 1.2; }
.gem.lit .gem-body { fill: #10b981; filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.8)); }
.gem.lit .gem-facets { stroke: #065f46; }
.streak-gems.pop .gem.lit:last-of-type, .streak-gems.pop .gem.lit { animation: pop 0.45s ease both; animation-delay: var(--d); }
.streak-gems.shake { animation: shake 0.4s ease; }

/* ---------- questions ---------- */
.q-area { margin-top: 10px; }
.q-prompt { font-size: 1.3rem; line-height: 1.55; margin: 6px 0 10px; }
.q-visual-wrap { display: flex; justify-content: center; margin: 6px 0 12px; overflow-x: auto; }
.q-visual { max-width: 100%; height: auto; }
.q-visual.wide { width: 100%; max-width: 520px; }
.q-pair { display: flex; flex-wrap: wrap; gap: 14px 22px; justify-content: center; align-items: flex-end; }
.q-pair > div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--font-ui); font-size: 0.85rem; }
.q-table { border-collapse: collapse; font-size: 1.05rem; background: rgba(255, 255, 255, 0.5); }
.q-table th, .q-table td { border: 1.5px solid var(--ink-soft); padding: 4px 14px; text-align: left; }
.q-table th { font-family: var(--font-ui); font-size: 0.8rem; background: var(--parch-2); }
.answer-form { display: flex; gap: 10px; flex-wrap: wrap; }
.answer-input {
  flex: 1 1 220px; min-width: 0; font-family: var(--font-ui); font-size: 1.2rem; padding: 0.55em 0.8em;
  border: 2.5px solid var(--ink); border-radius: 10px; background: #fffdf6; color: var(--ink);
}
.answer-input:focus { outline: none; border-color: var(--gold-d); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.35); }
.answer-input:disabled { opacity: 0.7; }
.fire-btn { font-size: 1rem; }
.input-help { font-family: var(--font-ui); font-size: 0.74rem; color: var(--ink-soft); margin-top: 6px; }
.input-preview { font-family: var(--font-ui); font-size: 0.8rem; color: var(--navy-3); min-height: 1.1em; }
.q-invalid { color: var(--crimson); font-family: var(--font-ui); font-size: 0.85rem; min-height: 1.1em; margin-top: 4px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.choice-btn {
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fffdf6; padding: 0.7em 0.9em;
  font-size: 1.1rem; text-align: center; transition: transform 0.1s, background 0.15s;
}
.choice-btn:hover:not(:disabled) { background: #fff7d6; transform: translateY(-1px); }
.choice-btn.right { background: #dcfce7; border-color: var(--emerald); }
.choice-btn.wrong { background: #fee2e2; border-color: var(--crimson); }
.shake { animation: shake 0.4s ease; }

.feedback { margin-top: 12px; border-radius: 10px; }
.feedback:empty { display: none; }
.feedback.good, .feedback.bad, .feedback.info { padding: 10px 14px; border-left: 6px solid; }
.feedback.good { background: rgba(21, 128, 61, 0.09); border-color: var(--emerald); }
.feedback.bad { background: rgba(185, 28, 28, 0.08); border-color: var(--crimson); }
.feedback.info { background: rgba(19, 58, 87, 0.08); border-color: var(--navy-3); }
.feedback p { margin: 4px 0; }
.fb-title { font-weight: 700; font-size: 1.12rem; }
.feedback.good .fb-title { color: var(--emerald); }
.feedback.bad .fb-title { color: var(--crimson); }
.fb-sub { font-style: italic; color: var(--ink-soft); }
.fb-tip { font-size: 0.95rem; }
.steps { margin: 6px 0 4px; padding-left: 1.4em; line-height: 1.6; }
.steps li { margin: 3px 0; }
details summary { cursor: pointer; color: var(--navy-3); font-weight: 600; }
.train-btn.pulse { background: var(--gold); border-color: var(--gold-d); animation: pulse 1.2s ease-in-out infinite; }
.hint-box { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(234, 179, 8, 0.15); border: 1.5px dashed var(--gold-d); }

/* ---------- training ---------- */
.training-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; margin-bottom: 12px; }
.topic-line { margin: 0 0 6px; font-weight: 600; }
.formula { overflow-x: auto; padding: 4px 0; }
.video-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px;
  border: 2px solid var(--ink); border-radius: 12px; text-decoration: none; color: var(--ink); background: #fffdf6;
  transition: transform 0.12s, box-shadow 0.12s;
}
.video-link:hover { transform: translateY(-1px); box-shadow: 0 4px 0 rgba(59, 38, 19, 0.2); }
.video-link b { display: block; font-family: var(--font-ui); font-size: 0.9rem; }
.video-link small { display: block; color: var(--ink-soft); }
.vl-icon { font-size: 1.4rem; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; flex-shrink: 0; }
.khan .vl-icon { background: #14bf96; }
.oct .vl-icon { background: #dc2626; color: #fff; font-size: 1.1rem; }
.atlas-row { display: flex; gap: 14px; align-items: flex-start; }
.atlas-thumb {
  position: relative; flex: 0 0 132px; height: 164px; padding: 0; overflow: hidden; cursor: zoom-in;
  border: 2px solid var(--ink); border-radius: 10px; background: #fff; box-shadow: 0 3px 0 rgba(59, 38, 19, 0.2);
  transition: transform 0.12s;
}
.atlas-thumb:hover { transform: translateY(-2px) rotate(-1deg); }
.atlas-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.atlas-cta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px; text-align: center;
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700; background: rgba(11, 37, 58, 0.85); color: var(--parch);
}
.atlas-text { flex: 1; min-width: 0; }
.atlas-text p:last-child { margin-bottom: 0; }
.atlas-modal { width: min(820px, 100%); }
.atlas-full { border: 2px solid var(--parch-3); border-radius: 10px; overflow: hidden; background: #fff; }
.atlas-full img { width: 100%; height: auto; display: block; }

.tabs { display: flex; gap: 6px; margin: 4px 0 -2px 8px; position: relative; z-index: 1; }
.tab {
  font-family: var(--font-ui); font-weight: 700; font-size: 0.9rem; padding: 0.55em 1em; cursor: pointer;
  border: 2px solid var(--parch-3); border-bottom: none; border-radius: 12px 12px 0 0; background: var(--parch-2); color: var(--ink-soft);
}
.tab.active { background: #fbf3dc; color: var(--ink); border-color: var(--parch-3); }
.tab-best { font-weight: 600; color: var(--emerald); font-size: 0.8rem; }
.tabs + .card, .tabs ~ .card[data-panel] { border-top-left-radius: 0; }

.training-modal.tp-active .training-grid { display: none; }
.tp-intro p { margin: 6px 0; }
.tp-bestline { font-family: var(--font-ui); font-size: 0.88rem; color: var(--emerald); }
.tp-timer { display: block; margin: 10px 0 2px; font-weight: 600; cursor: pointer; }
.tp-timer input { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; accent-color: var(--gold-d); }
.tp-hud { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-family: var(--font-ui); font-weight: 700; font-size: 0.9rem; }
.tp-score { color: var(--gold-d); }
.tp-combo { color: var(--ink-soft); }
.tp-combo.hot { color: var(--crimson); animation: pop 0.35s ease; }
.tp-fuse { height: 8px; border-radius: 6px; background: rgba(59, 38, 19, 0.12); margin: 8px 0 4px; overflow: hidden; }
.tp-fuse-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #dc2626, #f59e0b, #facc15); }
.tp-volley { margin: 10px 0 2px; padding: 8px 12px; border-radius: 10px; background: rgba(19, 58, 87, 0.07); border: 1.5px solid var(--navy-3); }
.tp-stem { font-size: 1.15rem; }
.tp-vtag { font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--navy-3); margin-right: 6px; }
.tp-work { font-size: 1rem; margin-top: 4px; }
.tp-work:empty { display: none; }
.tp-kind { font-family: var(--font-ui); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin-top: 10px; }
.tp-hidden { padding: 24px; font-size: 1.1rem; font-weight: 600; color: var(--ink-soft); border: 2px dashed var(--parch-3); border-radius: 12px; }
.tp-results h3 { margin-bottom: 10px; }
.tp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.tp-stats div { text-align: center; padding: 10px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.6); border: 2px solid var(--parch-3); }
.tp-stats span { display: block; font-size: 1.8rem; font-weight: 700; }
.tp-stats small { font-family: var(--font-ui); font-size: 0.75rem; color: var(--ink-soft); }
.tp-review { padding-left: 1.4em; }
.tp-review li { margin: 0 0 10px; }
.tp-review-stem { font-size: 0.9rem; color: var(--navy-3); }
.tp-review-ans { margin-top: 2px; }
.practice-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.practice-count { font-family: var(--font-ui); font-size: 0.8rem; font-weight: 600; color: var(--emerald); }

/* ---------- loot ---------- */
.loot-modal { text-align: center; overflow: hidden; position: relative; }
.loot-stage { display: flex; justify-content: center; margin: 4px 0; }
.chest-lid { transform-box: fill-box; transform-origin: 50% 100%; animation: lid-open 0.7s 0.35s cubic-bezier(0.3, 1.6, 0.6, 1) both; }
.chest-glow { opacity: 0; animation: fade-in 0.5s 0.6s ease both; }
.rank-up { font-family: var(--font-title); font-size: 1.2rem; margin: 6px 0 10px; color: var(--crimson); animation: pop 0.5s 0.8s ease both; }
.rank-up.quiet { color: var(--ink-soft); font-size: 1rem; }
.reward-card {
  display: flex; align-items: center; gap: 18px; text-align: left; margin: 0 auto; max-width: 560px;
  background: rgba(255, 255, 255, 0.55); border: 2px solid var(--gold-d); border-radius: 14px; padding: 12px 16px;
  animation: rise 0.5s 0.9s ease both;
}
.reward-card h3 { margin: 0 0 4px; font-size: 1.25rem; }
.reward-card p { margin: 0 0 6px; }
.reward-kicker { font-family: var(--font-ui); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold-d); }
.reward-art { flex-shrink: 0; }
.trophy-big { font-size: 4rem; width: 120px; text-align: center; }
.unlock-note { margin-top: 12px; }
.final-msg { font-size: 1.2rem; font-weight: 600; }
.coin-rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.coin { position: absolute; top: -40px; left: var(--x); font-size: 1.4rem; animation: fall 1.8s var(--d) ease-in both; }

/* ---------- cabin ---------- */
.cabin-grid { display: grid; grid-template-columns: 260px 1fr; gap: 14px; }
.cabin-preview { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cabin-name { margin: 4px 0 0 !important; }
.cabin-rank { margin: 0; }
.slot-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.slot-tab {
  border: 2px solid var(--parch-3); background: #fffdf6; border-radius: 999px; padding: 0.3em 0.8em;
  font-family: var(--font-ui); font-size: 0.78rem; font-weight: 600;
}
.slot-tab[aria-selected='true'] { background: var(--navy-2); color: var(--parch); border-color: var(--navy); }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.item-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px;
  border: 2px solid var(--parch-3); border-radius: 12px; background: #fffdf6; text-align: center;
  transition: transform 0.12s, border-color 0.12s;
}
.item-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--gold-d); }
.item-card.equipped { border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.25); }
.item-card.fresh { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.4); }
.item-card.locked .item-art { filter: brightness(0) opacity(0.25); }
.item-art { height: 96px; overflow: hidden; display: flex; align-items: flex-start; justify-content: center; }
.item-name { font-family: var(--font-ui); font-size: 0.76rem; font-weight: 700; line-height: 1.2; }
.item-status { font-family: var(--font-ui); font-size: 0.68rem; color: var(--ink-soft); }
.item-card.equipped .item-status { color: var(--emerald); font-weight: 700; }
.trophy-shelf { margin-top: 12px; }
.trophies {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px;
  padding: 10px; border-bottom: 10px solid #7c4a1e; border-radius: 4px;
  background: linear-gradient(transparent 85%, rgba(124, 74, 30, 0.25));
}
.trophy { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.trophy-icon { font-size: 2.2rem; line-height: 1.2; }
.trophy.missing .trophy-icon { font-family: var(--font-title); color: var(--parch-3); }
.trophy-name { font-family: var(--font-ui); font-size: 0.66rem; font-weight: 600; }
.trophy.fresh .trophy-icon { animation: pop 0.6s ease 2; }

/* ---------- accounts ---------- */
.intro { font-size: 1.1rem; }
.crew-cards { display: grid; gap: 10px; margin-bottom: 14px; }
.crew-card {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  border: 2px solid var(--parch-3); border-radius: 12px; padding: 8px 12px; background: rgba(255, 255, 255, 0.5);
  transition: border-color 0.12s, transform 0.12s;
}
.crew-card:hover { border-color: var(--gold-d); transform: translateY(-1px); }
.crew-card.active { border-color: var(--gold-d); background: rgba(234, 179, 8, 0.12); }
.crew-pick {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  border: none; background: transparent; padding: 0; text-align: left; min-width: 0;
}
.show-recruit { margin-bottom: 12px; }
.save-note { margin: 4px 0 0; }
.crew-avatar { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); display: grid; place-items: start center; background: var(--parch); }
.crew-avatar svg { margin-top: 4px; }
.crew-info { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.crew-info b { font-family: var(--font-title); font-size: 1.05rem; }
.crew-info small { font-family: var(--font-ui); font-size: 0.72rem; color: var(--ink-soft); }
.crew-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.code-box { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.code-box textarea, .import-text {
  width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.72rem; padding: 8px;
  border: 2px solid var(--parch-3); border-radius: 8px; background: #fffdf6; resize: vertical; word-break: break-all;
}
.recruit, .import { margin-bottom: 12px; }
.recruit-form { display: grid; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .look span { font-family: var(--font-ui); font-size: 0.78rem; font-weight: 700; }
.field input {
  font-family: var(--font-ui); font-size: 1rem; padding: 0.5em 0.7em; border: 2px solid var(--ink); border-radius: 10px; background: #fffdf6;
}
.harbors { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.harbor-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px;
  border: 2px solid var(--parch-3); border-radius: 10px; background: #fffdf6;
}
.harbor-card b { font-family: var(--font-title); font-size: 0.9rem; }
.harbor-card small { font-family: var(--font-ui); font-size: 0.7rem; color: var(--ink-soft); }
.harbor-card.sel { border-color: var(--gold-d); background: rgba(234, 179, 8, 0.18); }
.look { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 18px; }
.swatches { display: flex; gap: 6px; margin-top: 4px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); }
.swatch.sel { box-shadow: 0 0 0 3px var(--parch), 0 0 0 6px var(--gold-d); }
.recruit-preview { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); margin-left: auto; display: grid; place-items: start center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); z-index: 100;
  background: var(--navy); color: var(--parch); border: 2px solid var(--gold); border-radius: 12px;
  padding: 10px 18px; font-family: var(--font-ui); font-size: 0.9rem; max-width: min(92vw, 560px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: #22c55e; }
.toast.bad { border-color: #ef4444; }
.noscript { color: var(--parch); text-align: center; padding: 2rem; }

/* ---------- animations ---------- */
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7); } 50% { box-shadow: 0 0 0 10px rgba(234, 179, 8, 0); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes lid-open { from { transform: rotate(0) translateY(0); } to { transform: rotate(-24deg) translateY(-18px); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(560px) rotate(var(--r)); opacity: 0; } }
/* SVG groups positioned with a transform attribute must not get CSS transforms */
.player-ship, .monster { animation-name: bob-svg; }
@keyframes bob-svg { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .hud-actions .btn span:not(.notif), .ocean-jump button span { display: none; }
  .ocean-jump button { padding: 0.35em 0.6em; font-size: 1rem; }
}
@media (max-width: 760px) {
  body { font-size: 17px; }
  .hud { gap: 8px; padding: 6px 10px; }
  .ocean-jump { order: 3; width: 100%; justify-content: center; margin: 0; }
  .hud-actions { margin-left: auto; }
  .hud-name { max-width: 140px; font-size: 0.95rem; }
  .training-grid, .cabin-grid { grid-template-columns: 1fr; }
  .atlas-thumb { flex-basis: 96px; height: 120px; }
  .tp-stats span { font-size: 1.4rem; }
  .modal { padding: 14px 14px 18px; }
  .modal-head h2 { font-size: 1.15rem; }
  .q-prompt { font-size: 1.15rem; }
  .reward-card { flex-direction: column; text-align: center; }
  .crew-pick { grid-template-columns: auto 1fr; }
  .crew-pick > .btn { grid-column: 1 / -1; justify-self: start; }
  .zoom-controls { right: 18px; bottom: 18px; }
  .map-frame { padding: 6px; }
}

/* ---------- Hardcore voyage ---------- */
.hardcore-warn { margin: 4px 0 8px; padding: 6px 10px; border-radius: 8px; font-family: var(--font-ui); font-size: 0.85rem; background: rgba(127, 29, 29, 0.1); border: 1.5px dashed #991b1b; color: #7f1d1d; }
.wreck-banner { margin-bottom: 10px; padding: 8px 12px; border-radius: 10px; background: #1f1410; color: #fde68a; border: 2px solid #991b1b; }
.wreck-banner .fb-title { color: #fca5a5; }
.hardcore-toggle { display: flex; gap: 8px; align-items: flex-start; font-family: var(--font-ui); font-size: 0.85rem; cursor: pointer; margin-top: 8px; }
.hardcore-toggle input { margin-top: 2px; accent-color: #991b1b; }

/* ---------- picture-first questions & read-aloud ---------- */
.say-btn { float: right; margin: 0 0 6px 10px; font-size: 1.5rem; line-height: 1; padding: 6px 10px; border-radius: 999px; border: 2px solid var(--parch-3); background: #fff7d6; cursor: pointer; }
.say-btn:hover { background: #fde68a; }
.big-num { display: inline-block; min-width: 1.4em; font-family: var(--font-title); font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.big-eq { display: inline-block; font-family: var(--font-title); font-size: 2.2rem; font-weight: 700; letter-spacing: 0.04em; }
.q-prompt .big-num { font-size: 2.8rem; vertical-align: middle; }
.choice-btn .q-visual { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.choice-btn .q-group { max-height: 90px; }
.before-after { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.before-after .q-visual { max-height: 90px; width: auto; }
.ba-arrow { font-size: 2rem; }

/* ---------- bonus islands & ULTRA RARE loot ---------- */
@keyframes ultra-shift { from { background-position: 0% 50%; } to { background-position: 200% 50%; } }
.ultra-tag { margin: 0 0 4px; font-family: var(--font-ui); font-weight: 800; letter-spacing: 0.12em; font-size: 0.8rem; background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7, #ef4444); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: ultra-shift 3s linear infinite; }
.ultra-tag.small { display: block; font-size: 0.62rem; margin: 2px 0 0; }
.item-card.ultra, .reward-card.ultra { position: relative; border: 3px solid transparent; background: linear-gradient(#fffbeb, #fffbeb) padding-box, linear-gradient(90deg, #ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7, #ef4444) border-box; background-size: 100% 100%, 200% 100%; animation: ultra-shift 4s linear infinite; box-shadow: 0 0 14px rgba(168, 85, 247, 0.35); }
.item-card.ultra.locked { filter: saturate(0.5); }
.badge.ultra-badge { background: linear-gradient(90deg, #a855f7, #3b82f6); color: #fff; }
.bonus-note { margin: 4px 0 8px; padding: 6px 10px; border-radius: 8px; font-family: var(--font-ui); font-size: 0.85rem; background: rgba(168, 85, 247, 0.1); border: 1.5px dashed #7c3aed; color: #4c1d95; }
.map .bonus-island .bonus-glow { animation: bonus-pulse 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes bonus-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.big-emoji { display: inline-block; font-size: 2.2rem; line-height: 1.15; }
.emoji-row { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
