/* Paper and ink, carried over from the Flutter client so the two read as one
   product. The drawings are the whole point, so the interface stays quiet.

   No web fonts anywhere: the system stack renders 繁體中文 natively on every
   phone, and shipping a CJK webfont would cost more bytes than the entire rest
   of the app. That is the single decision that makes this open in under a
   second on campus 4G. */

:root {
  --paper: #F7F3EA;
  --paper-deep: #EFE8DA;
  --card: #FFFFFF;
  --rule: #E4DCCB;
  --ink: #2B2A26;
  --ink-soft: #6B675E;
  --ink-faint: #9A9488;
  --water: #1F6B7D;
  --water-wash: #DFEDF0;
  --coral: #BC5137;
  --coral-wash: #F7E5DF;
  --seaweed: #4B7A4A;

  --sys: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
         "Noto Sans TC", "Microsoft JhengHei", Roboto, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15191B;
    --paper-deep: #1C2225;
    --card: #1D2427;
    --rule: #2C3539;
    --ink: #EDE7DA;
    --ink-soft: #A3ACAA;
    --ink-faint: #6F7A78;
    --water: #6FC5D6;
    --water-wash: #1C3239;
    --coral: #E8846A;
    --coral-wash: #33231E;
    --seaweed: #8DBA89;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sys);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100%; display: flex; flex-direction: column; }

.boot {
  flex: 1;
  display: grid;
  place-items: center;
}
.boot-fish { font-size: 44px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(-4px); } 50% { transform: translateY(4px); } }

/* ---------- layout ---------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

.screen.no-nav { padding-bottom: var(--safe-bottom); }

.screen-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 10px;
}

.screen-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.screen-body { flex: 1; padding: 0 20px 24px; }

.back {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 6px 4px 6px 0;
  cursor: pointer;
}

/* ---------- nav ---------- */

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border-top: 1px solid var(--rule);
  z-index: 20;
}

.nav button {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 0;
}
.nav button .ico { font-size: 19px; line-height: 1; }
.nav button[aria-current="page"] { color: var(--water); font-weight: 700; }

.badge {
  position: absolute;
  transform: translate(11px, -11px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---------- pieces ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: start;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 15px 16px;
  margin-bottom: 10px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  appearance: none;
}
.row:disabled { opacity: .55; cursor: default; }

.row-mark {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--paper-deep);
  display: grid; place-items: center;
  font-size: 21px;
  flex: none;
}
.row-mark.near { background: var(--water-wash); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 16px; }
.row-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.row-chev { color: var(--ink-faint); flex: none; }

.btn {
  appearance: none;
  display: block;
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: var(--water);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 16px;
  cursor: pointer;
}
.btn:disabled { opacity: .4; cursor: default; }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--rule);
  padding: 14px;
}

.field {
  width: 100%;
  border: 2px solid var(--rule);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* never below 16px: iOS zooms the page on focus otherwise */
  padding: 14px;
  appearance: none;
}
.field:focus-visible { outline: 2px solid var(--water); outline-offset: 1px; }
.field.center { text-align: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--water-wash);
  color: var(--water);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 11px;
  border-radius: 999px;
}

.note {
  padding: 13px 15px;
  border-radius: 13px;
  font-size: 14px;
  background: var(--coral-wash);
  color: var(--coral);
  font-weight: 600;
}
.note.calm { background: var(--water-wash); color: var(--water); }

.muted { color: var(--ink-soft); font-size: 14px; }
.tiny { color: var(--ink-faint); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.center-col { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.grow { flex: 1; }
.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 56px 0; }
.empty .big { font-size: 46px; }

/* ---------- fish ---------- */

.fish-canvas { display: block; width: 100%; height: auto; }

.fish-tile {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fish-name { font-weight: 700; font-size: 14px; text-align: center; }
.fish-by { font-size: 11px; color: var(--ink-faint); text-align: center; }

/* ---------- drawing ---------- */

.pad {
  width: 100%;
  aspect-ratio: 1;
  background: var(--card);
  border: 2px solid var(--rule);
  border-radius: 22px;
  touch-action: none;
  display: block;
}

.inkbox { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  padding: 0;
  cursor: pointer;
  appearance: none;
}
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.nib {
  width: 30px; height: 32px;
  border: 0; background: none; padding: 0;
  display: grid; place-items: center; cursor: pointer;
}
.nib i { display: block; border-radius: 50%; background: var(--ink-faint); }
.nib[aria-pressed="true"] i { background: var(--ink); }

/* ---------- reveal ---------- */

.sheet {
  position: fixed; inset: 0;
  background: rgba(20,18,14,.55);
  display: grid; place-items: center;
  padding: 24px;
  z-index: 40;
}
.sheet-card {
  background: var(--paper);
  border-radius: 26px;
  padding: 22px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 100%;
  overflow: auto;
}
.reveal-frame {
  background: var(--card);
  border: 2px solid var(--rule);
  border-radius: 18px;
  padding: 10px;
}
.reveal-meta { text-align: center; opacity: 0; transition: opacity .5s ease; }
.reveal-meta.shown { opacity: 1; }

/* ---------- quests ---------- */

.quest { display: flex; gap: 13px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.quest:last-child { border-bottom: 0; }
.quest-tick {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--rule);
  display: grid; place-items: center;
  font-size: 13px; flex: none; margin-top: 2px;
  color: transparent;
}
.quest.done .quest-tick { background: var(--seaweed); border-color: var(--seaweed); color: #fff; }
.quest-title { font-weight: 700; }
.quest.done .quest-title { color: var(--ink-soft); }
.bar { height: 5px; border-radius: 999px; background: var(--paper-deep); overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; background: var(--water); border-radius: 999px; }

/* ---------- meet ---------- */

.tabs { display: flex; gap: 6px; padding: 0 20px 12px; }
.tab {
  flex: 1; appearance: none; border: 0; font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px; border-radius: 12px; background: var(--paper-deep); color: var(--ink-soft);
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--water-wash); color: var(--water); }

.qr { background: #fff; padding: 16px; border-radius: 20px; border: 2px solid var(--rule); }
.qr svg { display: block; width: 100%; height: auto; image-rendering: pixelated; }

.code {
  font-size: 27px; font-weight: 800; letter-spacing: 5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.countdown { width: 100%; max-width: 220px; }
.countdown .bar { height: 8px; }
.countdown .bar i { background: var(--water); transition: width 1s linear; }
.countdown.low .bar i { background: var(--coral); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  max-width: calc(100vw - 40px);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
