:root {
  --ink: #132126;
  --muted: #6f7d7e;
  --paper: #eef1ea;
  --panel: rgba(255, 253, 246, 0.94);
  --panel-solid: #fffdf6;
  --line: rgba(30, 45, 44, 0.14);
  --water: #5e9e9f;
  --deep: #174a62;
  --accent: #e55337;
  --accent-dark: #a33326;
  --gold: #d9a33a;
  --good: #2d9b69;
  --warn: #d4932c;
  --bad: #c84343;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html,
body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(243, 218, 155, 0.55), transparent 30%),
    linear-gradient(180deg, #cbded8 0%, #a9c2bb 45%, #7a9894 100%);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  touch-action: manipulation;
  user-select: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100vw, 520px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.82), rgba(234, 239, 230, 0.94) 48%, rgba(232, 237, 228, 0.98)),
    var(--paper);
}

.topbar,
.hud,
.controls,
.meters {
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 7px;
  margin-bottom: 6px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.app-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: 0 5px 12px rgba(4, 79, 61, 0.22);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  flex: 0 0 auto;
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.icon-button,
.top-actions .tab {
  width: 36px;
  height: 34px;
  border: 1px solid rgba(20, 38, 42, 0.16);
  border-radius: 9px;
  background: linear-gradient(180deg, #fffaf0, #eee5d4);
  box-shadow: 0 4px 12px rgba(36, 52, 46, 0.14);
  color: #45575a;
  font-size: 11px;
  font-weight: 900;
}

.icon-button {
  width: 44px;
}

.top-actions .tab.active {
  border-color: rgba(229, 83, 55, 0.5);
  background: #fff4e8;
  color: var(--accent-dark);
}

.hud {
  grid-column: 1 / -1;
  grid-template-columns: 0.72fr 1.1fr 1.1fr;
  gap: 6px;
  margin-bottom: 0;
}

.stat {
  min-width: 0;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.88);
  box-shadow: 0 4px 14px rgba(35, 48, 45, 0.08);
  backdrop-filter: blur(14px);
}

.stat span,
.meter span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.stat strong {
  display: block;
  overflow: hidden;
  margin-top: 0;
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat:first-child strong {
  color: #9b6820;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 48, 57, 0.22);
  border-radius: 8px;
  background: #7eb0aa;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 13px 28px rgba(26, 47, 48, 0.22);
  height: auto;
}

.stage::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 22%),
    radial-gradient(circle at 72% 78%, rgba(255, 242, 192, 0.24), transparent 18%);
  mix-blend-mode: screen;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.condition-chip {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  max-width: calc(100% - 174px);
  overflow: hidden;
  padding: 7px 10px;
  border: 1px solid rgba(22, 32, 38, 0.12);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.82);
  box-shadow: 0 6px 16px rgba(16, 29, 33, 0.12);
  color: #34484b;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

.toast {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid rgba(22, 32, 38, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 0 8px 20px rgba(16, 29, 33, 0.16);
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
  text-align: center;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(14px);
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
}

.meters {
  grid-template-columns: 1fr;
  margin: 7px 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.65);
}

.meter {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 8px;
}

.track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(30, 45, 44, 0.13);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ee785c, var(--accent));
  box-shadow: 0 0 12px rgba(229, 83, 55, 0.4);
  transition: width 90ms linear, background-color 90ms linear;
}

.tension i {
  background: linear-gradient(90deg, #ecc063, var(--warn));
}

.stamina i {
  background: linear-gradient(90deg, #61c58b, var(--good));
}

.controls {
  grid-template-columns: 1.1fr 0.9fr 0.9fr 0.82fr;
  grid-template-areas: "cast reel jerk pause";
  gap: 7px;
  margin-bottom: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.controls button {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 7px 6px;
  border: 1px solid rgba(38, 49, 46, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf7, #eee8dc);
  box-shadow: 0 5px 12px rgba(31, 43, 39, 0.12);
  font-size: 14px;
  font-weight: 850;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.controls button * {
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

#castButton {
  grid-area: cast;
  min-height: 98px;
  font-size: 17px;
}

#reelButton {
  grid-area: reel;
  min-height: 98px;
  border-radius: 999px;
  font-size: 16px;
}

#jerkButton {
  grid-area: jerk;
  min-height: 98px;
  border-radius: 999px;
  border-color: rgba(229, 83, 55, 0.38);
  background: linear-gradient(180deg, #fff8ef, #f2dfd0);
  font-size: 16px;
}

#pauseButton {
  grid-area: pause;
  min-height: 98px;
  border-radius: 999px;
}

.control-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(16, 28, 30, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  font-size: 19px;
  font-weight: 950;
  line-height: 1;
}

#castButton .control-icon {
  width: 42px;
  height: 42px;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.18);
  font-size: 28px;
}

#reelButton .control-icon,
#jerkButton .control-icon {
  width: 42px;
  height: 42px;
  font-size: 25px;
}

.controls button:active,
.controls button.held {
  transform: translateY(1px);
  background: linear-gradient(180deg, #efe5d6, #ded2bd);
  box-shadow: 0 2px 6px rgba(31, 43, 39, 0.1);
}

.controls .primary {
  border-color: var(--accent-dark);
  background: linear-gradient(180deg, #ff7458, var(--accent));
  color: white;
  text-shadow: 0 1px 1px rgba(102, 26, 20, 0.45);
}

.controls .primary::before {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  content: "";
}

.panel {
  display: none;
}

.panel.active {
  position: fixed;
  left: max(10px, calc((100vw - 520px) / 2 + 10px));
  right: max(10px, calc((100vw - 520px) / 2 + 10px));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 20;
  display: block;
  max-height: min(64dvh, 620px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(25, 43, 43, 0.18);
  border-radius: 14px;
  background: rgba(248, 246, 238, 0.97);
  box-shadow: 0 18px 56px rgba(12, 26, 30, 0.32);
  backdrop-filter: blur(18px);
}

.panel-title {
  position: sticky;
  top: -12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -12px -12px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(30, 45, 44, 0.1);
  background: rgba(248, 246, 238, 0.96);
}

.panel-title strong {
  font-size: 15px;
}

.panel-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(30, 45, 44, 0.14);
  border-radius: 8px;
  background: var(--panel-solid);
  font-size: 21px;
  font-weight: 800;
}

.intel,
.book-list {
  display: grid;
  gap: 7px;
}

.book-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.intel p {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.82);
  color: #2a383d;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.42;
}

.book-card {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 7px;
  min-height: 172px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.86);
  box-shadow: 0 4px 12px rgba(31, 43, 39, 0.08);
}

.book-card.locked {
  filter: saturate(0.4);
}

.fish-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 190 / 120;
  border-radius: 8px;
  background: #e9efe7;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.book-card b,
.book-card span,
.book-card em {
  display: block;
}

.book-card b {
  font-size: 13px;
}

.book-card span {
  margin-top: 4px;
  color: #516266;
  font-size: 11px;
  line-height: 1.35;
}

.book-card em {
  margin-top: 5px;
  color: #9b6820;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.gear-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.gear-switch-list {
  display: grid;
  gap: 10px;
}

.switch-group {
  display: grid;
  gap: 7px;
}

.switch-group h3 {
  margin: 0;
  color: #435256;
  font-size: 13px;
}

.switch-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.switch-card {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-height: 92px;
  padding: 8px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: 0 4px 12px rgba(31, 43, 39, 0.08);
}

.switch-card.active {
  border-color: rgba(229, 83, 55, 0.82);
  background: #fff7ee;
  outline: 2px solid rgba(229, 83, 55, 0.14);
}

.switch-card b {
  overflow: hidden;
  max-width: 100%;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gear-card,
.shop-list button {
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  text-align: left;
  box-shadow: 0 4px 12px rgba(31, 43, 39, 0.08);
}

.gear-card {
  display: grid;
  gap: 6px;
}

.lure-thumb {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef3ec, #fff9ee);
}

.gear-card.active {
  border-color: rgba(229, 83, 55, 0.82);
  background: #fff7ee;
  outline: 2px solid rgba(229, 83, 55, 0.16);
}

.gear-card b,
.shop-list b {
  display: block;
  font-size: 14px;
}

.gear-card span,
.shop-list span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.shop-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 0 14px 10px;
}

.shop-tab {
  min-height: 34px;
  border: 1px solid rgba(30, 45, 44, 0.12);
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.72);
  color: #627174;
  font-size: 12px;
  font-weight: 900;
}

.shop-tab.active {
  border-color: rgba(229, 83, 55, 0.48);
  background: #fff4e8;
  color: var(--accent-dark);
}

dialog {
  width: min(calc(100vw - 24px), 480px);
  padding: 0;
  border: 1px solid rgba(28, 45, 43, 0.18);
  border-radius: 8px;
  background: #f5f1e8;
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(12, 26, 30, 0.32);
}

dialog::backdrop {
  background: rgba(15, 24, 28, 0.48);
  backdrop-filter: blur(3px);
}

dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
}

dialog h2 {
  font-size: 18px;
}

dialog header button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(30, 45, 44, 0.14);
  border-radius: 8px;
  background: var(--panel-solid);
  font-size: 22px;
}

.shop-list {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
  max-height: min(62vh, 650px);
  overflow: auto;
}

.shop-group {
  display: grid;
  gap: 8px;
}

.shop-group h3 {
  margin: 0;
  color: #435256;
  font-size: 13px;
}

.shop-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 10px;
}

.spot-map-list {
  display: grid;
  gap: 9px;
  padding: 0 14px 14px;
  max-height: min(68vh, 690px);
  overflow: auto;
}

.spot-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-solid);
  box-shadow: 0 5px 14px rgba(31, 43, 39, 0.08);
  text-align: left;
}

.spot-card.active {
  border-color: rgba(229, 83, 55, 0.82);
  background: #fff7ee;
  outline: 2px solid rgba(229, 83, 55, 0.14);
}

.spot-card strong {
  font-size: 15px;
}

.spot-card span {
  color: #56666a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.spot-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.spot-badges i {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(36, 63, 66, 0.08);
  color: #405257;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.shop-card.equipped {
  border-color: rgba(229, 83, 55, 0.82);
  background: #fff7ee;
  outline: 2px solid rgba(229, 83, 55, 0.14);
}

.gear-thumb {
  width: 72px;
  height: 50px;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef3ec, #fff9ee);
}

.shop-copy {
  min-width: 0;
}

.shop-list em {
  display: block;
  margin-top: 7px;
  color: var(--accent-dark);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

@media (max-height: 790px) {
  #castButton {
    min-height: 82px;
  }

  #reelButton,
  #jerkButton,
  #pauseButton {
    min-height: 82px;
  }

  .meters {
    margin: 5px 0;
    padding: 6px;
  }

  .meter {
    gap: 6px;
  }

  .track {
    height: 8px;
  }

  .control-icon {
    width: 26px;
    height: 26px;
    font-size: 17px;
  }

  #castButton .control-icon,
  #reelButton .control-icon,
  #jerkButton .control-icon {
    width: 34px;
    height: 34px;
    font-size: 22px;
  }

  .intel p,
  .book-card {
    padding: 8px;
  }
}

@media (max-width: 370px) {
  .app {
    padding-left: 8px;
    padding-right: 8px;
  }

  h1 {
    font-size: 18px;
  }

  .controls button {
    font-size: 11px;
  }

  .top-actions {
    gap: 3px;
  }

  .icon-button,
  .top-actions .tab {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }

  .icon-button {
    width: 40px;
  }

  .condition-chip {
    max-width: calc(100% - 138px);
    padding: 6px 8px;
    font-size: 10px;
  }

  .book-list {
    grid-template-columns: 1fr;
  }
}
