:root {
  --ink: #07163e;
  --blue: #1278ee;
  --blue-dark: #063b9c;
  --sky: #5dd7f5;
  --green: #0dcc4e;
  --green-dark: #079536;
  --yellow: #ffdb22;
  --orange: #ff8b19;
  --cream: #fffdf0;
  --red: #f23a42;
  --shadow: rgba(4, 20, 61, 0.26);
  --header-height: 80px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--ink);
  background: #087cad;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
a {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100vw, 56.25dvh, 760px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #5dd7f5;
  box-shadow: 0 0 34px rgba(0, 0, 0, 0.28);
}

.topbar {
  position: relative;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(var(--header-height) + env(safe-area-inset-top));
  min-height: calc(var(--header-height) + env(safe-area-inset-top));
  padding: calc(7px + env(safe-area-inset-top)) 12px 7px;
  overflow: visible;
  background-color: #59d5f3;
  background-image: url("assets/background-phone.jpeg");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: 100% auto;
  border-bottom: 0;
}

.brand-link {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 96px;
  height: auto;
  aspect-ratio: 1182 / 760;
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

.brand-link img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 0 rgba(6, 22, 62, 0.18));
}

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

.image-button,
.square-button {
  display: grid;
  place-items: center;
  width: 47px;
  height: 47px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 15px;
  box-shadow: 0 4px 0 var(--ink);
  text-decoration: none;
}

.image-button {
  overflow: hidden;
  background: #147cf1;
}

.image-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.square-button {
  color: #fff;
  background: linear-gradient(#258eff, #0759d0);
  font-size: 28px;
  font-weight: 1000;
  line-height: 1;
}

.sound-button {
  color: var(--ink);
  background: linear-gradient(#ffed43, #ffbf0a);
  font-size: 22px;
}

.image-button:active,
.square-button:active,
.game-button:active,
.small-game-button:active,
.pirate-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.game-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #53d2f2;
  background-image: url("assets/background-phone.jpeg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.screen.is-active {
  animation: screenIn 260ms ease-out both;
}

.game-logo-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.game-logo-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: drop-shadow(0 6px 0 rgba(5, 22, 61, 0.14));
}

.menu-screen {
  display: grid;
  grid-template-rows: clamp(120px, 22dvh, 165px) minmax(150px, 1fr) auto;
  justify-items: center;
  align-items: stretch;
  padding: 0 14px calc(14px + env(safe-area-inset-bottom));
}

.menu-logo {
  z-index: 3;
  align-self: center;
  width: min(69vw, 440px);
  height: auto;
  aspect-ratio: 1.96;
  margin: 0;
}

.menu-logo img {
  transform: none;
}

.menu-character {
  position: relative;
  z-index: 2;
  align-self: stretch;
  width: min(72vw, 410px);
  min-height: 0;
  height: 100%;
  margin: -4px 0 0;
}

.menu-character img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 9px 4px rgba(6, 22, 62, 0.22));
  animation: pirateBob 2.4s ease-in-out infinite;
}

.joy-ray {
  position: absolute;
  z-index: -1;
  width: 12px;
  height: 45px;
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 0 2px 0 rgba(255, 139, 25, 0.45);
}

.ray-one {
  left: 14%;
  top: 18%;
  transform: rotate(-43deg);
}

.ray-two {
  right: 11%;
  top: 26%;
  transform: rotate(48deg);
}

.ray-three {
  right: 16%;
  top: 52%;
  transform: rotate(73deg);
}

.menu-actions {
  position: relative;
  z-index: 5;
  display: grid;
  align-self: end;
  width: min(66%, 500px);
  gap: clamp(7px, 1.1vh, 11px);
}

.menu-actions .game-button {
  font-size: clamp(18px, 5.5vw, 28px);
}

.game-button,
.small-game-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  border: 4px solid var(--ink);
  font-weight: 1000;
  letter-spacing: 0.2px;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(5, 22, 61, 0.15);
}

.game-button {
  min-height: clamp(45px, 6.5dvh, 64px);
  padding: 6px 18px;
  border-radius: 21px;
  box-shadow: 0 6px 0 var(--ink);
  color: #fff;
  font-size: clamp(17px, 4.8vw, 27px);
}

.game-button.green {
  background: linear-gradient(#21e15a, var(--green-dark));
}

.game-button.blue {
  background: linear-gradient(#2999ff, #075bda);
}

.game-button.yellow {
  color: var(--ink);
  background: linear-gradient(#ffec49, #ffc20b);
  text-shadow: none;
}

.game-button.cream {
  color: var(--ink);
  background: linear-gradient(#fffef6, #f6eed0);
  text-shadow: none;
}

.button-icon {
  display: grid;
  place-items: center;
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.cream .button-icon {
  color: #fff;
  background: var(--blue);
  border: 2px solid var(--ink);
}

.pirate-face {
  font-size: 25px;
}

.select-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 17px calc(18px + env(safe-area-inset-bottom));
}

.select-logo {
  flex: 0 0 clamp(112px, 18dvh, 158px);
  width: min(69vw, 420px);
  height: auto;
  aspect-ratio: 1.96;
  margin: 0 0 -2px;
}

.select-logo img {
  transform: none;
}

.panel-title {
  z-index: 3;
  width: min(92%, 530px);
  margin: 0 0 clamp(10px, 1.7vh, 18px);
  padding: 8px 15px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
  font-size: clamp(18px, 5.2vw, 30px);
  line-height: 1.1;
  text-align: center;
}

.pirate-options {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1 1 auto;
  width: min(100%, 620px);
  min-height: 245px;
  max-height: 550px;
  gap: clamp(9px, 2.3vw, 18px);
}

.pirate-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  overflow: visible;
  border: 4px solid var(--ink);
  border-radius: 24px;
  background: rgba(255, 254, 244, 0.96);
  box-shadow: 0 6px 0 var(--ink);
}

.pirate-card.is-selected {
  background: #fffbe8;
  border-color: #ffcf15;
  box-shadow: 0 0 0 4px var(--ink), 0 8px 0 var(--ink);
}

.selection-check {
  position: absolute;
  z-index: 5;
  top: -15px;
  right: -12px;
  display: none;
  place-items: center;
  width: clamp(47px, 12vw, 70px);
  height: clamp(47px, 12vw, 70px);
  border: 4px solid var(--ink);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(#31e25b, #069d32);
  box-shadow: 0 4px 0 var(--ink);
  font-size: clamp(26px, 7vw, 42px);
  line-height: 1;
}

.pirate-card.is-selected .selection-check {
  display: grid;
}

.pirate-portrait {
  display: grid;
  place-items: center;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.pirate-portrait img {
  display: block;
  width: 108%;
  height: 108%;
  object-fit: contain;
  transition: transform 180ms ease;
}

.pirate-card:hover .pirate-portrait img,
.pirate-card:focus-visible .pirate-portrait img {
  transform: scale(1.035);
}

.pirate-label {
  flex: 0 0 auto;
  padding: 6px 4px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fffef7;
  font-size: clamp(16px, 4.5vw, 26px);
  font-weight: 1000;
  line-height: 1;
}

.select-actions {
  position: relative;
  z-index: 4;
  display: grid;
  flex: 0 0 auto;
  width: min(66%, 490px);
  gap: 10px;
  margin-top: clamp(14px, 2.4vh, 24px);
}

.confirm-button {
  min-height: clamp(58px, 7.4vh, 74px);
}

.small-game-button {
  min-height: 48px;
  padding: 7px 18px;
  border-radius: 17px;
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
  font-size: clamp(16px, 4vw, 22px);
}

.play-screen {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: manipulation;
}

.scoreboard {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 9px 10px 5px;
}

.player-card,
.round-card {
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  text-align: center;
}

.player-card {
  display: grid;
  min-width: 0;
  min-height: 62px;
  padding: 5px 7px;
  border-radius: 17px;
  background: rgba(255, 254, 247, 0.95);
  transition: transform 180ms ease, background 180ms ease;
}

.player-card.is-turn {
  transform: translateY(-2px);
}

#playerCard0.is-turn {
  background: linear-gradient(#8df1a6, #21c95a);
  box-shadow: 0 4px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, 0.58);
}

#playerCard1.is-turn {
  background: linear-gradient(#9ee4ff, #35a5f2);
  box-shadow: 0 4px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, 0.58);
}

.player-name {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.35em;
  padding-top: 0.12em;
  overflow: hidden;
  font-size: clamp(11px, 3vw, 18px);
  font-weight: 1000;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  font-size: clamp(24px, 6.5vw, 38px);
  line-height: 1;
}

.round-card {
  min-width: 68px;
  padding: 6px 8px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(#227de4, #154b9e);
  font-size: 11px;
  font-weight: 1000;
  line-height: 1.05;
}

.round-card strong {
  display: block;
  margin-top: 2px;
  font-size: 19px;
}

.turn-message {
  position: relative;
  z-index: 20;
  align-self: center;
  max-width: 94%;
  margin: 5px auto 2px;
  padding: 7px 16px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 0 var(--ink);
  font-size: clamp(12px, 3.5vw, 19px);
  font-weight: 1000;
  line-height: 1.1;
  text-align: center;
}

.turn-message.player {
  background: #d9ffe4;
}

.turn-message.bot {
  background: #d9f3ff;
}

.turn-message.safe {
  background: #d9ffe4;
}

.turn-message.win {
  background: var(--yellow);
}

.play-stage {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.toy {
  position: relative;
  width: min(84%, 530px);
  aspect-ratio: 1122 / 1402;
  max-height: 100%;
  flex: 0 0 auto;
}

.pirate-barrel-image {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 11px 5px var(--shadow));
  transition: opacity 170ms ease, transform 200ms ease;
}

.empty-barrel {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 1.5%;
  width: 58%;
  aspect-ratio: 601 / 839;
  opacity: 0;
  transform: translateX(-50%) scale(0.94);
  transition: opacity 180ms ease, transform 240ms ease;
}

.empty-barrel > svg:first-child {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  filter: drop-shadow(0 10px 4px var(--shadow));
}

.barrel-star {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 58.5%;
  width: 25%;
  height: auto;
  overflow: hidden;
  transform: translate(-50%, -50%);
}

.jumping-pirate {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 42%;
  display: block;
  width: 82%;
  height: 61%;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 16px 5px rgba(5, 22, 61, 0.23));
  pointer-events: none;
  transform: translate(-50%, 42%) scale(0.55) rotate(-7deg);
  transform-origin: 50% 85%;
}

.toy.is-popping .pirate-barrel-image {
  opacity: 0;
  transform: scale(0.98);
}

.toy.is-popping .empty-barrel {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.toy.is-popping .jumping-pirate {
  animation: piratePop 1.55s cubic-bezier(0.18, 0.78, 0.22, 1) both;
}

.hole-layer {
  position: absolute;
  z-index: 8;
  inset: 0;
}

.toy.is-popping .hole-layer {
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.hole {
  position: absolute;
  width: clamp(43px, 11vw, 70px);
  height: clamp(43px, 11vw, 70px);
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  background: transparent;
  touch-action: manipulation;
  transform: translate(-50%, -50%);
}

.hole::before {
  content: "";
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.001);
}

.hole::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  opacity: 0;
  box-shadow: 0 0 0 4px rgba(255, 228, 37, 0.9), 0 0 18px 8px rgba(255, 228, 37, 0.6);
  transition: opacity 130ms ease;
}

.hole:not(.is-used):hover::after,
.hole:not(.is-used):focus-visible::after {
  opacity: 1;
}

.hole.is-used {
  pointer-events: none;
}

.sword-sprite {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: clamp(52px, 14vw, 86px);
  height: auto;
  overflow: hidden;
  pointer-events: none;
  transform: translate(-20%, -50%) rotate(var(--angle));
  transform-origin: 20% 50%;
  filter: drop-shadow(0 3px 1px rgba(5, 22, 61, 0.22));
  animation: swordIn 260ms cubic-bezier(0.2, 1.45, 0.5, 1) both;
}

.pop-burst {
  position: absolute;
  z-index: 13;
  left: 50%;
  top: 30%;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.pop-burst i {
  position: absolute;
  left: -7px;
  top: -44px;
  width: 14px;
  height: 50px;
  border-radius: 999px;
  background: var(--yellow);
  transform-origin: 7px 44px;
}

.pop-burst i:nth-child(1) { transform: rotate(0deg) translateY(-58px); }
.pop-burst i:nth-child(2) { transform: rotate(60deg) translateY(-58px); }
.pop-burst i:nth-child(3) { transform: rotate(120deg) translateY(-58px); }
.pop-burst i:nth-child(4) { transform: rotate(180deg) translateY(-58px); }
.pop-burst i:nth-child(5) { transform: rotate(240deg) translateY(-58px); }
.pop-burst i:nth-child(6) { transform: rotate(300deg) translateY(-58px); }

.toy.is-popping .pop-burst {
  animation: burst 900ms ease-out both;
}

.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 14px calc(17px + env(safe-area-inset-bottom));
}

.result-logo {
  z-index: 2;
  flex: 0 0 clamp(88px, 14dvh, 135px);
  width: min(56vw, 350px);
  height: auto;
  aspect-ratio: 1.96;
  margin: 0 0 -7px;
}

.result-pirate {
  z-index: 3;
  display: block;
  flex: 1 1 auto;
  width: min(69%, 390px);
  min-height: 175px;
  max-height: 360px;
  object-fit: contain;
  filter: drop-shadow(0 12px 4px rgba(5, 22, 61, 0.2));
  animation: resultBounce 900ms cubic-bezier(0.2, 1.35, 0.4, 1) both;
}

.victory-banner {
  position: relative;
  z-index: 5;
  width: min(96%, 610px);
  margin: -7px 0 4px;
  padding: 10px 12px 8px;
  border: 5px solid var(--ink);
  border-radius: 22px 22px 31px 31px;
  color: #fff;
  background: linear-gradient(#ffdb24, #f29b09);
  box-shadow: 0 7px 0 var(--ink);
  text-align: center;
  transform: rotate(-1deg);
}

.victory-banner h2 {
  margin: 0;
  font-size: clamp(28px, 8.5vw, 52px);
  line-height: 1;
  text-shadow: 0 4px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink);
}

.victory-banner p {
  display: inline-block;
  margin: 7px 0 -25px;
  padding: 6px 20px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-size: clamp(14px, 4vw, 22px);
  font-weight: 1000;
}

.result-score {
  z-index: 4;
  margin: 25px 0 8px;
  padding: 6px 16px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 var(--ink);
  font-size: clamp(14px, 4vw, 21px);
  font-weight: 1000;
}

.result-actions {
  z-index: 4;
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  width: min(96%, 590px);
  gap: 10px;
}

.result-actions .game-button {
  min-height: clamp(57px, 7.6vh, 72px);
  padding-inline: 12px;
  font-size: clamp(15px, 4.3vw, 24px);
}

.choose-again {
  grid-column: 1 / -1;
}

.overlay {
  position: absolute;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(3, 17, 55, 0.76);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: overlayIn 180ms ease-out both;
}

.modal {
  position: relative;
  width: min(100%, 500px);
  max-height: calc(100% - 8px);
  padding: 16px 16px 15px;
  overflow: auto;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: 0 9px 0 var(--ink);
  text-align: center;
}

.modal-close {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  padding: 0 0 4px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 31px;
  font-weight: 1000;
  line-height: 1;
}

.modal-pirate {
  height: clamp(70px, 12dvh, 112px);
  margin-top: -5px;
}

.modal-pirate img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal h2 {
  margin: 0 0 9px;
  font-size: clamp(24px, 6.5vw, 34px);
}

.how-steps {
  display: grid;
  gap: 7px;
  text-align: left;
}

.how-steps p {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 9px;
  border: 2px solid #ddd2a8;
  border-radius: 15px;
  background: #fff;
  font-size: clamp(12px, 3.35vw, 16px);
  font-weight: 800;
  line-height: 1.23;
}

.how-steps .step-number {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 20px;
  font-weight: 1000;
}

.how-steps .step-copy {
  display: block;
  min-width: 0;
}

.different-rule {
  margin: 8px 0 9px;
  padding: 7px 9px;
  border-radius: 13px;
  color: #843512;
  background: #fff0a5;
  font-size: clamp(12px, 3.4vw, 16px);
  font-weight: 1000;
}

.modal-action {
  width: min(85%, 330px);
}

.exit-modal {
  width: min(100%, 430px);
}

.modal-emoji {
  font-size: 64px;
  line-height: 1;
}

.exit-modal p {
  margin: 5px 0 16px;
  font-size: 17px;
  font-weight: 800;
}

.modal-button-row {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
}

.compact {
  min-height: 54px;
  font-size: 17px;
}

@keyframes screenIn {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pirateBob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-6px) rotate(1deg); }
}

@keyframes swordIn {
  from {
    opacity: 0.2;
    transform: translate(-20%, -50%) rotate(var(--angle)) scale(0.36);
  }
  to {
    opacity: 1;
    transform: translate(-20%, -50%) rotate(var(--angle)) scale(1);
  }
}

@keyframes piratePop {
  0% {
    opacity: 0;
    transform: translate(-50%, 42%) scale(0.55) rotate(-7deg);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, -10%) scale(1.06) rotate(8deg);
  }
  62% {
    opacity: 1;
    transform: translate(-50%, -26%) scale(1) rotate(-5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -18%) scale(1.02) rotate(2deg);
  }
}

@keyframes burst {
  0% { opacity: 0; transform: scale(0.2) rotate(-12deg); }
  30% { opacity: 1; transform: scale(1.1) rotate(6deg); }
  100% { opacity: 0; transform: scale(1.35) rotate(13deg); }
}

@keyframes resultBounce {
  0% { opacity: 0; transform: translateY(90px) scale(0.45) rotate(-8deg); }
  58% { opacity: 1; transform: translateY(-10px) scale(1.08) rotate(4deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(-1deg); }
}


@media (max-height: 690px) {
  :root {
    --header-height: 72px;
  }

  .topbar {
    padding-top: calc(5px + env(safe-area-inset-top));
    padding-bottom: 5px;
    border-bottom-width: 3px;
  }

  .image-button,
  .square-button {
    width: 40px;
    height: 40px;
    border-width: 3px;
    border-radius: 13px;
  }

  .square-button {
    font-size: 23px;
  }

  .sound-button {
    font-size: 18px;
  }

  .brand-link img {
    max-width: none;
  }

  .brand-link {
    width: 90px;
  }

  .menu-logo {
    width: min(69vw, 400px);
    margin: 0;
  }

  .menu-character {
    width: min(72vw, 340px);
    min-height: 0;
    max-height: none;
  }

  .menu-actions {
    width: min(66%, 430px);
    gap: 6px;
  }

  .game-button {
    min-height: 46px;
    border-width: 3px;
    border-radius: 17px;
    box-shadow: 0 4px 0 var(--ink);
    font-size: clamp(15px, 4.3vw, 20px);
  }

  .button-icon {
    flex-basis: 29px;
    width: 29px;
    height: 29px;
    font-size: 19px;
  }

  .select-logo {
    flex-basis: 137px;
  }

  .panel-title {
    padding: 6px 12px;
    border-width: 3px;
  }

  .pirate-options {
    min-height: 205px;
  }

  .select-actions {
    gap: 7px;
    margin-top: 10px;
  }

  .small-game-button {
    min-height: 42px;
    border-width: 3px;
    box-shadow: 0 4px 0 var(--ink);
  }

  .scoreboard {
    padding-top: 5px;
  }

  .player-card {
    min-height: 51px;
    padding: 3px 6px;
  }

  .round-card {
    padding: 4px 7px;
  }

  .turn-message {
    margin-top: 2px;
    padding: 5px 12px;
  }

  .toy {
    width: min(84%, 430px);
  }

  .result-logo {
    flex-basis: 110px;
  }

  .result-pirate {
    min-height: 120px;
    max-height: 205px;
  }

  .victory-banner {
    padding-block: 7px 5px;
  }

  .result-score {
    margin-top: 22px;
    margin-bottom: 5px;
  }

  .result-actions {
    gap: 7px;
  }

  .result-actions .game-button {
    min-height: 48px;
  }

  .overlay {
    padding: 8px;
  }

  .modal {
    padding: 11px 13px 12px;
    border-width: 4px;
    border-radius: 23px;
  }

  .modal-pirate {
    height: 62px;
    margin: -2px 0 0;
  }

  .modal h2 {
    margin-bottom: 7px;
    font-size: 25px;
  }

  .how-steps {
    gap: 5px;
  }

  .how-steps p {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 7px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .how-steps .step-number {
    width: 32px;
    height: 32px;
    border-width: 2px;
    font-size: 18px;
  }

  .different-rule {
    margin: 6px 0 7px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .modal-action {
    min-height: 43px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .menu-screen {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    grid-template-rows: auto 1fr;
    padding: 4px 16px 12px;
  }

  .menu-logo {
    grid-column: 1;
    grid-row: 1;
    width: min(95%, 260px);
    height: 118px;
    aspect-ratio: 1.96;
    justify-self: center;
    margin: -12px 0 -16px;
  }

  .menu-character {
    grid-column: 1;
    grid-row: 2;
    width: 90%;
    height: 100%;
    max-height: none;
    justify-self: center;
  }

  .menu-actions {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    width: 100%;
  }

  .select-screen {
    display: grid;
    grid-template-columns: 0.33fr 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 7px 14px;
    padding: 8px 18px 12px;
  }

  .select-logo {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: start;
    width: 100%;
    height: 120px;
    margin: -17px 0 0;
  }

  .panel-title {
    grid-column: 2;
    margin: 0;
  }

  .pirate-options {
    grid-column: 2;
    min-height: 0;
    width: 100%;
  }

  .select-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 0.45fr;
    width: 75%;
    margin: 0 auto;
  }

  .play-stage {
    justify-content: center;
  }

  .result-screen {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    grid-template-rows: auto 1fr auto;
    gap: 5px 15px;
    padding: 5px 24px 12px;
  }

  .result-logo {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 85px;
    margin: -10px 0 -14px;
  }

  .result-pirate {
    grid-column: 1;
    grid-row: 2 / 4;
    width: 100%;
    height: 100%;
  }

  .victory-banner {
    grid-column: 2;
    grid-row: 1;
    margin: 5px 0 0;
  }

  .result-score {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    justify-self: center;
    margin: 20px 0 0;
  }

  .result-actions {
    grid-column: 2;
    grid-row: 2 / 4;
    align-self: end;
    width: 100%;
  }
}

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

/* As telas de menu e seleção usam as artes finais aprovadas como canvas. */
.app-shell {
  display: block;
}

.game-area {
  position: absolute;
  inset: 0;
}

.topbar {
  position: absolute;
  inset: 0 0 auto;
  width: 100%;
}

.app-shell.view-menu .topbar,
.app-shell.view-select .topbar,
.app-shell.view-result .topbar {
  visibility: hidden;
  pointer-events: none;
}

.play-screen {
  padding-top: calc(var(--header-height) + env(safe-area-inset-top));
}

.art-screen.menu-screen,
.art-screen.select-screen,
.art-screen.result-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-template: none;
  padding: 0;
  background: #58d4f2;
}

.art-canvas {
  position: relative;
  width: min(100%, 56.25dvh);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  flex: none;
}

.screen-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.art-hotspot {
  position: absolute;
  z-index: 5;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: transparent;
  background: transparent;
  box-shadow: none;
  touch-action: manipulation;
}

.art-hotspot:active,
.pirate-card.art-hotspot:active {
  transform: scale(0.985);
  box-shadow: none;
}

.art-hotspot:focus-visible {
  outline: 5px solid rgba(255, 255, 255, 0.96);
  outline-offset: -7px;
}

.art-back-hotspot,
.selection-back-hotspot {
  left: 2.2%;
  top: 2.3%;
  width: 15.5%;
  height: 7.9%;
}

.art-help-hotspot {
  left: 68.3%;
  top: 2.3%;
  width: 13.5%;
  height: 7.9%;
}

.art-sound-hotspot {
  left: 83.6%;
  top: 2.3%;
  width: 13.5%;
  height: 7.9%;
}

.menu-hotspot {
  left: 21.1%;
  width: 58.3%;
}

.one-player-hotspot {
  top: 68.75%;
  height: 6.55%;
}

.two-player-hotspot {
  top: 75.75%;
  height: 6.65%;
}

.how-to-play-hotspot {
  top: 82.85%;
  height: 7.1%;
}

.selection-art-canvas .pirate-options {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: block;
  width: auto;
  min-height: 0;
  max-height: none;
  pointer-events: none;
}

.selection-art-canvas .pirate-card {
  top: 40.2%;
  width: 46.2%;
  height: 34.5%;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  border: 0;
  border-radius: 4.7%;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}

.selection-art-canvas .pirate-one-card {
  left: 3.4%;
}

.selection-art-canvas .pirate-two-card {
  left: 50.3%;
}

.selection-art-canvas .pirate-card.is-selected {
  background: transparent;
  border: 0;
  box-shadow: inset 0 0 0 clamp(4px, 0.9vw, 7px) #ffd91d,
              inset 0 0 0 clamp(8px, 1.8vw, 13px) #07163e;
}

.live-selection-check {
  position: absolute;
  z-index: 7;
  top: -5.5%;
  right: -1.5%;
  display: none;
  place-items: center;
  width: 24%;
  aspect-ratio: 1;
  border: clamp(3px, 0.7vw, 6px) solid #07163e;
  border-radius: 50%;
  color: #fff;
  background: #15bf42;
  box-shadow: 0 0 0 clamp(3px, 0.7vw, 6px) #ffdc20;
  font-size: clamp(22px, 7vw, 54px);
  font-weight: 1000;
  line-height: 1;
}

.pirate-card.is-selected .live-selection-check {
  display: grid;
}

.confirm-pirate-hotspot {
  left: 21.1%;
  top: 77.05%;
  width: 58.1%;
  height: 9.5%;
}

.cancel-pirate-hotspot {
  left: 30.8%;
  top: 89.65%;
  width: 38.5%;
  height: 6.5%;
}

.result-art-canvas {
  container-type: inline-size;
}

.result-outcome-banner {
  position: absolute;
  z-index: 6;
  left: 10.8%;
  top: 39.75%;
  display: grid;
  place-items: center;
  width: 78.4%;
  height: 7.45%;
  padding: 0 2.2%;
  border: clamp(3px, 0.72vw, 5px) solid var(--ink);
  border-radius: clamp(11px, 2.7vw, 18px);
  color: #fff;
  background: linear-gradient(#ffe45a, #f5a817);
  box-shadow: 0 clamp(1px, 0.3vw, 2px) 0 var(--ink);
  overflow: hidden;
  transform: rotate(-0.7deg);
  pointer-events: none;
}

#resultScreenArt[src$="victory-pirate2.jpeg"] + .result-outcome-banner {
  top: 41.8%;
}

.result-outcome-banner strong {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(14px, 2.45dvh, 22px);
  font-size: clamp(14px, 4.6cqw, 22px);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: -0.055em;
  text-align: center;
  white-space: nowrap;
  -webkit-text-stroke: clamp(1px, 0.35vw, 2px) var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 clamp(2px, 0.45vw, 3px) 0 var(--ink);
}

.result-play-again-hotspot {
  left: 3.2%;
  top: 79.25%;
  width: 55.2%;
  height: 10.4%;
}

.result-menu-hotspot {
  left: 58.1%;
  top: 79.25%;
  width: 39%;
  height: 10.4%;
}

.result-choose-hotspot {
  left: 21.4%;
  top: 90.15%;
  width: 57.4%;
  height: 8.2%;
}

.overlay.how-art-overlay {
  place-items: stretch;
  padding: 0;
  background: #58d4f2;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.how-art-screen {
  width: 100%;
  height: 100%;
}

.how-art-canvas {
  width: min(100%, 56.25dvh);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
}

.how-back-hotspot {
  left: 2.2%;
  top: 2.3%;
  width: 15.5%;
  height: 7.9%;
}

.how-sound-hotspot {
  left: 83.6%;
  top: 2.3%;
  width: 13.5%;
  height: 7.9%;
}

.how-start-hotspot {
  left: 20%;
  top: 77.8%;
  width: 60%;
  height: 8.6%;
}

@media (orientation: landscape) and (max-height: 600px) {
  .art-screen.menu-screen,
  .art-screen.select-screen,
  .art-screen.result-screen {
    display: flex;
    padding: 0;
  }

  .art-canvas {
    width: auto;
    height: 100%;
    aspect-ratio: 9 / 16;
  }
}

/* Controles da partida no mesmo acabamento cartunesco das artes aprovadas. */
.app-shell.view-play .topbar {
  height: calc(76px + env(safe-area-inset-top));
  min-height: calc(76px + env(safe-area-inset-top));
  padding: calc(5px + env(safe-area-inset-top)) 12px 4px;
  background-color: #61d7fd;
  border: 0;
}

.app-shell.view-play .brand-link {
  width: 104px;
}

.app-shell.view-play .brand-link img {
  filter: drop-shadow(0 3px 0 rgba(7, 22, 62, 0.18));
}

.app-shell.view-play .image-button {
  width: 52px;
  height: 52px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.app-shell.view-play .image-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.72);
}

.app-shell.view-play .image-button:active {
  transform: translateY(3px) scale(0.98);
  box-shadow: none;
}

.app-shell.view-play .square-button {
  position: relative;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 15px;
  box-shadow: 0 5px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, 0.34);
}

.app-shell.view-play .help-button {
  padding: 0 0 2px;
  background: linear-gradient(180deg, #2b99ff 0%, #0960d8 100%);
  font-size: 30px;
  text-shadow: 0 2px 0 rgba(7, 22, 62, 0.25);
}

.app-shell.view-play .sound-button {
  background: linear-gradient(180deg, #ffef48 0%, #ffbe0b 100%);
}

.sound-icon,
.sound-icon svg {
  display: block;
  width: 28px;
  height: 28px;
}

.sound-icon svg {
  overflow: visible;
}

.speaker-body {
  fill: var(--ink);
}

.sound-wave,
.mute-slash {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.mute-slash {
  display: none;
  stroke: #ef3044;
  stroke-width: 4;
}

.sound-button.is-muted .sound-wave {
  opacity: 0.18;
}

.sound-button.is-muted .mute-slash {
  display: block;
}

.app-shell.view-play .play-screen {
  padding-top: calc(76px + env(safe-area-inset-top));
}

.app-shell.view-play .scoreboard {
  width: calc(100% - 20px);
  margin: 3px auto 0;
  padding: 5px;
  gap: 5px;
  border: 4px solid var(--ink);
  border-radius: 22px;
  background: linear-gradient(180deg, #f3912a 0%, #bd4c12 100%);
  box-shadow: 0 5px 0 var(--ink), inset 0 3px 0 rgba(255, 214, 117, 0.54);
}

.app-shell.view-play .player-card,
.app-shell.view-play .round-card {
  min-height: 55px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5);
}

.app-shell.view-play .player-card {
  padding: 5px 7px 4px;
  background: linear-gradient(180deg, #fffef8 0%, #fff1c9 100%);
  transform: none;
}

.app-shell.view-play .player-card.is-turn {
  transform: none;
}

.app-shell.view-play #playerCard0.is-turn {
  background: linear-gradient(180deg, #8df1a6 0%, #21c95a 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.58);
}

.app-shell.view-play #playerCard1.is-turn {
  background: linear-gradient(180deg, #9ee4ff 0%, #35a5f2 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.58);
}

.app-shell.view-play .player-name {
  font-size: clamp(11px, 3vw, 17px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.app-shell.view-play .player-score {
  font-size: clamp(23px, 6vw, 34px);
}

.app-shell.view-play .round-card {
  min-width: 66px;
  padding: 5px 7px 4px;
  background: linear-gradient(180deg, #319aff 0%, #0758ca 100%);
  font-size: 11px;
  text-shadow: 0 2px 0 rgba(7, 22, 62, 0.38);
}

.app-shell.view-play .round-card strong {
  margin-top: 1px;
  font-size: 20px;
}

.app-shell.view-play .turn-message {
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 10px auto 1px;
  padding: 7px 17px 6px;
  border: 4px solid var(--ink);
  border-radius: 17px;
  background: linear-gradient(180deg, #fffef8 0%, #fff0c7 100%);
  box-shadow: 0 5px 0 var(--ink), inset 0 2px 0 #fff;
  font-size: clamp(12px, 3.35vw, 18px);
}

.app-shell.view-play .turn-message.player {
  background: linear-gradient(180deg, #eaffef 0%, #bff3ca 100%);
}

.app-shell.view-play .turn-message.bot {
  background: linear-gradient(180deg, #e8f9ff 0%, #bfeaff 100%);
}

.app-shell.view-play .turn-message.safe {
  background: linear-gradient(180deg, #eaffef 0%, #bff3ca 100%);
}

.app-shell.view-play .turn-message.win {
  background: linear-gradient(180deg, #ffed48 0%, #ffc615 100%);
}


@media (max-height: 690px) {
  .app-shell.view-play .topbar {
    height: calc(66px + env(safe-area-inset-top));
    min-height: calc(66px + env(safe-area-inset-top));
  }

  .app-shell.view-play .brand-link {
    width: 88px;
  }

  .app-shell.view-play .image-button {
    width: 45px;
    height: 45px;
  }

  .app-shell.view-play .square-button {
    width: 42px;
    height: 42px;
    border-width: 3px;
    border-radius: 13px;
  }

  .app-shell.view-play .help-button {
    font-size: 25px;
  }

  .app-shell.view-play .play-screen {
    padding-top: calc(66px + env(safe-area-inset-top));
  }

  .app-shell.view-play .scoreboard {
    margin-top: 2px;
    padding: 4px;
    border-width: 3px;
    border-radius: 18px;
    box-shadow: 0 4px 0 var(--ink), inset 0 2px 0 rgba(255, 214, 117, 0.54);
  }

  .app-shell.view-play .player-card,
  .app-shell.view-play .round-card {
    min-height: 48px;
    border-width: 2px;
    border-radius: 12px;
  }

  .app-shell.view-play .turn-message {
    margin-top: 7px;
    padding: 5px 13px;
    border-width: 3px;
    border-radius: 14px;
    box-shadow: 0 4px 0 var(--ink), inset 0 2px 0 #fff;
  }
}


/* O alvo e a espada acompanham a escala do brinquedo, nunca a largura da tela. */
.hole {
  width: 13.5%;
  height: auto;
  aspect-ratio: 1;
}

.sword-sprite {
  width: 132%;
  max-width: none;
}

/* Tablets e desktops mantêm a proporção vertical 9:16 do celular.
   O conteúdo fica centralizado, sem esticar nem recompor os elementos. */
