:root {
  --pp-night: #031521;
  --pp-panel: #082536;
  --pp-panel-deep: #041b2a;
  --pp-line: rgba(92, 221, 222, 0.34);
  --pp-gold: #ffc257;
  --pp-gold-light: #ffe29a;
  --pp-cyan: #5de5e4;
  --pp-text: #f5f8fb;
  --pp-muted: #adc4d0;
  --pp-danger: #ff7a67;
  --pp-radius: 16px;
  --pp-stage-ratio: 1.8006430868;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.piratenflipper-page {
  min-width: 320px;
  margin: 0;
  color: var(--pp-text);
  background:
    radial-gradient(circle at 50% -15%, rgba(19, 105, 126, 0.22), transparent 38rem),
    linear-gradient(180deg, #031521, #020d16 70rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  font: inherit;
}

.pp-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;
}

.pp-skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 16px;
  color: #071724;
  background: var(--pp-gold-light);
  border-radius: 10px;
  font-weight: 900;
  transform: translateY(-160%);
}

.pp-skip-link:focus {
  transform: none;
}

.pp-game-section {
  width: 100%;
  height: 100dvh;
  min-height: 630px;
  padding: clamp(6px, 1vh, 12px) clamp(8px, 1vw, 18px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(6px, 0.8vh, 10px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(3, 24, 38, 0.98), rgba(2, 15, 25, 0.98)),
    radial-gradient(circle at 50% 20%, rgba(41, 158, 167, 0.2), transparent 45%);
  border-bottom: 1px solid rgba(255, 194, 87, 0.32);
}

.pp-game-toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pp-title-block {
  min-width: 0;
}

.pp-back-link,
.pp-eyebrow {
  display: block;
  margin: 0 0 2px;
  color: var(--pp-gold);
  font-size: clamp(0.62rem, 0.73vw, 0.76rem);
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

.pp-back-link {
  width: max-content;
  text-decoration: none;
}

.pp-back-link:hover,
.pp-back-link:focus-visible {
  color: var(--pp-gold-light);
  text-decoration: underline;
}

.pp-title-block h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.35vw, 2.55rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.pp-title-block h1 span {
  display: inline-block;
  margin-left: 0.45em;
  color: var(--pp-gold-light);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.44em;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  vertical-align: 0.3em;
}

.pp-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.pp-tool-button,
.pp-primary-button,
.pp-secondary-button,
.pp-control-pad {
  border: 1px solid rgba(91, 224, 225, 0.35);
  color: var(--pp-text);
  background: linear-gradient(180deg, rgba(15, 58, 76, 0.98), rgba(7, 35, 51, 0.98));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.pp-tool-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 13px;
  font-weight: 850;
}

.pp-tool-button:hover,
.pp-tool-button:focus-visible,
.pp-control-pad:hover,
.pp-control-pad:focus-visible {
  border-color: var(--pp-cyan);
  background: linear-gradient(180deg, rgba(20, 78, 96, 1), rgba(8, 43, 60, 1));
  outline: none;
}

.pp-tool-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pp-tool-button-new {
  color: #251703;
  border-color: rgba(255, 194, 87, 0.72);
  background: linear-gradient(180deg, #ffe29a, #f4ad3c);
}

.pp-stat-strip {
  min-height: 54px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pp-stat-card {
  min-width: 0;
  padding: 6px clamp(8px, 1.2vw, 18px);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--pp-line);
  border-radius: 13px;
  background:
    linear-gradient(105deg, rgba(12, 49, 66, 0.97), rgba(5, 30, 44, 0.97)),
    radial-gradient(circle at 10% 50%, rgba(93, 229, 228, 0.16), transparent 50%);
  overflow: hidden;
}

.pp-stat-card > span:last-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: clamp(6px, 0.7vw, 12px);
}

.pp-stat-card small {
  color: var(--pp-muted);
  font-size: clamp(0.6rem, 0.69vw, 0.72rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pp-stat-card strong {
  color: var(--pp-gold-light);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.12rem, 1.65vw, 1.75rem);
  line-height: 1;
  white-space: nowrap;
}

.pp-stat-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  color: #271703;
  border: 1px solid #ffe6a8;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe7a5, #e99b2e);
  box-shadow: 0 0 16px rgba(255, 194, 87, 0.2);
  font-weight: 950;
}

.pp-ball-icon {
  background:
    radial-gradient(circle at 35% 28%, #fff 0 6%, #84f8f4 13%, #2ca6bd 48%, #092746 76%, #020c18 100%);
  border-color: #a7fffb;
}

.pp-game-viewport {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(225px, 19vw, 300px);
  gap: clamp(7px, 0.8vw, 12px);
}

.pp-stage-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

.pp-stage {
  position: relative;
  width: min(100%, calc((100dvh - 240px) * var(--pp-stage-ratio)));
  max-height: calc(100% - 78px);
  aspect-ratio: 1680 / 933;
  flex: 0 1 auto;
  overflow: hidden;
  border: 1px solid rgba(91, 225, 224, 0.5);
  border-radius: 14px;
  background: #051823;
  box-shadow:
    0 12px 35px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 194, 87, 0.1);
  isolation: isolate;
}

#ppCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  outline: none;
}

#ppCanvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--pp-cyan);
}

.pp-loading,
.pp-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
}

.pp-loading {
  gap: 10px;
  align-content: center;
  color: var(--pp-gold-light);
  background: #051823;
  font-weight: 850;
}

.pp-loading[hidden] {
  display: none;
}

.pp-loading span {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(93, 229, 228, 0.2);
  border-top-color: var(--pp-cyan);
  border-radius: 50%;
  animation: pp-spin 0.85s linear infinite;
}

@keyframes pp-spin {
  to { transform: rotate(360deg); }
}

.pp-overlay {
  padding: 16px;
  background: rgba(0, 12, 20, 0.66);
  backdrop-filter: blur(4px);
}

.pp-overlay[hidden] {
  display: none;
}

.pp-overlay-card {
  width: min(460px, 92%);
  padding: clamp(18px, 2.5vw, 30px);
  text-align: center;
  border: 1px solid rgba(93, 229, 228, 0.72);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(10, 47, 64, 0.98), rgba(3, 23, 36, 0.99));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
}

.pp-overlay-card h2 {
  margin: 5px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.4vw, 2.25rem);
  line-height: 1.08;
}

.pp-overlay-card > p:not(.pp-eyebrow) {
  margin: 0 auto 18px;
  color: #c7d8e0;
  line-height: 1.55;
}

.pp-pearl {
  width: 46px;
  height: 46px;
  display: inline-block;
  margin-bottom: 8px;
  border: 1px solid #c8fffb;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff 0 7%, #7df2eb 17%, #2d9db3 50%, #0a3452 78%, #020c18 100%);
  box-shadow: 0 0 24px rgba(93, 229, 228, 0.5);
}

.pp-overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.pp-primary-button,
.pp-secondary-button {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 13px;
  font-weight: 950;
}

.pp-primary-button {
  color: #2b1a02;
  border-color: #ffe2a0;
  background: linear-gradient(180deg, #ffe29a, #f4aa35);
}

.pp-primary-button:hover,
.pp-primary-button:focus-visible,
.pp-secondary-button:hover,
.pp-secondary-button:focus-visible {
  filter: brightness(1.08);
  outline: 2px solid var(--pp-cyan);
  outline-offset: 2px;
}

.pp-message {
  min-height: 23px;
  max-width: 100%;
  margin: 2px 0 0;
  padding: 3px 14px;
  color: #d8e8ee;
  font-size: clamp(0.68rem, 0.78vw, 0.82rem);
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pp-message.is-good {
  color: #9af3d2;
}

.pp-message.is-warning {
  color: var(--pp-gold-light);
}

.pp-message.is-error {
  color: #ffaaa0;
}

.pp-leaderboard-panel {
  min-height: 0;
  padding: clamp(12px, 1.1vw, 18px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid #b87925;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(8, 38, 55, 0.98), rgba(2, 22, 35, 0.99)),
    radial-gradient(circle at 50% 0, rgba(255, 194, 87, 0.12), transparent 48%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 224, 154, 0.18),
    0 10px 28px rgba(0, 0, 0, 0.32);
}

.pp-leaderboard-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pp-leaderboard-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 1.45vw, 1.62rem);
  line-height: 1.03;
}

.pp-live-badge {
  padding: 4px 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #a7fff1;
  border: 1px solid rgba(93, 229, 228, 0.45);
  border-radius: 999px;
  background: rgba(17, 102, 108, 0.25);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pp-live-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5ff0c5;
  box-shadow: 0 0 8px #5ff0c5;
}

.pp-leaderboard {
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  align-content: start;
  gap: clamp(3px, 0.55vh, 7px);
  list-style: none;
  overflow: hidden;
}

.pp-leaderboard li {
  min-width: 0;
  min-height: clamp(31px, 4.2vh, 42px);
  padding: 4px 7px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(76, 161, 177, 0.28);
  border-radius: 9px;
  background: rgba(1, 17, 28, 0.58);
}

.pp-leaderboard li.is-current-user {
  border-color: var(--pp-cyan);
  background: rgba(19, 91, 103, 0.38);
}

.pp-leaderboard-rank {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #291801;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe5a0, #efa633);
  font-size: 0.72rem;
  font-weight: 950;
}

.pp-leaderboard-name {
  min-width: 0;
  overflow: hidden;
  color: #f5f8fb;
  font-size: clamp(0.7rem, 0.76vw, 0.82rem);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pp-leaderboard-score {
  color: var(--pp-gold-light);
  font-size: clamp(0.67rem, 0.72vw, 0.78rem);
  white-space: nowrap;
}

.pp-leaderboard-empty {
  grid-template-columns: 26px minmax(0, 1fr) !important;
}

.pp-leaderboard-empty p,
.pp-ranking-note {
  margin: 0;
  color: var(--pp-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.pp-ranking-note {
  margin-top: auto;
  padding-top: 8px;
}

.pp-controls {
  width: min(800px, 100%);
  min-height: 44px;
  margin-top: 6px;
  padding: 4px;
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(230px, 300px) minmax(170px, 220px);
  justify-content: center;
  align-self: center;
  flex: 0 0 auto;
  gap: 5px;
  border: 1px solid rgba(93, 229, 228, 0.24);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(7, 31, 45, 0.95), rgba(2, 18, 29, 0.96));
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.25),
    inset 0 1px rgba(255, 255, 255, 0.04);
}

.pp-control-pad {
  min-width: 0;
  min-height: 36px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: rgba(255, 194, 87, 0.48);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(14, 64, 80, 0.98), rgba(5, 31, 45, 0.98));
  box-shadow:
    0 3px 9px rgba(0, 0, 0, 0.2),
    inset 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -1px rgba(255, 194, 87, 0.12);
  font-size: clamp(0.69rem, 0.76vw, 0.8rem);
  font-weight: 900;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  touch-action: none;
  user-select: none;
}

.pp-control-pad.is-active {
  border-color: var(--pp-gold-light);
  background: linear-gradient(180deg, #eaa943, #8c571a);
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.3),
    inset 0 2px rgba(255, 240, 190, 0.28);
}

.pp-control-pad kbd {
  min-width: 30px;
  padding: 4px 7px;
  color: var(--pp-gold-light);
  border: 1px solid rgba(255, 216, 135, 0.58);
  border-radius: 999px;
  background: rgba(2, 17, 27, 0.72);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
  font: 900 0.7rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  text-align: center;
}

.pp-control-launch {
  position: relative;
  flex-wrap: wrap;
  align-content: center;
  row-gap: 4px;
}

.pp-control-launch > span[data-launch-label] {
  white-space: nowrap;
}

.pp-launch-meter {
  width: 100%;
  height: 4px;
  display: block;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.5);
}

.pp-launch-meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pp-cyan), var(--pp-gold), #ff694f);
  transition: width 60ms linear;
}

.pp-noscript {
  position: fixed;
  z-index: 20;
  right: 12px;
  bottom: 12px;
  padding: 12px;
  color: #fff;
  background: #741c1c;
  border-radius: 10px;
}

.pp-content-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 72px 0 30px;
}

.pp-intro {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
  align-items: end;
  gap: 40px;
  padding-bottom: 38px;
}

.pp-intro h2,
.pp-info-grid h2,
.pp-faq h2 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.08;
}

.pp-intro h2 {
  font-size: clamp(2rem, 4vw, 4rem);
}

.pp-intro > p,
.pp-info-grid p,
.pp-faq p {
  color: #b9ced8;
  line-height: 1.7;
}

.pp-intro > p {
  margin: 0;
  font-size: 1.03rem;
}

.pp-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.pp-info-grid article {
  position: relative;
  min-height: 220px;
  padding: 26px;
  overflow: hidden;
  border: 1px solid rgba(79, 170, 186, 0.28);
  border-radius: var(--pp-radius);
  background: linear-gradient(145deg, rgba(9, 43, 60, 0.9), rgba(3, 23, 35, 0.95));
}

.pp-info-grid h2 {
  max-width: 80%;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
}

.pp-info-grid p:last-child {
  margin-bottom: 0;
}

.pp-card-symbol {
  position: absolute;
  right: 20px;
  top: 17px;
  color: rgba(255, 194, 87, 0.28);
  font-size: 3.2rem;
}

.pp-faq {
  margin-top: 58px;
}

.pp-faq > h2 {
  margin-bottom: 24px;
  font-size: clamp(2rem, 3.5vw, 3.1rem);
}

.pp-faq details {
  border-top: 1px solid rgba(89, 183, 196, 0.28);
}

.pp-faq details:last-child {
  border-bottom: 1px solid rgba(89, 183, 196, 0.28);
}

.pp-faq summary {
  padding: 19px 4px;
  color: #f3f7fa;
  font-weight: 850;
  cursor: pointer;
}

.pp-faq details p {
  max-width: 850px;
  margin: -5px 0 20px;
}

.pp-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #819da9;
  border-top: 1px solid rgba(89, 183, 196, 0.18);
  font-size: 0.82rem;
}

.pp-footer p {
  margin: 0;
}

.pp-footer a {
  color: var(--pp-gold-light);
}

@media (max-width: 1050px) {
  .pp-game-viewport {
    grid-template-columns: minmax(0, 1fr) 214px;
  }

  .pp-leaderboard-panel {
    padding: 10px;
  }

  .pp-stat-card > span:last-child {
    display: block;
  }

  .pp-stat-card small {
    display: block;
    margin-bottom: 1px;
  }
}

@media (max-width: 820px), (orientation: portrait) {
  .pp-game-section {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .pp-game-toolbar {
    align-items: flex-start;
  }

  .pp-title-block h1 span {
    display: block;
    margin: 4px 0 0;
    font-size: 0.5em;
  }

  .pp-tool-button {
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.75rem;
  }

  .pp-stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pp-game-viewport {
    grid-template-columns: 1fr;
  }

  .pp-stage {
    width: 100%;
    max-height: none;
  }

  .pp-leaderboard-panel {
    max-height: none;
  }

  .pp-leaderboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pp-controls {
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-top: 8px;
    transform: none;
  }

  .pp-control-launch {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .pp-intro,
  .pp-info-grid {
    grid-template-columns: 1fr;
  }

  .pp-content-shell {
    padding-top: 52px;
  }
}

@media (max-width: 520px) {
  .pp-game-section {
    padding-inline: 5px;
  }

  .pp-toolbar-actions {
    gap: 4px;
  }

  .pp-tool-button span:first-child {
    display: none;
  }

  .pp-stat-card {
    gap: 6px;
    padding-inline: 7px;
  }

  .pp-stat-icon {
    width: 25px;
    height: 25px;
    flex-basis: 25px;
    font-size: 0.7rem;
  }

  .pp-leaderboard {
    grid-template-columns: 1fr;
  }

  .pp-control-pad {
    padding-inline: 7px;
  }

  .pp-control-pad kbd {
    min-width: 28px;
    padding-inline: 5px;
  }

  .pp-intro {
    gap: 18px;
  }

  .pp-info-grid article {
    padding: 22px;
  }

  .pp-footer {
    display: block;
  }

  .pp-footer p + p {
    margin-top: 8px;
  }
}

@media (max-height: 760px) and (min-width: 821px) {
  .pp-game-section {
    min-height: 600px;
    gap: 5px;
    padding-block: 5px;
  }

  .pp-game-toolbar {
    min-height: 42px;
  }

  .pp-tool-button {
    min-height: 36px;
  }

  .pp-stat-strip {
    min-height: 46px;
  }

  .pp-stat-icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .pp-stage {
    width: min(100%, calc((100dvh - 188px) * var(--pp-stage-ratio)));
  }

  .pp-controls {
    min-height: 44px;
  }

  .pp-control-pad {
    min-height: 36px;
  }

  .pp-leaderboard li {
    min-height: 29px;
  }
}

@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;
  }
}
