:root {
  --sea: #0b3954;
  --sea-light: #087e8b;
  --foam: #e6f2f1;
  --parchment: #f6efdf;
  --paper: #fffdf7;
  --ink: #2b2118;
  --muted: #7d705e;
  --line: #e4d9c3;
  --gold: #f2b134;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(43, 33, 24, 0.08), 0 4px 14px rgba(43, 33, 24, 0.07);
  --display: 'Pirata One', Georgia, serif;
  /* per-expedition sea (overridden inline) */
  --sea-from: var(--sea);
  --sea-to: var(--sea-light);
  --accent: var(--gold);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  background: var(--parchment);
  color: var(--ink);
}
body.voyage-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
h2, h3 { margin: 0; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.82rem; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---------- Buttons & fields ---------- */

.btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn.primary { background: var(--gold); border-color: transparent; color: var(--ink); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger:hover { box-shadow: none; text-decoration: underline; }
.btn.big { padding: 12px 20px; font-size: 1rem; }

.icon-btn {
  padding: 4px 7px;
  border: none;
  border-radius: 8px;
  background: transparent;
  opacity: 0.55;
  cursor: pointer;
}
.icon-btn:hover { opacity: 1; background: var(--foam); }
.icon-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.icon-btn.light { color: #fff; opacity: 0.8; font-size: 1.1rem; }
.icon-btn.light:hover { background: rgba(255, 255, 255, 0.15); }

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--sea-light);
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.mini-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.mini-btn:hover:not(:disabled) { background: var(--foam); }
.mini-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mini-btn.danger { color: var(--danger); }

label, legend {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
label input, label select, label textarea, .search {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--sea-light); outline-offset: 1px; }
.field-hint { font-weight: 400; letter-spacing: normal; text-transform: none; }
fieldset { margin: 0; padding: 0; border: none; min-width: 0; }
legend { margin-bottom: 6px; }
.legend-hint { display: inline; font-weight: 400; letter-spacing: normal; text-transform: none; }
.stack { display: grid; gap: 12px; }

/* ---------- Avatars ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--av, var(--muted));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
}
.avatars { display: inline-flex; align-items: center; }
.avatars .avatar + .avatar { margin-left: -7px; }
.avatar.more { background: var(--line); color: var(--ink); }

/* ---------- Login ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
  background: linear-gradient(160deg, var(--sea) 0%, #0e4d6e 60%, var(--sea-light) 100%);
}
.auth-card {
  width: min(400px, 100%);
  padding: 28px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: pop 0.3s ease-out;
}
.auth-brand { color: var(--sea); font-family: var(--display); font-size: 2.2rem; }
.auth-card h2 { margin: 8px 0 4px; font-size: 1.3rem; }
.auth-card form { margin: 18px 0 10px; }
.auth-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 0.88rem; font-weight: 600; }

/* ---------- Header ---------- */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 38px;
  background: linear-gradient(160deg, var(--sea) 0%, #0e4d6e 100%);
  color: #fff;
}
.topbar::after,
.voyage-hero::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='16' viewBox='0 0 40 16'%3E%3Cpath d='M0 16 V8 Q10 0 20 8 T40 8 V16 Z' fill='%23f6efdf'/%3E%3C/svg%3E") repeat-x;
  background-size: 40px 16px;
  animation: waves 6s linear infinite;
}
.voyage-hero::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='16' viewBox='0 0 40 16'%3E%3Cpath d='M0 16 V8 Q10 0 20 8 T40 8 V16 Z' fill='%23fffdf7'/%3E%3C/svg%3E");
}

@keyframes waves { to { background-position-x: 40px; } }

h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2.4rem; letter-spacing: 0.5px; }
.tagline { flex: 1; margin: 0; opacity: 0.7; }

.me-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.me-btn:hover { background: rgba(255, 255, 255, 0.2); }
.me-btn .avatar { width: 30px; height: 30px; border-color: transparent; font-size: 0.85rem; }
.badge {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.75rem;
  text-align: center;
}

/* ---------- Crews & search ---------- */

.crew-bar { padding: 8px 24px 0; }
.crews { display: flex; flex-wrap: wrap; gap: 8px; }

.crew-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s;
}
.crew-chip:hover { transform: translateY(-1px); }
.crew-chip.active { border-color: var(--crew); background: color-mix(in srgb, var(--crew) 14%, var(--paper)); }
.crew-chip .islands {
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--crew) 16%, transparent);
  font-size: 0.75rem;
}
.crew-chip.add { border: 2px dashed var(--line); background: transparent; box-shadow: none; color: var(--muted); }

.crew-bar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 12px; }
.crew-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--muted); font-size: 0.88rem; }
.crew-info strong { color: var(--ink); }
.crew-info > * + *::before { content: '·'; margin-right: 14px; color: var(--muted); }
.search { width: min(340px, 100%); border-radius: 999px; padding: 8px 14px; }

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 16px 24px 12px;
}
.column {
  min-height: 320px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.15s;
}
.column.drop-target { background: var(--foam); outline: 2px dashed var(--sea-light); outline-offset: -2px; }
.column header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.column h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; }
.column .hint { flex: 1; color: var(--muted); font-size: 0.8rem; }
.column .count {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sea);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.cards { display: grid; gap: 12px; }
.empty { margin: 24px 0; color: var(--muted); font-style: italic; text-align: center; }
.empty.small { margin: 12px 0; }

.empty-sea {
  grid-column: 1 / -1;
  padding: 60px 16px;
  border: 2px dashed var(--line);
  border-radius: 20px;
  text-align: center;
}
.empty-sea-icon { font-size: 3rem; animation: bob 2.4s ease-in-out infinite; }
.empty-sea h2 { margin: 8px 0; font-family: var(--display); font-weight: 400; font-size: 2rem; }
.empty-sea p { margin: 0 0 18px; color: var(--muted); }

.tips { margin: 0; padding: 0 24px 40px; color: var(--muted); font-size: 0.8rem; text-align: center; }
kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--paper);
  font-family: inherit;
  font-size: 0.75rem;
}

.card {
  overflow: hidden;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
  cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
}
.card:hover { transform: translateY(-2px) rotate(-0.4deg); box-shadow: 0 8px 24px rgba(43, 33, 24, 0.14); }
.card.dragging { opacity: 0.4; }
.card-sea {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--sea-from), var(--sea-to));
}
.card-emblem {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.35rem;
}
.card-body { padding: 10px 14px 12px; }
.card h3 { margin: 0 0 2px; font-size: 1rem; }
.card-next { margin: 0 0 8px; font-size: 0.84rem; }
.card footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 0.78rem; }
.card footer .avatars { margin-left: auto; }
.card footer .avatar { width: 22px; height: 22px; font-size: 0.65rem; }
.crew-tag { padding: 0; border: none; background: none; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
button.crew-tag:hover { text-decoration: underline; }
.crew-tag::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--crew);
  vertical-align: 1px;
}
.crew-tag.none { color: var(--muted); font-weight: 400; }
.crew-tag.none::before { display: none; }

/* Crew pickers (expedition crews, your crews) */
.crew-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.crew-toggle {
  padding: 5px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.crew-toggle:hover { transform: translateY(-1px); border-color: var(--crew); }
.crew-toggle.on { border-color: var(--crew); background: color-mix(in srgb, var(--crew) 16%, #fff); }
.voyage-hero .crew-toggle { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.1); color: #fff; }
.voyage-hero .crew-toggle.on { border-color: #fff; background: #fff; color: var(--ink); }
.small-btn { padding: 4px 12px; font-size: 0.82rem; }

.weather { padding: 1px 8px; border-radius: 999px; background: var(--foam); color: var(--ink); white-space: nowrap; }
.weather.choppy { background: #fff1d0; color: #7a4f00; }
.weather.storm { background: #fde2e0; color: var(--danger); font-weight: 600; }
.weather.done { background: #e1f3e6; color: #22663a; }

/* Mini route on cards */
.mini-route { display: flex; flex: 1; align-items: center; min-width: 0; height: 30px; }
.mini-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.mini-dot.port { width: 7px; height: 7px; background: rgba(255, 255, 255, 0.6); }
.mini-dot.done { background: var(--accent); }
.mini-dot.current { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3); }
.mini-leg {
  position: relative;
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0 4px, transparent 4px 8px);
}
.mini-leg.sailed { background: var(--accent); }
.mini-leg .ship { position: absolute; top: 50%; color: var(--accent); line-height: 0; transform: translate(-50%, -78%); }
.mini-leg .ship-svg { width: 22px; height: 22px; }
.card .ship-svg { animation: bob 2.4s ease-in-out infinite; }
.column[data-status='landed'] .ship-svg { animation: none; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-2px) rotate(3deg); }
}

/* ---------- Voyage view ---------- */

.voyage {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: 24px 16px;
  background: rgba(11, 57, 84, 0.5);
}
.voyage-sheet {
  max-width: 1100px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.voyage-sheet.entering { animation: rise 0.25s ease-out; }

@keyframes rise { from { transform: translateY(20px); opacity: 0; } }

.voyage-hero {
  position: relative;
  padding: 20px 24px 8px;
  background: linear-gradient(135deg, var(--sea-from), var(--sea-to));
  color: #fff;
}
.hero-top { display: flex; align-items: flex-start; gap: 14px; }
.emblem-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 2.1rem;
  cursor: pointer;
  transition: transform 0.15s;
}
.emblem-btn:hover { transform: rotate(-6deg) scale(1.06); }
.hero-titles { flex: 1; min-width: 0; }
.title-input, .goal-input {
  width: 100%;
  padding: 0 0 2px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: inherit;
}
.title-input { font-family: var(--display); font-size: 2.4rem; line-height: 1.15; }
.goal-input { font-size: 1rem; opacity: 0.9; }
.title-input::placeholder, .goal-input::placeholder { color: inherit; opacity: 0.55; }
.title-input:focus, .goal-input:focus { outline: none; border-bottom-color: var(--accent); }

.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; }
.status-pills { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.22); }
.pill {
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.pill:hover { color: #fff; }
.pill.on { background: #fff; color: var(--ink); }
.pill.ghost { border: 1px solid rgba(255, 255, 255, 0.35); }
.hero-chip { padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 0.85rem; font-weight: 600; }
.hero-chip.weather.choppy { background: #ffd166; color: #4a3000; }
.hero-chip.weather.storm { background: #e63946; color: #fff; }
.hero-chip.weather.done { background: #95d5b2; color: #123d23; }

.meta { display: inline-flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, 0.8); }
.meta select, .meta input {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  color-scheme: dark;
}
.meta select option { color: var(--ink); }
.meta-label, .meta { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.meta select, .meta input { font-size: 0.9rem; letter-spacing: normal; text-transform: none; }

.theme-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.theme-swatch {
  padding: 7px 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--sea-from), var(--sea-to));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.theme-swatch:hover { transform: translateY(-1px); }
.theme-swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

/* Route map */
.route-map {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  margin: 8px -24px 0;
  padding: 26px 24px 34px;
  scrollbar-width: thin;
}
.leg { position: relative; flex: 1 1 48px; min-width: 40px; height: 64px; }
.leg::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -6px;
  right: -6px;
  border-top: 3px dashed rgba(255, 255, 255, 0.45);
}
.leg.sailed::before { border-top: 3px solid var(--accent); }
.leg.ghost { flex: 0 0 28px; min-width: 28px; opacity: 0.5; }
.leg .ship {
  position: absolute;
  top: 50%;
  z-index: 1;
  color: var(--accent);
  line-height: 0;
  transform: translate(-50%, -82%);
  transition: left 0.9s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.leg .ship-svg { width: 38px; height: 38px; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.3)); }

.isle, .port {
  display: grid;
  justify-items: center;
  gap: 5px;
  flex: none;
  width: 108px;
  padding: 0;
  border: none;
  background: none;
  color: #fff;
  text-align: center;
}
.isle { cursor: pointer; }
.isle-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fdf0c8, #e7c376);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.14), 0 8px 16px rgba(0, 0, 0, 0.25);
  font-size: 1.9rem;
  transition: transform 0.15s;
}
.isle:hover .isle-icon { transform: translateY(-3px) scale(1.05); }
.isle.reached .isle-icon { background: radial-gradient(circle at 50% 38%, #e3f6e8, #8fd0a8); }
.isle.current .isle-icon { animation: pulse 2s ease-in-out infinite; }
.isle.selected .isle-icon { box-shadow: 0 0 0 4px #fff, 0 8px 16px rgba(0, 0, 0, 0.25); }
.isle.current.selected .isle-icon { animation: pulse-selected 2s ease-in-out infinite; }
.port .isle-icon { background: rgba(255, 255, 255, 0.18); font-size: 1.6rem; box-shadow: none; }
.isle.add .isle-icon {
  border: 2px dashed rgba(255, 255, 255, 0.6);
  background: transparent;
  box-shadow: none;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 300;
}
.isle.add { opacity: 0.75; }
.isle.add:hover { opacity: 1; }
.flag { position: absolute; top: -12px; right: -6px; font-size: 1.2rem; }
.isle-name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.isle.selected .isle-name { background: #fff; color: var(--ink); }
.isle-meta { font-size: 0.72rem; opacity: 0.85; }
.isle-meta.late { color: #ffc2b4; font-weight: 700; opacity: 1; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent), 0 8px 16px rgba(0, 0, 0, 0.25); }
  50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 35%, transparent), 0 8px 16px rgba(0, 0, 0, 0.25); }
}
@keyframes pulse-selected {
  0%, 100% { box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--accent); }
  50% { box-shadow: 0 0 0 4px #fff, 0 0 0 13px color-mix(in srgb, var(--accent) 35%, transparent); }
}

.landfall {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--gold) 25%, var(--paper));
  font-weight: 600;
  animation: pop 0.35s ease-out;
}

@keyframes pop { from { transform: scale(0.9); opacity: 0; } }

.voyage-body {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 24px;
  padding: 16px 24px 8px;
}

.stop-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.emoji-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform 0.1s;
}
.emoji-btn:hover { transform: scale(1.08); }
.emoji-btn.small { width: 36px; height: 36px; border-radius: 10px; font-size: 1.15rem; }
.stop-name {
  flex: 1;
  min-width: 160px;
  padding: 0 0 2px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: var(--display);
  font-size: 1.8rem;
}
.stop-name:focus { outline: none; border-bottom-color: var(--gold); }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
label.inline input { padding: 5px 8px; }
.stop-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 6px; font-size: 0.85rem; }

.tasks { margin: 0; padding: 0; list-style: none; }
.tasks li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tasks input[type='checkbox'], .order-group input[type='checkbox'] {
  flex: none;
  width: 19px;
  height: 19px;
  accent-color: var(--sea-light);
  cursor: pointer;
}
.task-title {
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}
.task-title:hover { border-color: var(--line); }
.task-title:focus { border-color: var(--sea-light); outline: none; background: #fff; }
.tasks li.done .task-title { color: var(--muted); text-decoration: line-through; }
.assignee {
  max-width: 130px;
  padding: 4px 8px;
  border: none;
  border-radius: 999px;
  background: var(--foam);
  font-size: 0.8rem;
  cursor: pointer;
}

.add-task input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: transparent;
}
.add-task input:focus { border-style: solid; border-color: var(--sea-light); outline: none; background: #fff; }

.log-panel {
  align-self: start;
  max-height: 460px;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--parchment);
}
.log-panel h3 { margin-bottom: 8px; font-family: var(--display); font-weight: 400; font-size: 1.4rem; }
.log-panel ol { margin: 0; padding: 0; list-style: none; }
.log-panel li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.87rem; }
.log-panel li:last-child { border-bottom: none; }
.log-panel time { display: block; color: var(--muted); font-size: 0.75rem; }

.voyage-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 24px 18px; }

/* ---------- Dialogs ---------- */

dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: none;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(11, 57, 84, 0.3);
}
dialog.wide { width: min(620px, calc(100vw - 32px)); }
dialog[open] { animation: pop 0.2s ease-out; }
dialog::backdrop { background: rgba(11, 57, 84, 0.45); }
.dialog-pad { display: grid; gap: 14px; padding: 22px 24px; }
dialog h2 { font-family: var(--display); font-weight: 400; font-size: 1.8rem; }
dialog h3 { margin-top: 4px; font-size: 1rem; }
.dialog-head { display: flex; align-items: center; gap: 12px; }
.dialog-head > .avatar { width: 44px; height: 44px; font-size: 1.2rem; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dialog-actions .btn.danger { padding-left: 0; }

/* New expedition */
.chart-hero {
  padding: 20px 24px 18px;
  background: linear-gradient(135deg, var(--sea-from), var(--sea-to));
  color: #fff;
  transition: background 0.3s;
}
.eyebrow { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; }
.chart-title { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.chart-title .emblem-btn { width: 54px; height: 54px; font-size: 1.7rem; }
.chart-title .title-input { font-size: 2rem; }
.draft-route { display: flex; align-items: center; }
.dr-isle {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fdf0c8, #e7c376);
  font-size: 1.05rem;
  animation: pop 0.25s ease-out;
}
.dr-isle.port { background: rgba(255, 255, 255, 0.2); }
.dr-leg { flex: 1; min-width: 10px; border-top: 2px dashed rgba(255, 255, 255, 0.5); }
.chart-body { display: grid; gap: 16px; padding: 18px 24px 22px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.preset {
  display: grid;
  justify-items: start;
  gap: 1px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.preset:hover { border-color: var(--sea-light); }
.preset.on { border-color: var(--sea-light); background: var(--foam); }
.preset-icon { font-size: 1.2rem; }
.preset strong { font-size: 0.88rem; }
.preset small { color: var(--muted); font-size: 0.72rem; }
.draft-stops { display: grid; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.draft-stops li { display: flex; align-items: center; gap: 8px; }
.draft-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sea);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}
.draft-stops input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.days { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 400; letter-spacing: normal; text-transform: none; font-size: 0.9rem; }
.days input { width: 80px; }
.themes { display: flex; flex-wrap: wrap; gap: 6px; }
.themes .theme-swatch { border-color: transparent; }
.themes .theme-swatch.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper) inset; }

/* Crews */
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { display: block; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.1s;
}
.swatch span:hover { transform: scale(1.08); }
.swatch.color span { border-color: transparent; background: var(--c); }
.swatch input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper) inset; transform: scale(1.08); }
.swatch input:focus-visible + span { outline: 2px solid var(--sea-light); outline-offset: 2px; }
.member-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.member-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}
.member-pick input { position: absolute; opacity: 0; pointer-events: none; }
.member-pick:has(input:checked) { border-color: var(--sea-light); background: var(--foam); }
.member-pick:has(input:checked)::after { content: '✓'; color: var(--sea-light); font-weight: 700; }
.member-pick:has(input:focus-visible) { outline: 2px solid var(--sea-light); }

/* Crew card */
#crew-card { overflow: hidden auto; }
.crew-hero {
  padding: 20px 24px 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--crew) 55%, #0b1d2a), var(--crew));
  color: #fff;
}
.crew-hero-top { display: flex; align-items: center; gap: 14px; }
.crew-flag {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 2.2rem;
}
.crew-hero h2 { font-size: 2.2rem; line-height: 1.1; }
.crew-stats { font-size: 0.85rem; opacity: 0.9; }
.objective { margin-top: 14px; color: rgba(255, 255, 255, 0.9); }
.objective textarea {
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  resize: vertical;
}
.objective textarea::placeholder { color: rgba(255, 255, 255, 0.6); }
.objective textarea:focus { outline: 2px solid #fff; outline-offset: 1px; }
.crew-card-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 18px 24px 22px; }
.crew-card-body h3 { margin-bottom: 8px; }
.crewmates { display: grid; margin: 0; padding: 0; list-style: none; }
.crewmates li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.crewmates .avatar { width: 34px; height: 34px; font-size: 0.9rem; }
.mate-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.crew-role {
  field-sizing: content;
  min-width: 6ch;
  max-width: 100%;
  padding: 2px 10px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  font-style: italic;
}
.crew-role:not(:placeholder-shown) { border-style: solid; border-color: var(--crew); background: color-mix(in srgb, var(--crew) 20%, #fff); font-style: normal; }
.crew-role::placeholder { color: var(--muted); }
.crew-role:hover { border-color: var(--crew); }
.crew-role:focus { border-style: solid; border-color: var(--crew); outline: none; background: #fff; color: var(--ink); }
.powers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.power {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--crew) 40%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--crew) 12%, #fff);
  font-size: 0.82rem;
  font-weight: 600;
  animation: pop 0.25s ease-out;
}
.power-x { margin-left: 2px; padding: 0 2px; border: none; background: none; color: var(--muted); font-size: 0.7rem; cursor: pointer; }
.power-x:hover { color: var(--danger); }
.power-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.power-form input { flex: 1 1 180px; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.crew-exps { display: flex; flex-wrap: wrap; gap: 8px; }
.crew-exp {
  padding: 7px 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--sea-from), var(--sea-to));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.crew-exp:hover { transform: translateY(-1px); }

/* Orders, team, invites */
.order-group { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.order-exp {
  display: flex;
  width: 100%;
  justify-content: space-between;
  padding: 8px 12px;
  border: none;
  background: linear-gradient(135deg, var(--sea-from), var(--sea-to));
  color: #fff;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.order-group ul { margin: 0; padding: 4px 12px; list-style: none; }
.order-group li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.order-group li + li { border-top: 1px solid var(--line); }
.team-list, .invite-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.team-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.team-list .avatar { width: 34px; height: 34px; font-size: 0.9rem; }
.team-list select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.role-tag { color: var(--muted); font-size: 0.85rem; }
.invite-list li { display: flex; align-items: center; gap: 6px; }
.invite-url { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--parchment); font-size: 0.8rem; }

/* ---------- Popovers: emoji picker, toast, celebration ---------- */

.emoji-pop {
  position: fixed;
  inset: auto;
  width: 252px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 12px 40px rgba(11, 57, 84, 0.25);
}
.emoji-pop:popover-open { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.emoji-pop button { padding: 4px 0; border: none; border-radius: 8px; background: none; font-size: 1.35rem; cursor: pointer; }
.emoji-pop button:hover { background: var(--foam); transform: scale(1.15); }

.toast {
  position: fixed;
  inset: auto auto 24px 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: var(--sea);
  color: #fff;
  font-weight: 500;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in { from { transform: translate(-50%, 16px); opacity: 0; } }

.celebration {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: none;
  background: transparent;
  pointer-events: none;
}
.celebration i { position: absolute; top: -40px; font-size: 26px; font-style: normal; animation: fall linear forwards; }

@keyframes fall { to { transform: translateY(110vh) rotate(var(--spin)); } }

.celebration .banner {
  position: absolute;
  top: 38%;
  left: 50%;
  display: grid;
  gap: 4px;
  padding: 18px 34px;
  border-radius: 20px;
  background: var(--sea);
  color: #fff;
  text-align: center;
  box-shadow: 0 20px 60px rgba(11, 57, 84, 0.35);
  transform: translate(-50%, -50%);
  animation: banner 3.2s ease-out forwards;
}
.celebration .banner strong { color: var(--gold); font-family: var(--display); font-size: 3rem; font-weight: 400; line-height: 1; }
.celebration.small .banner { top: 30%; padding: 14px 26px; animation-duration: 2.4s; }
.celebration.small .banner strong { font-size: 2.1rem; }

@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  12% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  20%, 80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ---------- Small screens & reduced motion ---------- */

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 14px 16px 34px; }
  .tagline { display: none; }
  .topbar h1 { flex: 1; font-size: 1.8rem; white-space: nowrap; }
  .wide-only { display: none; }
  .crew-hero, .crew-card-body { padding-left: 16px; padding-right: 16px; }
  .me-name { display: none; }
  .me-btn { padding-right: 8px; }
  .crew-bar { padding: 8px 16px 0; }
  .search { width: 100%; }
  .board { grid-template-columns: 1fr; padding: 16px 16px 12px; }
  .column { min-height: 0; }
  .tips { display: none; }
  .voyage { padding: 0; }
  .voyage-sheet { min-height: 100%; border-radius: 0; }
  .voyage-hero { padding: 16px 16px 8px; }
  .route-map { margin: 8px -16px 0; padding: 26px 16px 34px; }
  .title-input { font-size: 1.8rem; }
  .emblem-btn { width: 52px; height: 52px; font-size: 1.6rem; }
  .voyage-body { grid-template-columns: 1fr; padding: 16px 16px 8px; }
  .landfall { margin: 16px 16px 0; }
  .voyage-foot { padding: 8px 16px 18px; }
  .voyage-foot .muted { display: none; }
  .assignee { max-width: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .celebration i { display: none; }
}
