:root {
  --bg: #06233a; --card: #0d3654; --ink: #eaf6ff; --muted: #9cc3dc;
  --accent: #ffcf3f; --accent-ink: #2a1d00; --danger: #ff6b6b; --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #0f4c73 0%, var(--bg) 60%);
  color: var(--ink); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
main { max-width: 720px; margin: 0 auto; padding: 28px 16px 48px; }
h1 { font-size: 2rem; margin: 0 0 .3em; letter-spacing: -.5px; }
h2 { font-size: 1.3rem; margin: 1.6em 0 .6em; }
p { margin: .4em 0 1em; color: var(--muted); }
[hidden] { display: none !important; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  min-height: 52px; padding: 12px 22px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink);
}
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 2px solid rgba(255,255,255,.25); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, .btn:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.big { width: 100%; font-size: 1.15rem; min-height: 64px; margin: 8px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
input[type=text] {
  font: inherit; font-family: ui-monospace, monospace; font-size: 1.2rem; letter-spacing: 2px;
  padding: 12px 16px; border-radius: 14px; border: 2px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.25); color: var(--ink); min-width: 0; flex: 1;
}
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin: 12px 0; }
.tanks .card { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tanks code { font-size: 1.1rem; letter-spacing: 2px; flex: 1; }
.err { color: var(--danger); }

/* ── tank screen ── */
body.tank { overflow: hidden; background: #021018; }
body.tank canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.join {
  position: fixed; right: 2vw; bottom: 3vh; display: flex; gap: 14px; align-items: center;
  background: rgba(3, 25, 42, .78); border-radius: var(--radius); padding: 12px 16px 12px 12px;
  max-width: 420px; font-size: 15px; transition: transform .4s, opacity .4s;
}
.join #qr { width: 112px; height: 112px; flex: none; background: #fff; border-radius: 10px; overflow: hidden; }
.join #qr svg { width: 100%; height: 100%; display: block; }
.join b { display: block; font-size: 1.15em; }
.join span { display: block; color: var(--muted); margin: 4px 0; }
.join code { font-size: 1.1em; letter-spacing: 2px; color: var(--accent); }
.join.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }
/* empty tank: the invitation is the whole point of the screen */
.join.big { right: 50%; bottom: 50%; transform: translate(50%, 50%); max-width: 640px; font-size: 22px; padding: 22px; }
.join.big #qr { width: 220px; height: 220px; }
.join #add-here { display: flex; min-height: 40px; padding: 6px 16px; margin-top: 8px; font-size: .95em; }
/* the phone page, opened over the tank on this device */
.addframe { position: fixed; inset: 0; width: 100vw; height: 100vh; border: 0; z-index: 10; background: var(--bg); }
.msg { position: fixed; inset: auto 0 45vh; text-align: center; font-size: 1.3rem; color: var(--ink); }
.stats {
  position: fixed; left: 8px; top: 8px; margin: 0; padding: 8px 10px; z-index: 9;
  background: rgba(0,0,0,.7); color: #7fffb0; font: 14px/1.35 ui-monospace, monospace; pointer-events: none;
}

/* ── phone page ── */
.live { width: 100%; aspect-ratio: 16 / 10; display: block; border: 0; border-radius: var(--radius); background: #06263d; margin-bottom: 10px; }
.slider { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; font-weight: 600; }
.slider input { flex: 1; accent-color: var(--accent); min-height: 44px; }
.preview { width: 100%; aspect-ratio: 2 / 1; display: block; border-radius: var(--radius);
  background: repeating-conic-gradient(#0b2d46 0 25%, #0e3756 0 50%) 0 0 / 24px 24px; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.picks button { flex-direction: column; background: #fff; color: #123; border-radius: var(--radius); padding: 10px; min-height: 0; }
.picks canvas { width: 100%; aspect-ratio: 2 / 1; }
.spinner { width: 56px; height: 56px; border-radius: 50%; border: 6px solid rgba(255,255,255,.2); border-top-color: var(--accent);
  animation: spin 1s linear infinite; margin: 40px auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.fishlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.fishlist div { position: relative; background: rgba(0,0,0,.25); border-radius: 12px; }
.fishlist img { width: 100%; aspect-ratio: 2 / 1; display: block; }
.fishlist button { position: absolute; top: 4px; right: 4px; min-height: 36px; padding: 4px 12px; background: var(--danger); color: #fff; }

/* drawing: the whole screen is paper */
body.drawing { overflow: hidden; }
#s-draw { position: fixed; inset: 0; display: flex; flex-direction: column; background: #cfe0ec; z-index: 5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; background: var(--bg); }
.bar button { min-height: 44px; padding: 8px 14px; }
.bar .grow { flex: 1; }
.swatch { width: 40px; height: 40px; min-height: 0 !important; padding: 0 !important; border-radius: 50%; border: 3px solid transparent !important; }
.swatch.on, .size.on { outline: 3px solid #fff; outline-offset: 1px; }
#stage { flex: 1; position: relative; touch-action: none; }
#stage canvas { position: absolute; background: transparent; touch-action: none; }
#paint { background: #fff !important; border-radius: 8px; box-shadow: 0 6px 30px rgba(0,0,0,.25); }
#lines { pointer-events: none; }

/* ── print ── */
.sheets { display: grid; gap: 18px; }
.sheets .sheet svg { width: 100%; height: auto; display: block; border-radius: 6px; }
@media print {
  @page { size: A4 landscape; margin: 0; }
  body { background: #fff; }
  .noprint { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheets { display: block; }
  .sheets .sheet { break-after: page; }
  .sheets .sheet svg { width: 297mm; height: 210mm; border-radius: 0; }
}
