:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8b6dff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --gold: #ffc934;
  --font:
    "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
}
body {
  padding: 10px;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid #ffd84d;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  font: inherit;
  font-size: 12px;
}

.da-shell {
  width: min(900px, 100%);
  margin: 0 auto;
}

/* ---------- HUD ---------- */
.da-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.da-logo {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 3px 0 #23115e;
}
.da-logo span,
.da-card-logo span {
  background: linear-gradient(180deg, #7ff0ff, #2aa8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.da-chips {
  display: flex;
  gap: 6px;
  min-width: 0;
}
.da-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.da-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.da-chip strong {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.da-chip-coins {
  padding-left: 8px;
  background: linear-gradient(180deg, #3a2f12, #2a2310);
  box-shadow:
    inset 0 0 0 2px rgba(255, 201, 52, 0.35),
    0 3px 0 rgba(0, 0, 0, 0.35);
}
.da-chip-coins strong {
  color: var(--gold);
  font-size: 18px;
  min-width: 2ch;
}
.da-chip-btn {
  cursor: pointer;
  background: linear-gradient(180deg, #7a5bff, var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 3px 0 #3a1fb3;
}
.da-chip-btn span {
  color: #e6ddff;
}
.da-chip-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a1fb3;
}
.bump {
  animation: bump 0.35s ease;
}
@keyframes bump {
  40% {
    transform: scale(1.14);
  }
}

.da-coin {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    #fff6c2 0 18%,
    #ffd84d 30%,
    #f0a400 75%,
    #c47d00
  );
  box-shadow:
    inset 0 -2px 0 rgba(120, 60, 0, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ---------- Layout ---------- */
.da-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 12px;
  align-items: start;
}
.da-stage {
  display: flex;
  justify-content: center;
  min-width: 0;
}
.da-scene {
  position: relative;
  width: min(100%, calc((100vh - 84px) * 0.8));
  max-width: 520px;
  aspect-ratio: 4 / 5;
  border-radius: 22px;
  overflow: hidden;
  background: #1b7fd6;
  box-shadow:
    0 0 0 3px #26284a,
    0 14px 40px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.da-scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.da-scene canvas:focus-visible {
  outline: none;
}
.da-scene:has(canvas:focus-visible) {
  box-shadow:
    0 0 0 3px #ffd84d,
    0 14px 40px rgba(0, 0, 0, 0.5);
}
.da-scene.shake {
  animation: shake 0.4s ease;
}
@keyframes shake {
  20% {
    transform: translateX(-7px) rotate(-0.6deg);
  }
  40% {
    transform: translateX(6px) rotate(0.5deg);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}

.da-meter {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  pointer-events: none;
}
.da-meter[hidden] {
  display: none;
}
.da-meter-chip {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(8, 16, 48, 0.62);
  backdrop-filter: blur(4px);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.18);
}
.da-meter-chip span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a9d8ff;
}
.da-meter-chip strong {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.da-meter-chip.full strong {
  color: #ffd84d;
}

.da-phase {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 900;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(180deg, #ff7aa8, #ff3d6e);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 #a3163f,
    0 10px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.da-phase.up {
  background: linear-gradient(180deg, #5ff2b0, #13b97a);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 #0a7a50,
    0 10px 24px rgba(0, 0, 0, 0.35);
}
.da-phase.gold {
  background: linear-gradient(180deg, #ffe27a, #ffb300);
  color: #5a3500;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 4px 0 #b36b00,
    0 10px 24px rgba(0, 0, 0, 0.35);
}
.da-phase.show {
  animation: phase 1.3s ease forwards;
}
@keyframes phase {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  25% {
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(1);
  }
}

.da-toasts {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 6;
  display: grid;
  justify-items: center;
  gap: 6px;
  pointer-events: none;
}
.da-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #2d2f4a, #212233);
  box-shadow:
    inset 0 0 0 2px rgba(255, 201, 52, 0.5),
    0 10px 24px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  font-weight: 800;
  animation: toast 4.2s ease forwards;
}
.da-toast b {
  color: var(--gold);
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: translateY(-14px) scale(0.9);
  }
  8%,
  88% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.da-cast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 34px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #8a6dff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 5px 0 #3a1fb3,
    0 12px 26px rgba(20, 0, 80, 0.45);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
}
.da-cast[hidden] {
  display: none;
}
.da-cast:active {
  transform: translateX(-50%) translateY(3px);
  box-shadow: 0 2px 0 #3a1fb3;
}
.da-cast-ico {
  font-size: 22px;
}
@keyframes pulse {
  50% {
    scale: 1.06;
  }
}

/* ---------- Overlays ---------- */
.da-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(
    circle at 50% 40%,
    rgba(15, 16, 32, 0.35),
    rgba(15, 16, 32, 0.78)
  );
}
.da-overlay[hidden],
.da-modal[hidden] {
  display: none;
}
.da-card {
  width: min(100%, 360px);
  padding: 22px 20px 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, #25263a, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 2px #2f3150,
    0 18px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}
.da-card-logo {
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 0 #23115e;
}
.da-card p {
  margin: 12px 0 0;
  color: #d8daea;
  font-size: 15px;
  line-height: 1.4;
}
.da-card p b {
  color: #fff;
}
.da-card .da-hint {
  color: var(--muted);
  font-size: 12px;
}
.da-btn {
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}
.da-btn:active {
  transform: translateY(3px);
}
.da-btn-primary {
  background: linear-gradient(180deg, #8a6dff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3a1fb3;
}
.da-btn-primary:active {
  box-shadow: 0 1px 0 #3a1fb3;
}
.da-btn-secondary {
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 0 #15162a;
}
.da-btn-big {
  min-height: 58px;
  margin-top: 18px;
  padding: 0 56px;
  font-size: 24px;
}
.da-btn-icon {
  width: 44px;
  padding: 0;
}
.da-card-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.da-result-title {
  font-size: 28px;
  font-weight: 900;
  text-shadow: 0 3px 0 #23115e;
}
.da-result-coins {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.da-result-coins .da-coin {
  width: 30px;
  height: 30px;
}
.da-result-coins strong {
  font-size: 40px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 3px 0 #8a5a00;
}
.da-result-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.da-result-list li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 800;
  animation: pop-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}
.da-result-list li.new {
  box-shadow: inset 0 0 0 2px #ffd84d;
}
.da-result-list canvas {
  width: 40px;
  height: 26px;
}
.da-result-list em {
  font-style: normal;
  color: var(--gold);
}
.da-result-note {
  min-height: 1em;
}

/* ---------- Upgrade panel ---------- */
.da-panel {
  padding: 14px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: inset 0 0 0 2px #25263b;
}
.da-panel-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.da-upgrades {
  display: grid;
  gap: 10px;
}
.da-up {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px 12px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #2a2b40, var(--panel-2));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 0 #121322;
  text-align: left;
  cursor: pointer;
  transition: filter 0.15s;
}
.da-up:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #121322;
}
.da-up.afford {
  box-shadow:
    inset 0 0 0 2px rgba(104, 66, 255, 0.9),
    0 4px 0 #3a1fb3;
}
.da-up.afford .da-up-cost {
  background: linear-gradient(180deg, #8a6dff, var(--accent));
  color: #fff;
}
.da-up.poor .da-up-cost b {
  color: #ff8fa6;
}
.da-up:disabled {
  cursor: default;
  filter: saturate(0.4) brightness(0.8);
}
.da-up.maxed .da-up-cost {
  background: #2d3a2d;
  color: #8ff0a4;
}
.da-up.shake {
  animation: shake 0.35s ease;
}
.da-up.bought {
  animation: bump 0.4s ease;
}
.da-up-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}
.da-up-ico svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.da-up-ico-fish svg {
  fill: #fff;
  stroke: none;
}
.da-up-ico-fish svg circle {
  fill: #ff7a2a;
}
.da-up-ico-depth {
  background: linear-gradient(180deg, #4fd2ff, #1677e0);
}
.da-up-ico-fish {
  background: linear-gradient(180deg, #ffa24f, #ff6a2a);
}
.da-up-ico-offline {
  background: linear-gradient(180deg, #62f0b0, #16a874);
}
.da-up-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.da-up-name {
  font-size: 15px;
  font-weight: 900;
}
.da-up-val {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.da-up-val i {
  font-style: normal;
  color: #7dff9e;
}
.da-up-cost {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: #15162a;
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.da-up-lvl {
  position: absolute;
  top: -7px;
  left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #3a3c58;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
}
.da-panel-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ---------- Collection book ---------- */
.da-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(8, 9, 20, 0.72);
}
.da-card-book {
  width: min(100%, 620px);
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 16px;
  text-align: left;
}
.da-book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.da-book-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}
.da-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.da-book-grid li {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 6px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #1e5aa8, #133a78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-align: center;
}
.da-book-grid li.locked {
  background: #1d1e2e;
}
.da-book-grid li.rare {
  background: linear-gradient(180deg, #b37a00, #6b4300);
}
.da-book-grid canvas {
  width: 88px;
  height: 56px;
}
.da-book-name {
  font-size: 13px;
  font-weight: 900;
}
.da-book-meta {
  font-size: 11px;
  color: #c7d4f0;
}
.da-book-grid li.locked .da-book-meta,
.da-book-grid li.locked .da-book-name {
  color: #6f7290;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  body {
    padding: 8px;
  }
  .da-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .da-scene {
    width: 100%;
    max-width: 480px;
    aspect-ratio: 4 / 5;
  }
  .da-panel {
    padding: 10px;
  }
  .da-panel-title,
  .da-panel-note {
    display: none;
  }
  .da-upgrades {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .da-up {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 5px;
    padding: 12px 6px 10px;
    text-align: center;
  }
  .da-up-body {
    justify-items: center;
  }
  .da-up-ico {
    width: 38px;
    height: 38px;
  }
  .da-up-name {
    font-size: 12px;
    line-height: 1.1;
  }
  .da-up-val {
    font-size: 11px;
  }
  .da-up-cost {
    font-size: 13px;
  }
  .da-up-cost .da-coin {
    width: 15px;
    height: 15px;
  }
}
@media (max-width: 520px) {
  .da-logo {
    font-size: 19px;
  }
  .da-chip {
    padding: 4px 9px;
    gap: 4px;
  }
  .da-chip span {
    font-size: 9px;
  }
  .da-chip strong {
    font-size: 14px;
  }
  .da-chip-hide-sm {
    display: none;
  }
}
@media (max-width: 380px) {
  .da-logo {
    font-size: 16px;
  }
  .da-chip:not(.da-chip-coins):not(.da-chip-btn) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
  .da-phase.show {
    animation: none;
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  .da-toast {
    animation: none;
  }
}
