:root {
  --ink: #1c241c;
  --muted: #5d6b5a;
  --paper: #f3efe4;
  --card: #fffaf2;
  --line: #d9d0bf;
  --water: #1f6f66;
  --water-deep: #134e49;
  --moss: #3d7a45;
  --gold: #b56a1f;
  --danger: #9c3b2e;
  --good: #1f7a46;
  --shadow: 0 10px 30px rgba(40, 48, 32, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top, #f7f3e8 0%, #e7efe4 42%, #d5e3dc 100%);
  min-height: 100vh;
}

button, input { font: inherit; }

.app {
  width: min(1080px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand strong { display: block; font-size: 22px; letter-spacing: 0.08em; }
.brand .ver { margin-left: 6px; font-size: 13px; letter-spacing: 0.04em; color: var(--muted); font-weight: 650; }
.brand em { color: var(--muted); font-style: normal; font-size: 13px; }
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
  background: #1a1030;
}

.stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 92px;
  box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat b { font-size: 16px; }
.stat.clock { min-width: 112px; }
.stat.clock b { font-size: 20px; color: var(--water-deep); }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}
.tabs button.is-on { background: var(--ink); color: #f6f1e4; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.card-pic {
  width: calc(100% + 28px);
  height: 148px;
  margin: -14px -14px 12px;
  object-fit: cover;
  display: block;
  background: #e7efe4;
}
.card p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 10px; }
.meta span { white-space: normal; }
.unlock-line { margin: 0 0 10px; color: var(--gold); font-weight: 700; line-height: 1.4; word-break: break-all; }
.price { color: var(--gold); font-weight: 700; }

.btn {
  border: 0;
  background: var(--water);
  color: white;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.warn { background: var(--danger); }
.btn.good { background: var(--good); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.stage {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
}
.pond {
  position: relative;
  min-height: 360px;
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(#c8a36a 0 18%, transparent 18%),
    linear-gradient(180deg, #7eb8ae 0%, var(--water) 38%, var(--water-deep) 100%);
  color: #f7f3ea;
  padding: 16px;
}
.pond h2 { margin: 8px 0; position: relative; }
.pond .tone { position: relative; opacity: 0.9; font-size: 13px; }
.dock {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 74px;
  background: repeating-linear-gradient(90deg, #8a5a32 0 18px, #734824 18px 28px);
}
.float {
  position: absolute;
  left: 46%;
  bottom: 92px;
  width: 14px;
  height: 22px;
  border-radius: 8px 8px 6px 6px;
  background: #f2f2f2;
  box-shadow: 0 8px 0 #d24b3a;
  transform-origin: center bottom;
}
.float.is-wait { animation: bob 1s ease-in-out infinite; }
.float.is-bite { animation: bite 0.18s linear infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }
@keyframes bite { 50% { transform: translateY(10px) rotate(8deg); } }

.panel { display: flex; flex-direction: column; gap: 12px; }
.bar-wrap { height: 28px; background: #efe6d6; border-radius: 999px; position: relative; overflow: hidden; }
.zone {
  position: absolute;
  top: 0; bottom: 0;
  background: #8fce9a;
}
.needle {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: var(--ink);
}
.fish-scene {
  height: 340px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #d7ebe4 center / cover no-repeat;
}
.fish-scene img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fish-scene.is-on img { animation: scene-drift 4.5s ease-in-out infinite alternate; }
@keyframes scene-drift { to { transform: scale(1.05); } }
.text-play { display: grid; gap: 12px; }
.where { color: var(--muted); font-size: 13px; }
.countdown {
  margin: 8px 0;
  font-size: 32px;
  letter-spacing: 0.06em;
}
.dex-filters { align-items: center; margin-bottom: 12px; }
.dex-filters label { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.dex-filters select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}
.dex-block { margin-bottom: 18px; }
.dex-block h3 { margin: 0 0 8px; font-size: 16px; }
.dex-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.dex-fish {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  color: var(--ink);
  font-size: 14px;
}
.dex-fish.is-open { min-height: 320px; }
.dex-fish .dex-body { padding: 12px 12px 14px; }
.dex-fish.is-open .dex-body {
  background: linear-gradient(to top, rgba(255, 252, 246, 0.96) 58%, rgba(255, 252, 246, 0));
}
.dex-fish strong { display: block; color: var(--ink); font-size: 16px; font-weight: 650; }
.dex-fish .dex-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.dex-fish p { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink); }
.dex-fish small { display: block; margin-top: 4px; color: var(--muted); }
.dex-fish b { font-weight: 650; }
b.g-g { color: #7d8478; }
b.g-f { color: #6a8a3e; }
b.g-e { color: #2f8a55; }
b.g-d { color: #1c7c86; }
b.g-c { color: #2b6cb0; }
b.g-b { color: #5a4db8; }
b.g-a { color: #a33d78; }
b.g-s { color: #b56a1f; }
b.g-ss { color: #c4511a; }
b.g-sss { color: #c23333; }
b.g-legend { color: #a67c00; }
b.g-myth { color: #6d28a8; }
.sheet tr.g-g { background: #f3f4f1; }
.sheet tr.g-f { background: #f3f7ea; }
.sheet tr.g-e { background: #e8f6ee; }
.sheet tr.g-d { background: #e6f5f6; }
.sheet tr.g-c { background: #e8f1fb; }
.sheet tr.g-b { background: #efecfb; }
.sheet tr.g-a { background: #fbeaf3; }
.sheet tr.g-s { background: #fbf3e7; }
.sheet tr.g-ss { background: #fbeee6; }
.sheet tr.g-sss { background: #fbeaea; }
.sheet tr.g-legend { background: #fbf6dc; }
.sheet tr.g-myth { background: #f3e9fa; }
.dex-fish.is-locked.g-g { background-color: #f3f4f1; }
.dex-fish.is-locked.g-f { background-color: #f3f7ea; }
.dex-fish.is-locked.g-e { background-color: #e8f6ee; }
.dex-fish.is-locked.g-d { background-color: #e6f5f6; }
.dex-fish.is-locked.g-c { background-color: #e8f1fb; }
.dex-fish.is-locked.g-b { background-color: #efecfb; }
.dex-fish.is-locked.g-a { background-color: #fbeaf3; }
.dex-fish.is-locked.g-s { background-color: #fbf3e7; }
.dex-fish.is-locked.g-ss { background-color: #fbeee6; }
.dex-fish.is-locked.g-sss { background-color: #fbeaea; }
.dex-fish.is-locked.g-legend { background-color: #fbf6dc; }
.dex-fish.is-locked.g-myth { background-color: #f3e9fa; }
.dex-fish.g-g { border-color: #d5d8d1; }
.dex-fish.g-f { border-color: #d0ddb0; }
.dex-fish.g-e { border-color: #b7e0c8; }
.dex-fish.g-d { border-color: #b5e0e3; }
.dex-fish.g-c { border-color: #c3d7f2; }
.dex-fish.g-b { border-color: #d4cef3; }
.dex-fish.g-a { border-color: #f0c9de; }
.dex-fish.g-s { border-color: #f0d7b0; }
.dex-fish.g-ss { border-color: #f3cbb8; }
.dex-fish.g-sss { border-color: #f3c4c4; }
.dex-fish.g-legend { border-color: #ead98a; }
.dex-fish.g-myth { border-color: #ddc4ee; }
.dex-fish.is-in { box-shadow: inset 0 0 0 1px var(--good); }
.dex-fish.is-locked strong { color: var(--ink); font-weight: 650; }
.count {
  width: 88px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; }
.sheet th, .sheet td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.sheet td:last-child, .sheet th:last-child { white-space: nowrap; }
.catch {
  border-left: 4px solid var(--moss);
}
.catch h3 { font-size: 28px; margin-top: 4px; }
.catch b { font-size: 18px; }
.log { max-height: 180px; overflow: auto; font-size: 13px; color: var(--muted); }
.log div { padding: 4px 0; border-bottom: 1px dashed var(--line); }

.shop-col h2 { margin: 4px 0 10px; font-size: 16px; }
.owned { color: var(--good); font-size: 13px; }

.aquarium {
  position: relative;
  height: 460px;
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: 22px;
  border: 8px solid #d5e6ee;
  container-type: inline-size;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 255, 255, 0.45), transparent 36%),
    linear-gradient(#8fd0e6 0%, #2f86a3 34%, #0d4560 100%);
  box-shadow: inset 0 0 48px rgba(4, 24, 36, 0.28), var(--shadow);
}
.aquarium::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42px;
  background: linear-gradient(#d7c091, #b08b52);
  pointer-events: none;
}
.tank-stats {
  position: absolute;
  z-index: 6;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}
.tank-stats b {
  color: #f7fbff;
  background: rgba(6, 24, 36, 0.62);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}
.swimmer em {
  display: block;
  margin-top: 2px;
  text-align: center;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #f7fbff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}
.bubbles, .bubbles span { pointer-events: none; }
.bubbles span {
  position: absolute;
  bottom: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.75);
  animation: rise linear infinite;
}
.swimmer {
  position: absolute;
  left: 0;
  animation: drift ease-in-out infinite;
}
.swimmer.go-back { animation-name: drift-back; }
.swimmer.go-back .fish-body { transform: scaleX(-1); }
.swimmer.is-myth,
.swimmer.is-legend {
  left: var(--park, 18%);
  animation-timing-function: ease-in-out;
}
.swimmer.is-myth { animation-name: myth-loom; }
.swimmer.is-legend { animation-name: legend-arc; }
.fish-body img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 0;
  clip-path: none;
  -webkit-mask-image: radial-gradient(ellipse 70% 64% at 50% 46%, #000 46%, transparent 76%);
  mask-image: radial-gradient(ellipse 70% 64% at 50% 46%, #000 46%, transparent 76%);
}
.swimmer.is-myth .fish-body img,
.swimmer.is-legend .fish-body img {
  aspect-ratio: 1 / 1;
  -webkit-mask-image: radial-gradient(ellipse 80% 78% at 50% 46%, #000 52%, transparent 80%);
  mask-image: radial-gradient(ellipse 80% 78% at 50% 46%, #000 52%, transparent 80%);
}
.tank-empty {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
}
@keyframes drift {
  0% { transform: translate3d(-22%, 4px, 0); }
  50% { transform: translate3d(46cqi, -8px, 0); }
  100% { transform: translate3d(102cqi, 3px, 0); }
}
@keyframes drift-back {
  0% { transform: translate3d(102cqi, 3px, 0); }
  50% { transform: translate3d(46cqi, -8px, 0); }
  100% { transform: translate3d(-22%, 4px, 0); }
}
@keyframes myth-loom {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
@keyframes legend-arc {
  0%, 100% { transform: translate(0, 6px); }
  50% { transform: translate(18px, -12px); }
}
@keyframes rise {
  from { transform: translateY(0); opacity: 0.2; }
  to { transform: translateY(-320px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .swimmer, .fish-body img, .bubbles span { animation: none; }
  .swimmer { left: var(--park, 12%); }
}

@media (max-width: 800px) {
  .top, .stage { display: block; }
  .stats { justify-content: flex-start; margin-top: 10px; }
  .stage .card { margin-top: 12px; }
}


/* Shared interaction polish */
button, input, select { -webkit-tap-highlight-color: transparent; }
button { transition: background-color .18s, border-color .18s, box-shadow .18s; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #82b4a8; outline-offset: 3px; }
.btn:hover:not([aria-disabled="true"]):not(:disabled) { filter: brightness(.94); }
.btn[aria-disabled="true"] { opacity: .52; cursor: not-allowed; }
.tabs { overflow-x: auto; padding: 3px 1px 8px; scrollbar-width: thin; }
.tabs button { white-space: nowrap; flex-shrink: 0; }
.tabs button:hover:not(.is-on) { background: rgba(255,255,255,.55); border-color: #a9b8a5; }
.tabs button.is-on { box-shadow: 0 3px 8px #1c241c1c; }
.card { overflow: hidden; }
.card h3 { margin: 0 0 10px; font-size: 17px; }
.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table-scroll .sheet { min-width: 520px; }
.sheet th { padding-top: 12px; padding-bottom: 12px; background: #f2f1e8; color: var(--muted); }
.sheet tbody tr:last-child td { border-bottom: 0; }
.where { line-height: 1.65; }

/* Save management */
.save-page { display: grid; gap: 18px; padding-top: 8px; }
.save-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 2px; }
.eyebrow { font-size: 12px; letter-spacing: .1em; color: var(--water); }
.save-heading h2 { margin: 6px 0; font-size: 28px; letter-spacing: .04em; }
.save-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.save-badge { flex-shrink: 0; border: 1px solid #bed5c5; background: #edf5ed; color: var(--water-deep); border-radius: 999px; padding: 7px 12px; font-size: 12px; }
.save-summary { padding: 22px; }
.save-summary-head { display: flex; gap: 8px 20px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.save-summary-head h3 { font-size: 15px; }
.save-status { font-size: 12px; color: var(--muted); }
.save-metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; margin: 14px 0 0; }
.save-metrics div + div { border-left: 1px solid var(--line); padding-left: 20px; }
.save-metrics dt { color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.save-metrics dd { margin: 0; font-size: 21px; font-weight: 650; overflow-wrap: anywhere; }
.save-metrics small { font-size: 12px; font-weight: 400; color: var(--muted); }
.save-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.save-action { padding: 24px; display: flex; align-items: flex-start; flex-direction: column; }
.save-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 16px; border: 1px solid #cbdcd2; background: #eaf1e9; color: var(--water); border-radius: 13px; font-size: 25px; }
.save-action h3 { font-size: 18px; }
.save-action p { font-size: 14px; line-height: 1.8; max-width: 420px; margin-bottom: 20px; }
.save-action .btn { margin-top: auto; min-height: 42px; padding: 10px 18px; }
.save-action small { color: var(--muted); font-size: 12px; margin-top: 12px; line-height: 1.6; }
.save-danger { border: 1px solid #ddc8bc; background: #faf3ec; border-radius: 16px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.save-danger h3 { color: var(--danger); font-size: 15px; margin: 0 0 8px; }
.save-danger p { color: #7b6258; font-size: 13px; line-height: 1.7; margin: 0; }
.btn.danger-outline { color: var(--danger); border: 1px solid #c8a99a; background: transparent; flex-shrink: 0; }
.save-note { margin: 0 2px; }

/* Toasts stay independent of dialogs and page rerenders. */
.toast-region { position: fixed; z-index: 1000; top: 20px; right: 20px; width: min(400px, calc(100vw - 32px)); display: grid; gap: 10px; pointer-events: none; }
.toast { --toast-color: var(--water); display: flex; align-items: flex-start; gap: 11px; padding: 15px 13px 15px 16px; border: 1px solid #d6dfd5; border-left: 4px solid var(--toast-color); background: #fffef9; border-radius: 12px; box-shadow: 0 8px 30px #19352a24; pointer-events: auto; animation: toast-in .22s ease-out; }
.toast--success { --toast-color: var(--good); }
.toast--warning { --toast-color: #a86c1d; }
.toast--error { --toast-color: var(--danger); }
.toast-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--toast-color); color: white; flex-shrink: 0; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.toast p { flex: 1; font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.toast-close { border: 0; background: transparent; color: var(--muted); font-size: 21px; cursor: pointer; padding: 0 4px; line-height: 1.1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* A native dialog supplies focus containment; all visuals and actions are ours. */
.confirm-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow: auto; padding: 28px; color: var(--ink); background: #fffaf2; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 80px #17292035; }
.confirm-dialog::backdrop { background: #14271f65; backdrop-filter: blur(3px); }
.confirm-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; color: var(--water); background: #e4eee5; font-size: 23px; font-weight: 700; margin-bottom: 18px; }
.confirm-dialog.is-danger .confirm-icon { color: var(--danger); background: #f7e7dd; }
.confirm-dialog h2 { font-size: 21px; margin: 0 0 12px; }
.confirm-dialog p { color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; margin: 0; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.confirm-actions .btn { min-width: 92px; min-height: 42px; }
@media (max-width: 600px) {
  .app { padding-top: 16px; }
  .stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); width: 100%; }
  .stat, .stat.clock { min-width: 0; padding: 8px 10px; }
  .stat b { font-size: 14px; }
  .stat.clock b { font-size: 15px; }
  .save-page { gap: 14px; }
  .save-heading { align-items: flex-start; }
  .save-heading h2 { font-size: 25px; }
  .save-grid { grid-template-columns: 1fr; gap: 14px; }
  .save-summary, .save-action { padding: 20px; }
  .save-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); row-gap: 20px; }
  .save-metrics div:nth-child(3) { border-left: 0; padding-left: 0; }
  .save-danger { align-items: flex-start; flex-direction: column; gap: 14px; padding: 20px; }
  .toast-region { top: auto; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .confirm-dialog { padding: 24px; }
  .confirm-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  button { transition: none; }
}

.app-footer { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 28px 0 4px; color: var(--muted); font-size: 12px; }
.app-version { border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-variant-numeric: tabular-nums; }

.legacy-import { width: 100%; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.legacy-import summary { color: var(--water-deep); font-size: 13px; cursor: pointer; line-height: 1.6; }
.legacy-import p { margin: 12px 0; font-size: 12px; }
.legacy-import code { overflow-wrap: anywhere; }
.legacy-import label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legacy-import textarea { width: 100%; resize: vertical; min-height: 110px; max-height: 300px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font: 12px/1.6 monospace; background: #fffefb; color: var(--ink); }
.legacy-import textarea:focus-visible, .legacy-import summary:focus-visible { outline: 3px solid #82b4a8; outline-offset: 3px; }
.legacy-import .btn { margin-top: 10px; }
