:root {
  color-scheme: light;
  --ink: #24201a;
  --ink-soft: #59452e;
  --paper: #f4dea8;
  --paper-light: #fff0c5;
  --wood: #8b431b;
  --wood-dark: #45200f;
  --red: #c23d23;
  --red-dark: #6d1c12;
  --blue: #1778a9;
  --blue-deep: #0a4266;
  --gold: #e2a52e;
  --gold-light: #ffd96a;
  --cream: #fff1c4;
  --shadow: rgba(35, 21, 12, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d4669;
}

body {
  font-family: "Trebuchet MS", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 3px solid #fff7c9;
  outline-offset: 3px;
}

.miniapp {
  position: relative;
  width: min(100%, 430px);
  height: 100vh;
  min-height: 600px;
  margin: 0 auto;
  overflow: hidden;
  background: #50a9cf;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}

.app-screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.app-screen.is-active {
  display: block;
}

.game-screen {
  z-index: 1;
  isolation: isolate;
}

.setup-art {
  position: absolute;
  inset: 0;
  z-index: -3;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 46%;
  transform: scale(1.04);
}

.setup-tint,
.lobby-wash {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.setup-tint {
  background:
    linear-gradient(180deg, rgba(17, 82, 116, 0.06) 0 34%, rgba(30, 27, 19, 0.2) 57%, rgba(24, 20, 13, 0.78) 100%),
    linear-gradient(90deg, rgba(10, 53, 76, 0.2), transparent 36% 64%, rgba(10, 53, 76, 0.2));
}

.setup-brand {
  position: absolute;
  top: max(24px, calc(env(safe-area-inset-top) + 14px));
  left: 50%;
  width: min(90%, 356px);
  color: #fff2b7;
  text-align: center;
  text-shadow: 0 3px 0 #632412, 0 5px 12px rgba(23, 15, 9, 0.58);
  transform: translateX(-50%) rotate(-1deg);
}

.setup-brand span,
.setup-brand strong {
  display: block;
  letter-spacing: 0;
}

.setup-brand span {
  font: 900 12px/1 Georgia, serif;
  text-transform: uppercase;
}

.setup-brand strong {
  margin-top: 5px;
  font: 900 30px/0.95 Georgia, serif;
}

.name-board {
  position: absolute;
  right: 17px;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  left: 17px;
  padding: 23px 22px 20px;
  border: 3px solid #603218;
  border-radius: 7px;
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(102, 70, 38, 0.08) 28px 29px),
    #f2d793;
  box-shadow: inset 0 0 0 3px #ffe6a3, 0 7px 0 #743a19, 0 17px 32px rgba(20, 13, 8, 0.48);
  transform: rotate(-0.5deg);
}

.step-kicker,
.port-heading span {
  display: block;
  color: #a53a21;
  font: 900 10px/1 Georgia, serif;
  text-align: center;
  text-transform: uppercase;
}

.name-board h1,
.port-heading h1 {
  margin: 7px 0 8px;
  color: #372619;
  font: 900 27px/1 Georgia, serif;
  text-align: center;
  letter-spacing: 0;
}

.name-board p {
  margin: 0 auto 17px;
  max-width: 270px;
  color: #67482c;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.name-board label {
  display: block;
  margin-bottom: 6px;
  color: #50331e;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.name-board input {
  display: block;
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 2px solid #6a3a1d;
  border-radius: 5px;
  outline: 0;
  color: #2f241a;
  background: rgba(255, 244, 201, 0.78);
  box-shadow: inset 0 2px 7px rgba(83, 47, 22, 0.18), 0 2px 0 rgba(255, 255, 255, 0.52);
  font: 900 16px/1 Georgia, serif;
  user-select: text;
}

.name-board input:focus {
  border-color: #15759f;
  box-shadow: inset 0 2px 7px rgba(83, 47, 22, 0.14), 0 0 0 3px rgba(33, 132, 172, 0.24);
}

.name-board input[aria-invalid="true"] {
  border-color: #b73722;
}

.form-error {
  display: block;
  min-height: 17px;
  padding-top: 4px;
  color: #a32e1f;
  font-size: 10px;
  font-weight: 900;
}

.setup-action,
.cancel-match {
  width: 100%;
  min-height: 52px;
  border: 2px solid #5c2015;
  border-radius: 5px;
  color: #fff1bd;
  background: #b93e25;
  box-shadow: inset 0 2px 0 rgba(255, 222, 126, 0.35), 0 4px 0 #6f2615;
  font: 900 16px/1 Georgia, serif;
  cursor: pointer;
}

.setup-action:active,
.cancel-match:active {
  transform: translateY(3px);
  box-shadow: inset 0 2px 0 rgba(255, 222, 126, 0.35), 0 1px 0 #6f2615;
}

.server-presence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 28px;
  margin-top: 13px;
  padding: 5px 9px;
  border: 1px solid rgba(77, 53, 29, 0.35);
  border-radius: 4px;
  color: #60452b;
  background: rgba(255, 239, 188, 0.48);
  font-size: 9px;
  font-weight: 900;
}

.server-presence i {
  display: block;
  width: 8px;
  height: 8px;
  border: 1px solid #285842;
  border-radius: 50%;
  background: #49b775;
  box-shadow: 0 0 0 3px rgba(73, 183, 117, 0.16), 0 0 8px rgba(42, 155, 91, 0.55);
  animation: online-pulse 1500ms ease-in-out infinite;
}

.server-presence b {
  color: #9d381f;
  font: 900 13px/1 Georgia, serif;
}

.server-presence.is-lobby {
  width: fit-content;
  margin: 10px auto 0;
  color: #563a25;
  background: rgba(250, 224, 158, 0.72);
  box-shadow: 0 2px 0 rgba(100, 55, 24, 0.34);
}

.network-preview {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 11px;
}

.network-preview span {
  min-width: 44px;
  padding: 4px 8px;
  border: 1px solid rgba(92, 55, 29, 0.42);
  border-radius: 3px;
  color: #775837;
  font-size: 9px;
  font-weight: 900;
  text-align: center;
}

.network-preview span.is-active {
  color: #fff2bd;
  border-color: #154f6e;
  background: #1679a5;
}

.lobby-art {
  object-position: 50% 42%;
  filter: saturate(0.95) contrast(0.96);
}

.lobby-wash {
  background:
    linear-gradient(180deg, rgba(12, 78, 111, 0.28), rgba(41, 94, 105, 0.12) 27%, rgba(236, 205, 137, 0.86) 55%, #e2ba6b 100%);
  backdrop-filter: blur(1px);
}

.lobby-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(69px + env(safe-area-inset-top));
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  color: #fff3c0;
  background: rgba(48, 27, 14, 0.76);
  border-bottom: 2px solid rgba(255, 210, 102, 0.46);
  box-shadow: 0 5px 15px rgba(39, 20, 9, 0.26);
  backdrop-filter: blur(8px);
}

.captain-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.captain-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 2px solid #573018;
  border-radius: 50%;
  color: #643214;
  background: #efbd49;
  box-shadow: inset 0 2px 0 #ffe496, 0 3px 0 #6a3517;
  font: 900 19px/1 Georgia, serif;
}

.captain-identity div {
  min-width: 0;
}

.captain-identity small,
.captain-identity strong {
  display: block;
  letter-spacing: 0;
}

.captain-identity small {
  margin-bottom: 3px;
  color: #e9bf6c;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.captain-identity strong {
  max-width: 240px;
  overflow: hidden;
  font: 900 16px/1 Georgia, serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-edit {
  flex: 0 0 38px;
  font-size: 19px;
}

.lobby-content {
  position: absolute;
  inset: calc(69px + env(safe-area-inset-top)) 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 23px 14px max(25px, calc(env(safe-area-inset-bottom) + 17px));
  scrollbar-width: none;
}

.lobby-content::-webkit-scrollbar {
  display: none;
}

.port-heading {
  margin-bottom: 15px;
}

.port-heading span {
  color: #6b311b;
}

.port-heading h1 {
  margin-bottom: 0;
  font-size: 29px;
  text-shadow: 0 2px 0 rgba(255, 239, 186, 0.7);
}

.chain-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 100%;
  padding: 4px;
  border: 2px solid #6b3a1e;
  border-radius: 6px;
  background: rgba(90, 47, 22, 0.58);
  box-shadow: inset 0 2px 5px rgba(41, 20, 8, 0.26), 0 3px 0 rgba(84, 42, 18, 0.72);
}

.chain-option {
  min-height: 35px;
  border: 0;
  border-radius: 3px;
  color: #ffeab1;
  background: transparent;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.chain-option.is-active {
  color: #52301b;
  background: #f0c358;
  box-shadow: inset 0 2px 0 #ffe598, 0 2px 0 #8b4a1c;
}

.mode-list {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 76px;
  padding: 10px 11px;
  border: 2px solid #66371b;
  border-radius: 7px;
  color: #352519;
  background: rgba(247, 218, 145, 0.95);
  box-shadow: inset 0 2px 0 rgba(255, 250, 210, 0.74), 0 4px 0 #82451d, 0 7px 13px rgba(52, 28, 11, 0.18);
  text-align: left;
  cursor: pointer;
}

.mode-card:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: inset 0 2px 0 rgba(255, 250, 210, 0.74), 0 1px 0 #82451d;
}

.mode-card.is-demo {
  color: #fff2bf;
  border-color: #153f53;
  background: #1b789f;
  box-shadow: inset 0 2px 0 rgba(164, 229, 242, 0.45), 0 4px 0 #154b67, 0 7px 13px rgba(24, 56, 67, 0.22);
}

.mode-card.has-open-table {
  margin-top: 7px;
  border-color: #18767b;
  background:
    linear-gradient(90deg, rgba(91, 210, 191, 0.18), transparent 38%),
    rgba(250, 224, 148, 0.98);
  animation: open-table-glow 1300ms ease-in-out infinite alternate;
}

.mode-card.has-open-table::before {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border: 2px solid rgba(83, 233, 203, 0.82);
  border-radius: 8px;
  box-shadow: 0 0 0 2px rgba(255, 224, 116, 0.35), 0 0 15px rgba(61, 206, 190, 0.76);
  pointer-events: none;
}

.mode-card.is-own-table {
  filter: saturate(0.88);
}

.mode-beacon {
  position: absolute;
  top: -12px;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 19px;
  padding: 3px 9px;
  border: 1px solid #174e52;
  border-radius: 3px;
  color: #fff3b8;
  background: #177a7c;
  box-shadow: inset 0 1px 0 rgba(184, 255, 236, 0.45), 0 2px 0 #4d2b18;
  font: 900 8px/1 Georgia, serif;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}

.mode-beacon i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #baf3a1;
  box-shadow: 0 0 7px #baf3a1;
}

.mode-card.has-open-table .mode-copy span {
  color: #316157;
}

.mode-card.has-open-table .mode-pot small {
  color: #126865;
  font-size: 8px;
}

.mode-card:disabled {
  cursor: default;
  filter: grayscale(0.7);
  opacity: 0.62;
}

.mode-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #693918;
  border-radius: 50%;
  color: #693818;
  background: #efb83d;
  box-shadow: inset 0 2px 0 #ffe58d, 0 2px 0 rgba(75, 35, 14, 0.62);
  font: 900 18px/1 Georgia, serif;
}

.is-demo .mode-icon {
  color: #194d66;
  border-color: #153d51;
  background: #a9e5ec;
  box-shadow: inset 0 2px 0 #e5ffff, 0 2px 0 #133d50;
}

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

.mode-copy strong,
.mode-copy span,
.mode-pot b,
.mode-pot small {
  display: block;
  letter-spacing: 0;
}

.mode-copy strong {
  font: 900 15px/1 Georgia, serif;
}

.mode-copy span {
  margin-top: 5px;
  color: #745033;
  font-size: 9px;
  font-weight: 800;
}

.is-demo .mode-copy span {
  color: #c7eef0;
}

.mode-pot {
  min-width: 74px;
  text-align: right;
}

.mode-pot b {
  color: #a53a22;
  font: 900 17px/1 Georgia, serif;
  white-space: nowrap;
}

.mode-pot small {
  margin-top: 5px;
  color: #6b4a2f;
  font-size: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.is-demo .mode-pot b {
  color: #ffe07b;
}

.is-demo .mode-pot small {
  color: #c8f2f1;
}

.mode-note {
  margin: 2px 3px 1px;
  color: #714629;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.matchmaking-view {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  place-content: center;
  justify-items: center;
  padding: max(34px, env(safe-area-inset-top)) 28px max(28px, env(safe-area-inset-bottom));
  color: #fff2be;
  text-align: center;
  background:
    linear-gradient(rgba(9, 59, 84, 0.86), rgba(24, 39, 37, 0.92)),
    url("./assets/sea-duel-open-chest-v2.jpg") center / cover;
}

.matchmaking-view.is-visible {
  display: grid;
}

.radar {
  position: relative;
  width: 168px;
  height: 168px;
  margin-bottom: 28px;
  border: 3px solid #f0c45b;
  border-radius: 50%;
  background:
    linear-gradient(transparent 49%, rgba(245, 211, 118, 0.36) 50% 51%, transparent 52%),
    linear-gradient(90deg, transparent 49%, rgba(245, 211, 118, 0.36) 50% 51%, transparent 52%),
    repeating-radial-gradient(circle, rgba(255, 226, 140, 0.08) 0 24px, rgba(244, 208, 111, 0.33) 25px 26px),
    rgba(12, 89, 112, 0.72);
  box-shadow: inset 0 0 28px rgba(163, 234, 227, 0.2), 0 6px 0 #543019, 0 0 30px rgba(101, 219, 217, 0.2);
  overflow: hidden;
}

.radar::before {
  content: "";
  position: absolute;
  inset: 50% 50% 0 0;
  background: linear-gradient(32deg, rgba(114, 225, 211, 0.56), transparent 74%);
  transform-origin: 100% 0;
  animation: radar-sweep 2200ms linear infinite;
}

.radar span {
  position: absolute;
  top: 47px;
  right: 35px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffe17a;
  box-shadow: 0 0 0 5px rgba(255, 225, 122, 0.18), 0 0 16px #ffe17a;
  animation: radar-dot 1500ms ease-in-out infinite;
}

.radar i {
  position: absolute;
  bottom: 39px;
  left: 47px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8be5d9;
  box-shadow: 0 0 10px #8be5d9;
}

.match-kicker {
  color: #efc85e;
  font: 900 11px/1 Georgia, serif;
  text-transform: uppercase;
}

.matchmaking-view h2 {
  margin: 9px 0 10px;
  font: 900 29px/1 Georgia, serif;
  letter-spacing: 0;
  text-shadow: 0 3px 0 #4e2012;
}

.matchmaking-view p {
  max-width: 310px;
  min-height: 47px;
  margin: 0;
  color: #d7eae0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.match-bot-link {
  margin-top: 6px;
  color: #ffe082;
  font-size: 10px;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.match-stake {
  min-width: 205px;
  margin: 21px 0 17px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 224, 131, 0.42);
  border-radius: 4px;
  color: #ffe28c;
  background: rgba(30, 18, 10, 0.36);
  font: 900 13px/1 Georgia, serif;
}

.cancel-match {
  width: min(100%, 300px);
  background: #a43a27;
}

.cancel-match:disabled {
  cursor: default;
  filter: saturate(0.55);
  opacity: 0.78;
}

@keyframes radar-sweep {
  to { transform: rotate(360deg); }
}

@keyframes radar-dot {
  0%, 100% { opacity: 0.35; transform: scale(0.75); }
  45% { opacity: 1; transform: scale(1.2); }
}

@keyframes online-pulse {
  0%, 100% { opacity: 0.62; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes open-table-glow {
  from {
    box-shadow: inset 0 2px 0 rgba(255, 250, 210, 0.74), 0 4px 0 #6d4b21, 0 0 7px rgba(51, 188, 172, 0.42);
  }
  to {
    box-shadow: inset 0 2px 0 rgba(255, 250, 210, 0.9), 0 4px 0 #6d4b21, 0 0 20px rgba(59, 226, 199, 0.9);
  }
}

@supports (height: 100dvh) {
  .miniapp {
    height: 100dvh;
  }
}

.scene-art {
  position: absolute;
  inset: 0;
  z-index: -3;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.paper-grain {
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: 0.09;
  pointer-events: none;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(17deg, transparent 0 3px, rgba(42, 27, 14, 0.17) 4px, transparent 5px),
    repeating-linear-gradient(103deg, transparent 0 5px, rgba(255, 255, 255, 0.22) 6px, transparent 7px);
}

.wave-shine {
  position: absolute;
  left: -12%;
  right: -12%;
  top: 57%;
  z-index: -1;
  height: 17%;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 247, 191, 0.34);
  filter: blur(18px);
  transform: translateX(-40%);
}

.miniapp.is-flashing .wave-shine {
  animation: sea-flash 480ms ease-out;
}

.damage-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.ship-damage {
  --damage-level: 0;
  position: absolute;
  top: 27%;
  width: 39%;
  height: 54%;
  overflow: visible;
}

.ship-damage.is-you {
  left: 0;
}

.ship-damage.is-rival {
  right: 0;
}

.damage-marks {
  position: absolute;
  inset: 0;
}

.damage-mark {
  position: absolute;
  top: var(--damage-y);
  left: var(--damage-x);
  display: block;
  width: 17px;
  height: 15px;
  border: 3px solid rgba(76, 36, 15, 0.9);
  border-radius: 48% 52% 43% 57%;
  background: #211813;
  box-shadow:
    inset 2px 1px 0 rgba(0, 0, 0, 0.7),
    0 0 0 2px rgba(188, 93, 28, 0.45),
    0 4px 6px rgba(23, 13, 8, 0.34);
  transform: translate(-50%, -50%) rotate(var(--damage-rotate));
}

.damage-mark::before,
.damage-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 27px;
  height: 2px;
  border-radius: 2px;
  background: #4c2718;
  transform-origin: left center;
}

.damage-mark::before {
  transform: rotate(32deg);
}

.damage-mark::after {
  transform: rotate(-42deg);
}

.damage-mark.is-fresh {
  animation: damage-arrive 620ms ease-out both;
}

.critical-damage {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 800ms ease;
}

.ship-damage.is-critical .critical-damage {
  opacity: 1;
}

.mast-fragment {
  position: absolute;
  top: 4%;
  left: 12%;
  width: 8px;
  height: 154px;
  border: 2px solid #3d2416;
  border-radius: 4px;
  background: #835125;
  box-shadow: inset 2px 0 0 #c18a44, 3px 4px 8px rgba(39, 21, 10, 0.36);
  opacity: 0;
  transform: rotate(0) scaleY(0.92);
  transform-origin: 50% 88%;
}

.ship-damage.is-you .mast-fragment {
  left: 9%;
}

.ship-damage.is-rival .mast-fragment {
  right: 9%;
  left: auto;
}

.mast-fragment::before {
  content: "";
  position: absolute;
  top: 25px;
  left: 6px;
  width: 70px;
  height: 56px;
  border: 2px solid rgba(76, 45, 24, 0.78);
  background: rgba(232, 207, 151, 0.92);
  clip-path: polygon(0 0, 100% 18%, 68% 72%, 40% 54%, 0 100%);
}

.ship-damage.is-rival .mast-fragment::before {
  right: 6px;
  left: auto;
  transform: scaleX(-1);
}

.ship-damage.is-you.is-critical .mast-fragment {
  animation: mast-fall-left 1250ms cubic-bezier(0.18, 0.72, 0.22, 1) both;
}

.ship-damage.is-rival.is-critical .mast-fragment {
  animation: mast-fall-right 1250ms cubic-bezier(0.18, 0.72, 0.22, 1) both;
}

.mast-smoke,
.heavy-smoke {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: rgba(70, 68, 60, 0.86);
  filter: blur(1px);
}

.mast-smoke {
  top: 5%;
  left: -3%;
  width: 50px;
  height: 40px;
  box-shadow:
    25px -14px 0 5px rgba(86, 82, 70, 0.74),
    47px 2px 0 1px rgba(55, 54, 49, 0.7),
    14px 22px 0 4px rgba(89, 77, 62, 0.68);
  animation: smoke-breathe 1600ms ease-in-out infinite alternate;
}

.ship-damage.is-rival .mast-smoke {
  right: -3%;
  left: auto;
  transform: scaleX(-1);
}

.heavy-smoke {
  top: 65%;
  left: 21%;
  width: 52px;
  height: 42px;
  box-shadow:
    23px -26px 0 4px rgba(58, 58, 54, 0.76),
    45px -7px 0 1px rgba(83, 78, 67, 0.68);
  animation: smoke-rise 2100ms ease-in-out infinite;
}

.ship-damage.is-rival .heavy-smoke {
  right: 21%;
  left: auto;
}

.hull-fire {
  position: absolute;
  top: 72%;
  left: 42%;
  width: 24px;
  height: 38px;
  border-radius: 50% 50% 45% 45%;
  background: #f0ae2f;
  box-shadow: inset 0 -12px 0 #bd3d1d, 0 0 17px rgba(255, 139, 29, 0.8);
  clip-path: polygon(50% 0, 75% 35%, 100% 22%, 89% 74%, 62% 100%, 24% 88%, 0 52%, 28% 38%);
  animation: fire-flicker 440ms ease-in-out infinite alternate;
}

.ship-damage.is-rival .hull-fire {
  right: 42%;
  left: auto;
}

.ship-damage.is-ruined .mast-smoke,
.ship-damage.is-ruined .heavy-smoke {
  filter: blur(3px);
  transform: scale(1.28);
}

.ship-damage.is-ruined .hull-fire {
  transform: scale(1.3);
}

.ship-damage.is-destroyed .heavy-smoke {
  box-shadow:
    23px -26px 0 7px rgba(45, 45, 42, 0.86),
    50px -14px 0 5px rgba(72, 68, 59, 0.8),
    -12px -32px 0 3px rgba(61, 59, 53, 0.72);
}

.ship-damage.is-destroyed .hull-fire {
  width: 32px;
  height: 49px;
}

.shot-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.treasure-gold {
  --gold-level: 0;
  --gold-blur: 3px;
  --gold-opacity: 0.18;
  position: absolute;
  top: 55.2%;
  left: 50%;
  z-index: 3;
  width: 104px;
  height: 78px;
  pointer-events: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 0 var(--gold-blur) rgba(255, 198, 49, var(--gold-opacity)));
}

.gold-pile {
  position: absolute;
  inset: 0;
}

.gold-pile span {
  position: absolute;
  top: 20px;
  left: 50%;
  display: block;
  width: 18px;
  height: 13px;
  border: 2px solid #6e3914;
  border-radius: 50%;
  background: #f2b82f;
  box-shadow: inset 0 0 0 2px #ffdc68, 0 2px 0 #8c4918, 0 3px 5px rgba(65, 34, 12, 0.35);
  transform: translate(var(--pile-x), var(--pile-y)) rotate(var(--pile-rotate));
  animation: pile-land 320ms ease-out both;
}

.gold-pile span::after,
.falling-coin::after {
  content: "";
  position: absolute;
  inset: 2px 4px;
  border: 1px solid rgba(123, 66, 17, 0.72);
  border-radius: 50%;
}

.treasure-gold.is-catching {
  animation: treasure-catch 460ms 560ms ease-out both;
}

.battle-finale {
  position: absolute;
  inset: 0;
  z-index: 11;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

.game-screen.finale-you .battle-finale,
.game-screen.finale-rival .battle-finale {
  visibility: visible;
}

.finale-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(255, 238, 155, 0.64);
}

.empty-treasure-rock {
  position: absolute;
  top: 55.1%;
  left: 50%;
  width: 92px;
  height: 88px;
  opacity: 0;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 236, 170, 0.42) 0 4px, transparent 5px),
    linear-gradient(135deg, #b5a77e, #8d836a 62%, #67675c);
  border: 2px solid rgba(85, 71, 51, 0.46);
  box-shadow: inset -10px -11px 0 rgba(57, 61, 55, 0.18), 0 6px 9px rgba(33, 23, 15, 0.17);
  clip-path: polygon(15% 8%, 62% 0, 91% 20%, 100% 63%, 83% 100%, 16% 92%, 0 57%);
  transform: translate(-50%, -12%);
}

.game-screen.finale-you .empty-treasure-rock,
.game-screen.finale-rival .empty-treasure-rock {
  animation: reveal-empty-rock 620ms 260ms ease-out both;
}

.game-screen.finale-you .finale-flash,
.game-screen.finale-rival .finale-flash {
  animation: finale-flash 700ms ease-out both;
}

.finale-chest {
  position: absolute;
  top: 56%;
  left: 50%;
  width: 68px;
  height: 43px;
  border: 3px solid #4c2815;
  border-radius: 4px 4px 9px 9px;
  background:
    linear-gradient(90deg, transparent 44%, #e8b64b 45% 57%, transparent 58%),
    repeating-linear-gradient(90deg, #8c461c 0 19px, #b96325 20px 22px);
  box-shadow: inset 0 -7px 0 rgba(67, 27, 9, 0.34), 0 5px 0 #512513, 0 9px 15px rgba(30, 15, 7, 0.4);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.72);
}

.finale-chest::before {
  content: "";
  position: absolute;
  right: -3px;
  bottom: calc(100% - 4px);
  left: -3px;
  height: 28px;
  border: 3px solid #4c2815;
  border-radius: 50% 50% 3px 3px;
  background:
    linear-gradient(90deg, transparent 44%, #e8b64b 45% 57%, transparent 58%),
    repeating-linear-gradient(90deg, #9e501f 0 19px, #c46c2b 20px 22px);
  transform: rotateX(34deg);
  transform-origin: 50% 100%;
}

.finale-chest::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 50%;
  width: 14px;
  height: 17px;
  border: 2px solid #75400f;
  border-radius: 3px;
  background: #f2c654;
  transform: translateX(-50%);
}

.finale-coins {
  position: absolute;
  top: -8px;
  left: 8px;
  width: 13px;
  height: 9px;
  border: 2px solid #824814;
  border-radius: 50%;
  background: #ffd760;
  box-shadow:
    14px -4px 0 -1px #efb534,
    27px 2px 0 -1px #ffd760,
    41px -3px 0 -1px #e9a728,
    9px 6px 0 -1px #f3bd39,
    34px 7px 0 -1px #f7c743;
}

.game-screen.finale-you .finale-chest {
  animation: chest-to-left 2400ms 250ms cubic-bezier(0.18, 0.75, 0.2, 1) both;
}

.game-screen.finale-rival .finale-chest {
  animation: chest-to-right 2400ms 250ms cubic-bezier(0.18, 0.75, 0.2, 1) both;
}

.game-screen.finale-you .treasure-gold,
.game-screen.finale-rival .treasure-gold {
  animation: treasure-departs 720ms ease-in both;
}

.sink-curtain {
  position: absolute;
  top: 42%;
  bottom: -7%;
  width: 51%;
  opacity: 0;
  background: linear-gradient(180deg, rgba(67, 174, 191, 0.58), rgba(8, 90, 123, 0.94) 43%, #074669 100%);
  clip-path: polygon(0 7%, 9% 2%, 20% 8%, 32% 1%, 47% 8%, 60% 3%, 73% 9%, 86% 1%, 100% 7%, 100% 100%, 0 100%);
  transform: translateY(100%);
}

.sink-curtain.is-you {
  left: 0;
}

.sink-curtain.is-rival {
  right: 0;
  transform: translateY(100%) scaleX(-1);
}

.game-screen.finale-you .sink-curtain.is-rival,
.game-screen.finale-rival .sink-curtain.is-you {
  animation: water-swallow 2750ms 470ms cubic-bezier(0.32, 0.05, 0.45, 1) both;
}

.sinking-wreck {
  position: absolute;
  top: 57%;
  width: 42%;
  height: 180px;
  opacity: 0;
  transform-origin: 50% 72%;
}

.sinking-wreck.is-you {
  left: 1%;
}

.sinking-wreck.is-rival {
  right: 1%;
  transform: scaleX(-1);
}

.wreck-hull {
  position: absolute;
  top: 75px;
  left: 8px;
  width: 145px;
  height: 57px;
  border: 4px solid #321d13;
  border-radius: 8px 8px 62% 43%;
  background:
    repeating-linear-gradient(0deg, #6b361c 0 9px, #3e2519 10px 13px);
  box-shadow: inset -17px -13px 0 rgba(28, 18, 13, 0.28), 0 7px 11px rgba(22, 15, 10, 0.44);
  clip-path: polygon(0 0, 100% 5%, 88% 78%, 64% 100%, 18% 83%);
}

.wreck-mast {
  position: absolute;
  top: 1px;
  left: 78px;
  width: 8px;
  height: 102px;
  border: 2px solid #301d13;
  border-radius: 4px;
  background: #75451f;
  transform-origin: 50% 92%;
}

.wreck-sail {
  position: absolute;
  top: 18px;
  left: 86px;
  width: 61px;
  height: 56px;
  border: 3px solid #4c301e;
  background: #d7b777;
  clip-path: polygon(0 0, 100% 17%, 74% 52%, 92% 100%, 39% 76%, 0 94%);
}

.wreck-crack {
  position: absolute;
  top: 83px;
  left: 70px;
  z-index: 2;
  width: 6px;
  height: 44px;
  background: #1c1511;
  clip-path: polygon(20% 0, 100% 0, 54% 38%, 100% 48%, 26% 100%, 0 100%, 42% 56%, 0 43%);
}

.wreck-debris {
  position: absolute;
  width: 29px;
  height: 9px;
  border: 2px solid #321c12;
  border-radius: 3px;
  background: #77401f;
  opacity: 0;
}

.debris-one {
  top: 85px;
  left: 31px;
}

.debris-two {
  top: 101px;
  left: 113px;
}

.wreck-bubbles {
  position: absolute;
  top: 110px;
  left: 49px;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(210, 244, 234, 0.85);
  border-radius: 50%;
  box-shadow:
    22px 13px 0 -2px rgba(210, 244, 234, 0.8),
    48px -4px 0 -3px rgba(210, 244, 234, 0.86),
    74px 17px 0 -1px rgba(210, 244, 234, 0.72);
  opacity: 0;
}

.game-screen.finale-you .sinking-wreck.is-rival {
  animation: wreck-sink-right 2900ms 360ms cubic-bezier(0.45, 0.02, 0.63, 1) both;
}

.game-screen.finale-rival .sinking-wreck.is-you {
  animation: wreck-sink-left 2900ms 360ms cubic-bezier(0.45, 0.02, 0.63, 1) both;
}

.game-screen.finale-you .sinking-wreck.is-rival .wreck-mast,
.game-screen.finale-rival .sinking-wreck.is-you .wreck-mast {
  animation: wreck-mast-break 900ms 820ms ease-in both;
}

.game-screen.finale-you .sinking-wreck.is-rival .wreck-debris,
.game-screen.finale-rival .sinking-wreck.is-you .wreck-debris {
  animation: debris-fly 1100ms 760ms ease-out both;
}

.game-screen.finale-you .sinking-wreck.is-rival .debris-two,
.game-screen.finale-rival .sinking-wreck.is-you .debris-two {
  animation-delay: 920ms;
  animation-direction: reverse;
}

.game-screen.finale-you .sinking-wreck.is-rival .wreck-bubbles,
.game-screen.finale-rival .sinking-wreck.is-you .wreck-bubbles {
  animation: bubbles-rise 1800ms 1250ms ease-out both;
}

.falling-coin {
  position: absolute;
  top: 29%;
  left: 50%;
  z-index: 4;
  display: block;
  width: var(--coin-size);
  height: var(--coin-height);
  border: 2px solid #6d3511;
  border-radius: 50%;
  background: #f6bd31;
  box-shadow: inset 0 0 0 2px #ffe17b, 0 2px 5px rgba(54, 28, 9, 0.38);
  opacity: 0;
  animation: coin-rain 880ms var(--delay) cubic-bezier(0.2, 0.65, 0.35, 1) both;
}

.muzzle-flash,
.cannonball,
.shot-impact {
  position: absolute;
  display: block;
}

.muzzle-flash {
  top: 67.5%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff5a8;
  box-shadow: 0 0 0 8px rgba(250, 111, 31, 0.72), 0 0 28px 14px rgba(255, 214, 76, 0.76);
  animation: muzzle-pop 260ms ease-out both;
}

.muzzle-flash::before,
.muzzle-flash::after {
  content: "";
  position: absolute;
  inset: -12px 13px;
  background: #ffcf45;
  transform: rotate(45deg);
}

.muzzle-flash::after {
  transform: rotate(-45deg);
}

.muzzle-flash.is-you {
  left: 31%;
}

.muzzle-flash.is-rival {
  right: 31%;
}

.cannonball {
  z-index: 2;
  width: 14px;
  height: 14px;
  border: 2px solid #17120e;
  border-radius: 50%;
  background: #39342e;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.28), 0 4px 8px rgba(0, 0, 0, 0.42);
}

.cannonball::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 8px;
  width: 48px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 246, 203, 0.72);
  filter: blur(2px);
}

.cannonball.is-you {
  animation: shot-from-left 920ms cubic-bezier(0.2, 0.7, 0.4, 1) both;
}

.cannonball.is-rival {
  animation: shot-from-right 920ms cubic-bezier(0.2, 0.7, 0.4, 1) both;
}

.cannonball.is-rival::after {
  right: auto;
  left: 8px;
}

.shot-impact {
  top: 68%;
  width: 42px;
  height: 42px;
  border: 6px dotted #fff0a2;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: impact-pop 360ms 790ms ease-out both;
}

.shot-impact.is-you {
  left: 25%;
}

.shot-impact.is-rival {
  left: 75%;
}

.miniapp.is-shooting .scene-art {
  animation: scene-recoil 260ms ease-out;
}

.topbar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.game-title {
  position: relative;
  min-width: 0;
  padding: 8px 16px 9px 14px;
  color: #fff5c8;
  text-shadow: 0 2px 0 #552113, 0 3px 6px rgba(0, 0, 0, 0.42);
  filter: drop-shadow(0 4px 4px rgba(48, 25, 12, 0.26));
}

.game-title::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 2px solid #5f2d17;
  background: #b64125;
  box-shadow: inset 0 2px 0 rgba(255, 224, 133, 0.5), 0 3px 0 #6a2d16;
  clip-path: polygon(3% 8%, 96% 0, 100% 82%, 70% 89%, 51% 100%, 28% 89%, 0 94%);
}

.game-title span,
.game-title strong {
  display: block;
  letter-spacing: 0;
}

.game-title span {
  font: 700 10px/1 Georgia, serif;
  text-transform: uppercase;
  opacity: 0.86;
}

.game-title strong {
  margin-top: 3px;
  font: 900 clamp(15px, 4.5vw, 19px)/1 Georgia, serif;
  white-space: nowrap;
}

.utility-actions {
  display: flex;
  gap: 7px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0 0 2px;
  border: 2px solid #5b3119;
  border-radius: 50%;
  color: #4d2a16;
  background: #f0c760;
  box-shadow: inset 0 2px 0 #ffe89d, 0 3px 0 #7e451d, 0 5px 10px rgba(50, 24, 10, 0.28);
  font: 900 21px/1 Georgia, serif;
  cursor: pointer;
}

.icon-button:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 0 #ffe89d, 0 1px 0 #7e451d;
}

.reset-icon {
  font-size: 25px;
}

.pot-plate {
  position: absolute;
  top: max(76px, calc(env(safe-area-inset-top) + 66px));
  left: 50%;
  z-index: 4;
  width: 178px;
  min-height: 54px;
  padding: 6px 12px 7px;
  text-align: center;
  transform: translateX(-50%) rotate(-1deg);
  filter: drop-shadow(0 5px 5px rgba(58, 33, 12, 0.3));
}

.pot-plate::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 2px solid #6c3717;
  background:
    linear-gradient(rgba(255, 232, 142, 0.3), transparent),
    #cc7a26;
  box-shadow: inset 0 0 0 2px rgba(255, 215, 101, 0.35), 0 4px 0 #743a16;
  clip-path: polygon(4% 10%, 96% 0, 100% 83%, 82% 94%, 56% 90%, 38% 100%, 2% 88%, 0 27%);
}

.pot-plate span,
.pot-plate strong,
.pot-plate small {
  display: block;
  letter-spacing: 0;
}

.pot-plate span {
  color: #5c321b;
  font: 800 9px/1 Georgia, serif;
  text-transform: uppercase;
}

.pot-plate strong {
  margin-top: 1px;
  color: #2c2015;
  font: 900 20px/1 Georgia, serif;
}

.pot-plate small {
  margin-top: 2px;
  color: #693819;
  font-size: 9px;
  font-weight: 800;
}

.timer-cluster {
  position: absolute;
  top: clamp(137px, 18.3vh, 171px);
  left: 50%;
  z-index: 4;
  display: grid;
  justify-items: center;
  width: min(92%, 360px);
  transform: translateX(-50%);
}

.timer-rope {
  position: absolute;
  top: 42px;
  left: 50%;
  z-index: -1;
  width: min(98vw, 420px);
  height: 58px;
  border-top: 5px solid #5b3b23;
  border-radius: 50%;
  transform: translateX(-50%) rotate(-1deg);
  box-shadow: 0 -2px 0 #c7944a;
  opacity: 0.84;
}

.timer-face {
  position: relative;
  display: grid;
  place-content: center;
  width: 126px;
  height: 126px;
  border: 5px solid #513018;
  border-radius: 50%;
  text-align: center;
  background:
    radial-gradient(circle at 45% 36%, #fff5c6 0 4%, transparent 5%),
    #efc759;
  box-shadow:
    inset 0 0 0 4px #fbe393,
    inset 0 -9px 0 rgba(141, 76, 25, 0.16),
    0 5px 0 #713d1d,
    0 8px 18px rgba(44, 24, 12, 0.32);
  transition: transform 180ms ease, background-color 180ms ease;
}

.timer-face::before,
.timer-face::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 17px;
  height: 28px;
  border: 3px solid #513018;
  background: #b86923;
  transform: translateY(-50%);
}

.timer-face::before {
  left: -20px;
  border-radius: 9px 2px 2px 9px;
}

.timer-face::after {
  right: -20px;
  border-radius: 2px 9px 9px 2px;
}

.timer-face span,
.timer-face strong,
.timer-face small {
  display: block;
  letter-spacing: 0;
}

.timer-face span,
.timer-face small {
  color: #70451f;
  font-weight: 900;
  text-transform: uppercase;
}

.timer-face span {
  font-size: 9px;
}

.timer-face strong {
  margin: 1px 0 -1px;
  color: #302419;
  font: 900 38px/0.98 Georgia, serif;
  font-variant-numeric: tabular-nums;
}

.timer-face small {
  font-size: 8px;
}

.timer-face.is-hot {
  background: #f06f34;
  animation: hot-pulse 720ms ease-in-out infinite alternate;
}

.timer-face.is-hot strong,
.timer-face.is-hot span,
.timer-face.is-hot small {
  color: #fff6c9;
  text-shadow: 0 2px 0 #7a1e12;
}

.leader-ribbon {
  position: relative;
  min-width: 192px;
  margin-top: 10px;
  padding: 7px 22px 8px;
  color: #fff5cc;
  text-align: center;
  text-shadow: 0 2px 0 #42190f;
  transform: rotate(1deg);
}

.leader-ribbon::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 2px solid #541e13;
  background: #ad3522;
  box-shadow: 0 3px 0 #5e2315;
  clip-path: polygon(0 10%, 14% 16%, 19% 0, 81% 4%, 87% 18%, 100% 12%, 94% 90%, 82% 82%, 77% 100%, 20% 96%, 15% 81%, 3% 91%);
}

.leader-ribbon span {
  font: 900 13px/1 Georgia, serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.leader-ribbon.is-you::before {
  background: #176e98;
  border-color: #123d55;
  box-shadow: 0 3px 0 #17425a;
}

.round-message {
  max-width: 276px;
  margin: 10px 0 0;
  padding: 5px 10px;
  border: 1px solid rgba(81, 47, 24, 0.55);
  border-radius: 4px;
  color: #47301e;
  background: rgba(255, 241, 196, 0.88);
  box-shadow: 0 3px 8px rgba(54, 30, 13, 0.22);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.captains {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: clamp(176px, 22.5vh, 210px);
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
  align-items: end;
  gap: 5px;
}

.captain-card {
  min-width: 0;
  padding: 7px 8px 8px;
  border: 2px solid #5b311b;
  border-radius: 7px;
  color: #342318;
  background: rgba(249, 223, 155, 0.94);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.48), 0 4px 0 rgba(86, 43, 20, 0.83), 0 7px 12px rgba(52, 30, 14, 0.25);
  transition: transform 180ms ease, background-color 180ms ease;
}

.captain-you {
  transform: rotate(-1deg);
}

.captain-rival {
  transform: rotate(1deg);
}

.captain-card.is-leader {
  color: #fff3c4;
  background: #b53a25;
  transform: translateY(-5px) rotate(-1deg);
}

.captain-rival.is-leader {
  transform: translateY(-5px) rotate(1deg);
}

.captain-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px;
}

.captain-head span {
  overflow: hidden;
  font: 900 11px/1 Georgia, serif;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.captain-head strong {
  flex: 0 0 auto;
  font-size: 9px;
}

.captain-head b {
  font: 900 15px/1 Georgia, serif;
}

.ammo {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  min-height: 10px;
  margin-top: 6px;
}

.ammo span {
  display: block;
  aspect-ratio: 1;
  border: 1px solid #322319;
  border-radius: 50%;
  background: #45413a;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.35), 0 1px 0 rgba(255, 255, 255, 0.2);
}

.ammo span.is-used {
  border-color: rgba(63, 42, 25, 0.38);
  background: rgba(92, 70, 43, 0.2);
  box-shadow: none;
}

.damage-meter {
  --damage-width: 0%;
  position: relative;
  height: 4px;
  margin-top: 6px;
  border: 1px solid rgba(66, 37, 21, 0.62);
  border-radius: 3px;
  background: rgba(71, 52, 31, 0.22);
  overflow: hidden;
}

.damage-meter span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--damage-width);
  background: #c84225;
  transition: width 620ms ease, background-color 420ms ease;
}

.captain-card.is-leader .damage-meter {
  border-color: rgba(255, 236, 178, 0.5);
  background: rgba(52, 18, 12, 0.28);
}

.versus {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  border: 2px solid #5b311b;
  border-radius: 50%;
  color: #fff3c3;
  background: #207da7;
  box-shadow: 0 3px 0 #4c2a18;
  font: 900 10px/1 Georgia, serif;
}

.bottom-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  min-height: 177px;
  padding: 15px max(13px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(13px, env(safe-area-inset-left));
  color: var(--cream);
  background:
    linear-gradient(180deg, rgba(75, 32, 12, 0.2), rgba(51, 20, 8, 0.74)),
    rgba(78, 31, 10, 0.58);
  border-top: 3px solid rgba(64, 28, 12, 0.78);
  box-shadow: inset 0 3px 0 rgba(246, 167, 59, 0.32), 0 -5px 18px rgba(69, 32, 13, 0.2);
  backdrop-filter: blur(1px);
}

.fairness-strip {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 225, 139, 0.38);
  border-radius: 4px;
  background: rgba(45, 19, 9, 0.58);
  font-size: 9px;
  font-weight: 800;
}

.fairness-strip b {
  color: var(--gold-light);
  font-size: 10px;
}

.equal-mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #563015;
  background: #f1c65a;
  font: 900 14px/1 Georgia, serif;
}

.primary-action {
  position: relative;
  display: grid;
  grid-template-columns: 37px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 75px;
  margin-top: 8px;
  padding: 9px 20px 10px;
  border: 3px solid #571c12;
  border-radius: 7px;
  color: #fff3bf;
  background:
    linear-gradient(180deg, rgba(255, 221, 112, 0.24), transparent 42%),
    #c64425;
  box-shadow:
    inset 0 0 0 2px rgba(255, 210, 103, 0.3),
    0 5px 0 #612010,
    0 8px 12px rgba(34, 13, 6, 0.32);
  text-align: left;
  text-shadow: 0 2px 0 #681b11;
  cursor: pointer;
  overflow: hidden;
}

.primary-action::after {
  content: "";
  position: absolute;
  top: -20%;
  left: -28%;
  width: 22%;
  height: 145%;
  background: rgba(255, 239, 173, 0.26);
  transform: rotate(16deg);
}

.primary-action:not(:disabled):active {
  transform: translateY(4px);
  box-shadow: inset 0 0 0 2px rgba(255, 210, 103, 0.3), 0 1px 0 #612010;
}

.primary-action:disabled {
  cursor: default;
  filter: saturate(0.45);
  opacity: 0.72;
}

.primary-action.is-hot {
  background: #db7021;
  animation: action-glow 560ms ease-in-out infinite alternate;
}

.cannon-icon {
  position: relative;
  display: block;
  width: 36px;
  height: 17px;
  border: 3px solid #5b2713;
  border-radius: 4px 14px 14px 4px;
  background: #e9b549;
  box-shadow: inset 0 3px 0 #ffe294, 0 3px 0 #713717;
  transform: rotate(-6deg);
}

.cannon-icon::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 6px;
  width: 25px;
  height: 13px;
  border-radius: 2px;
  background: #713717;
  transform: rotate(7deg);
}

.cannon-icon::after {
  content: "";
  position: absolute;
  top: 15px;
  left: 7px;
  width: 14px;
  height: 14px;
  border: 3px solid #4c2111;
  border-radius: 50%;
  background: #c47b2b;
  box-shadow: 16px -2px 0 -3px #c47b2b, 16px -2px 0 0 #4c2111;
}

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

.action-copy strong,
.action-copy small {
  display: block;
  letter-spacing: 0;
}

.action-copy strong {
  font: 900 clamp(19px, 6vw, 25px)/1 Georgia, serif;
  white-space: nowrap;
}

.action-copy small {
  margin-top: 5px;
  color: #ffd878;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 0 #54180f;
}

.mini-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 8px;
  color: rgba(255, 239, 190, 0.88);
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}

.mini-rule i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #f0b841;
}

.event-toast {
  position: absolute;
  left: 50%;
  bottom: 47%;
  z-index: 12;
  max-width: 82%;
  padding: 8px 14px;
  border: 2px solid #5b3119;
  border-radius: 5px;
  color: #422711;
  background: #ffe493;
  box-shadow: 0 4px 0 #7c431c, 0 8px 20px rgba(47, 25, 11, 0.3);
  font: 900 12px/1.2 Georgia, serif;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px) rotate(-1deg);
}

.event-toast.is-visible {
  animation: toast-in 1400ms ease both;
}

.game-dialog {
  width: min(88%, 354px);
  max-height: calc(100% - 36px);
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  overflow: visible;
}

.game-dialog::backdrop {
  background: rgba(15, 32, 39, 0.64);
  backdrop-filter: blur(3px);
}

.dialog-board {
  position: relative;
  padding: 27px 24px 22px;
  border: 3px solid #5d3218;
  border-radius: 7px;
  background:
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(104, 70, 34, 0.08) 29px 30px),
    #f2d895;
  box-shadow: inset 0 0 0 3px #ffe8a8, 0 8px 0 #713a19, 0 20px 40px rgba(25, 13, 6, 0.46);
  transform: rotate(-0.6deg);
}

.dialog-close {
  position: absolute;
  top: 9px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0 0 4px;
  border: 2px solid #683719;
  border-radius: 50%;
  color: #fff0b9;
  background: #ae3923;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.dialog-kicker {
  display: block;
  color: #a33b22;
  font: 900 10px/1 Georgia, serif;
  text-align: center;
  text-transform: uppercase;
}

.dialog-board h2 {
  margin: 7px 0 15px;
  color: #382719;
  font: 900 25px/1.05 Georgia, serif;
  text-align: center;
}

.dialog-board ol {
  margin: 0;
  padding-left: 23px;
  color: #4a3421;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.dialog-board li + li {
  margin-top: 9px;
}

.dialog-action {
  width: 100%;
  min-height: 48px;
  margin-top: 19px;
  border: 2px solid #5d2115;
  border-radius: 5px;
  color: #fff1bd;
  background: #b83d24;
  box-shadow: inset 0 2px 0 rgba(255, 222, 126, 0.35), 0 4px 0 #6f2615;
  font: 900 16px/1 Georgia, serif;
  cursor: pointer;
}

.result-board {
  padding-top: 23px;
  text-align: center;
}

.medal-seal {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 12px auto 14px;
  border: 5px double #7c3f16;
  border-radius: 50%;
  color: #814012;
  background: #f2b631;
  box-shadow: inset 0 0 0 5px #ffd96d, 0 5px 0 #774017;
  font-size: 38px;
}

.result-board.is-loss .medal-seal {
  color: #eee4c7;
  background: #778a8e;
  box-shadow: inset 0 0 0 5px #b6c2bd, 0 5px 0 #4b3830;
}

.result-board p {
  margin: -5px 0 0;
  color: #5d3b20;
  font-weight: 800;
}

.dialog-secondary {
  width: 100%;
  min-height: 42px;
  margin-top: 11px;
  border: 1px solid #71421f;
  border-radius: 4px;
  color: #5b351d;
  background: rgba(255, 239, 187, 0.58);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

@keyframes finale-flash {
  0% { opacity: 0; }
  22% { opacity: 0.7; }
  100% { opacity: 0; }
}

@keyframes reveal-empty-rock {
  0% { opacity: 0; transform: translate(-50%, -12%) scale(0.7); }
  100% { opacity: 1; transform: translate(-50%, -12%) scale(1); }
}

@keyframes chest-to-left {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.65) rotate(0); }
  13% { opacity: 1; transform: translate(-50%, -78%) scale(1.08) rotate(-5deg); }
  54% { opacity: 1; transform: translate(calc(-50% - 19vw), -180%) scale(1.03) rotate(-14deg); }
  82% { opacity: 1; transform: translate(calc(-50% - 29vw), 32%) scale(0.87) rotate(-20deg); }
  100% { opacity: 1; transform: translate(calc(-50% - 29vw), 18%) scale(0.88) rotate(-18deg); }
}

@keyframes chest-to-right {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.65) rotate(0); }
  13% { opacity: 1; transform: translate(-50%, -78%) scale(1.08) rotate(5deg); }
  54% { opacity: 1; transform: translate(calc(-50% + 19vw), -180%) scale(1.03) rotate(14deg); }
  82% { opacity: 1; transform: translate(calc(-50% + 29vw), 32%) scale(0.87) rotate(20deg); }
  100% { opacity: 1; transform: translate(calc(-50% + 29vw), 18%) scale(0.88) rotate(18deg); }
}

@keyframes treasure-departs {
  0%, 30% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.55); }
}

@keyframes water-swallow {
  0% { opacity: 0; transform: translateY(100%); }
  18% { opacity: 0.7; }
  100% { opacity: 1; transform: translateY(8%); }
}

@keyframes wreck-sink-left {
  0% { opacity: 0; transform: translate(0, -12px) rotate(0); }
  12% { opacity: 1; transform: translate(0, 0) rotate(0); }
  32% { opacity: 1; transform: translate(4px, 6px) rotate(-8deg); }
  53% { opacity: 1; transform: translate(-2px, 32px) rotate(15deg); }
  100% { opacity: 0; transform: translate(-13px, 270px) rotate(34deg); }
}

@keyframes wreck-sink-right {
  0% { opacity: 0; transform: scaleX(-1) translate(0, -12px) rotate(0); }
  12% { opacity: 1; transform: scaleX(-1) translate(0, 0) rotate(0); }
  32% { opacity: 1; transform: scaleX(-1) translate(4px, 6px) rotate(-8deg); }
  53% { opacity: 1; transform: scaleX(-1) translate(-2px, 32px) rotate(15deg); }
  100% { opacity: 0; transform: scaleX(-1) translate(-13px, 270px) rotate(34deg); }
}

@keyframes wreck-mast-break {
  0%, 22% { transform: rotate(0); }
  100% { transform: translate(18px, 17px) rotate(72deg); }
}

@keyframes debris-fly {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  16% { opacity: 1; }
  100% { opacity: 0; transform: translate(-37px, -54px) rotate(190deg); }
}

@keyframes bubbles-rise {
  0% { opacity: 0; transform: translateY(24px) scale(0.6); }
  20% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-120px) scale(1.3); }
}

@keyframes sea-flash {
  0% { opacity: 0; transform: translateX(-40%); }
  35% { opacity: 0.7; }
  100% { opacity: 0; transform: translateX(40%); }
}

@keyframes muzzle-pop {
  0% { opacity: 0; transform: scale(0.2) rotate(0); }
  32% { opacity: 1; transform: scale(1) rotate(18deg); }
  100% { opacity: 0; transform: scale(1.35) rotate(38deg); }
}

@keyframes shot-from-left {
  0% { left: 33%; top: 68%; transform: scale(0.82); }
  52% { left: 50%; top: 56%; transform: scale(1.18); }
  100% { left: 73%; top: 68%; transform: scale(0.88); }
}

@keyframes shot-from-right {
  0% { left: 65%; top: 68%; transform: scale(0.82); }
  52% { left: 49%; top: 56%; transform: scale(1.18); }
  100% { left: 25%; top: 68%; transform: scale(0.88); }
}

@keyframes impact-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7) rotate(50deg); }
}

@keyframes scene-recoil {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px) rotate(-0.15deg); }
  55% { transform: translateX(2px) rotate(0.15deg); }
}

@keyframes damage-arrive {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--damage-rotate)) scale(2.1); }
  45% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--damage-rotate)) scale(0.78); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--damage-rotate)) scale(1); }
}

@keyframes mast-fall-left {
  0% { opacity: 0; transform: translate(0, -8px) rotate(0) scaleY(0.92); }
  12% { opacity: 1; }
  31% { opacity: 1; transform: translate(2px, 0) rotate(-7deg) scaleY(0.92); }
  48% { opacity: 1; transform: translate(6px, 5px) rotate(14deg) scaleY(0.92); }
  100% { opacity: 1; transform: translate(34px, 30px) rotate(64deg) scaleY(0.92); }
}

@keyframes mast-fall-right {
  0% { opacity: 0; transform: translate(0, -8px) rotate(0) scaleY(0.92); }
  12% { opacity: 1; }
  31% { opacity: 1; transform: translate(-2px, 0) rotate(7deg) scaleY(0.92); }
  48% { opacity: 1; transform: translate(-6px, 5px) rotate(-14deg) scaleY(0.92); }
  100% { opacity: 1; transform: translate(-34px, 30px) rotate(-64deg) scaleY(0.92); }
}

@keyframes mast-crash-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  18% { transform: translate(-4px, 1px) rotate(-0.35deg); }
  35% { transform: translate(4px, -2px) rotate(0.35deg); }
  52% { transform: translate(-3px, 1px) rotate(-0.2deg); }
  70% { transform: translate(2px, 0) rotate(0.12deg); }
}

.miniapp.is-mast-crash .scene-art {
  animation: mast-crash-shake 820ms ease-out;
}

@keyframes smoke-breathe {
  from { opacity: 0.64; transform: translateY(4px) scale(0.92); }
  to { opacity: 0.92; transform: translateY(-10px) scale(1.08); }
}

@keyframes smoke-rise {
  0% { opacity: 0.35; transform: translate(0, 8px) scale(0.84); }
  55% { opacity: 0.9; }
  100% { opacity: 0.25; transform: translate(9px, -24px) scale(1.18); }
}

@keyframes fire-flicker {
  from { opacity: 0.8; transform: rotate(-4deg) scale(0.92); }
  to { opacity: 1; transform: rotate(5deg) scale(1.08); }
}

@keyframes coin-rain {
  0% {
    opacity: 0;
    transform: translate(var(--start-x), -24px) rotateX(0) rotateZ(0);
  }
  12% {
    opacity: 1;
  }
  56% {
    opacity: 1;
    transform: translate(var(--middle-x), 12vh) rotateX(190deg) rotateZ(var(--half-spin));
  }
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--end-x), 28vh) rotateX(360deg) rotateZ(var(--spin)) scale(0.72);
  }
}

@keyframes treasure-catch {
  0% { transform: translateX(-50%) scale(1); }
  38% { transform: translateX(-50%) scale(1.14) rotate(-2deg); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes pile-land {
  from {
    opacity: 0;
    transform: translate(var(--pile-x), calc(var(--pile-y) - 18px)) rotate(var(--pile-rotate)) scale(1.25);
  }
  to {
    opacity: 1;
    transform: translate(var(--pile-x), var(--pile-y)) rotate(var(--pile-rotate)) scale(1);
  }
}

@keyframes hot-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.045); }
}

@keyframes action-glow {
  from { box-shadow: inset 0 0 0 2px rgba(255, 210, 103, 0.3), 0 5px 0 #612010, 0 8px 12px rgba(34, 13, 6, 0.32); }
  to { box-shadow: inset 0 0 0 2px rgba(255, 240, 150, 0.55), 0 5px 0 #612010, 0 0 22px rgba(255, 182, 52, 0.8); }
}

@keyframes toast-in {
  0% { opacity: 0; transform: translate(-50%, 12px) rotate(-1deg) scale(0.92); }
  12%, 72% { opacity: 1; transform: translate(-50%, 0) rotate(-1deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -6px) rotate(-1deg) scale(0.98); }
}

@media (max-height: 720px) {
  .game-title span,
  .pot-plate small,
  .round-message,
  .mini-rule {
    display: none;
  }

  .game-title {
    padding-top: 9px;
    padding-bottom: 9px;
  }

  .pot-plate {
    top: 64px;
    min-height: 45px;
  }

  .timer-cluster {
    top: 115px;
  }

  .timer-face {
    width: 106px;
    height: 106px;
  }

  .timer-face strong {
    font-size: 32px;
  }

  .leader-ribbon {
    margin-top: 7px;
  }

  .captains {
    bottom: 163px;
  }

  .bottom-controls {
    min-height: 155px;
    padding-top: 9px;
  }

  .primary-action {
    min-height: 66px;
  }
}

@media (max-width: 350px) {
  .game-title strong {
    font-size: 14px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .captain-rival .captain-head span {
    font-size: 9px;
  }

  .action-copy strong {
    font-size: 18px;
  }

  .fairness-strip {
    font-size: 8px;
  }
}

@media (min-width: 600px) {
  body {
    display: grid;
    place-items: center;
    background:
      linear-gradient(rgba(7, 47, 71, 0.78), rgba(6, 33, 53, 0.9)),
      url("./assets/sea-duel-open-chest-v2.jpg") center / cover;
  }

  .miniapp {
    height: min(100dvh, 900px);
    border-right: 4px solid #713918;
    border-left: 4px solid #713918;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
