:root {
  --ink: #18312c;
  --ink-strong: #10241f;
  --soft: #61756f;
  --muted: #8c9b96;
  --paper: #fffdf7;
  --cream: #f7f4e8;
  --surface: rgba(255, 253, 247, 0.88);
  --line: rgba(24, 49, 44, 0.1);

  --leaf: #54b56f;
  --leaf-dark: #278a53;
  --lime: #b9dd68;
  --sun: #f4c95d;
  --sky: #6dc8d4;
  --coral: #ef846f;
  --violet: #8b79cf;
  --danger: #c94e52;

  --shadow-sm: 0 8px 24px rgba(38, 72, 58, 0.1);
  --shadow: 0 22px 60px rgba(38, 72, 58, 0.16);
  --radius-sm: 14px;
  --radius: 22px;
  --radius-lg: 32px;
  --header-height: 72px;
  --nav-height: 76px;
  --content-width: 1120px;

  color-scheme: light;
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(185, 221, 104, 0.36), transparent 24rem),
    radial-gradient(circle at 92% 12%, rgba(109, 200, 212, 0.26), transparent 25rem),
    linear-gradient(180deg, #fffdf7 0%, var(--cream) 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.25) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), transparent 72%);
  pointer-events: none;
  content: "";
}

button,
input,
select,
textarea {
  font: inherit;
}

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

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid rgba(39, 138, 83, 0.3);
  outline-offset: 3px;
}

.noscript-warning {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  padding: 12px 16px;
  color: #fff;
  background: var(--danger);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.app-shell {
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: calc(var(--header-height) + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  padding:
    calc(10px + env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    10px
    max(18px, env(safe-area-inset-left));
  background: rgba(255, 253, 247, 0.76);
  box-shadow: 0 8px 30px rgba(38, 72, 58, 0.05);
  backdrop-filter: blur(18px) saturate(150%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px 21px 17px 22px;
  color: #fff;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.55) 0 7%, transparent 8%),
    linear-gradient(145deg, var(--lime), var(--leaf-dark));
  box-shadow:
    0 8px 18px rgba(39, 138, 83, 0.24),
    inset 0 -5px 9px rgba(16, 79, 48, 0.13);
  font-size: 1.2rem;
  font-weight: 1000;
  transform: rotate(-3deg);
}

.brand-copy {
  display: grid;
  line-height: 1;
}

.brand-copy strong {
  color: var(--ink-strong);
  font-size: 1.05rem;
  font-weight: 1000;
  letter-spacing: 0.11em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--soft);
  font-size: 0.67rem;
  font-weight: 750;
}

.player-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-copy {
  display: grid;
  gap: 2px;
  text-align: right;
}

.player-copy strong {
  max-width: 145px;
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-copy small {
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button:hover {
  border-color: rgba(39, 138, 83, 0.24);
  background: #fff;
  transform: translateY(-2px);
}

.icon-button:active {
  transform: translateY(0) scale(0.96);
}

.app-view {
  width: min(100%, var(--content-width));
  min-height: calc(100dvh - var(--header-height));
  margin: 0 auto;
  padding:
    clamp(22px, 5vw, 56px)
    max(18px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.bottom-nav:not([hidden]) ~ .app-view,
.pingo-app:has(.bottom-nav:not([hidden])) .app-view {
  padding-bottom: calc(var(--nav-height) + 28px + env(safe-area-inset-bottom));
}

.boot-screen {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  align-items: center;
  gap: clamp(34px, 7vw, 86px);
  min-height: calc(100dvh - var(--header-height) - 90px);
}

.boot-world {
  position: relative;
  display: grid;
  place-items: center;
  width: min(68vw, 370px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid rgba(39, 138, 83, 0.12);
  border-radius: 42% 58% 55% 45% / 48% 40% 60% 52%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.96) 0 5%, transparent 6%),
    radial-gradient(circle at 55% 55%, var(--lime), var(--leaf) 54%, var(--leaf-dark) 100%);
  box-shadow:
    0 34px 80px rgba(39, 138, 83, 0.24),
    inset 0 -22px 36px rgba(14, 102, 61, 0.16),
    inset 0 18px 34px rgba(255, 255, 255, 0.28);
  animation: world-float 4s ease-in-out infinite;
}

.boot-world::after {
  position: absolute;
  right: 9%;
  bottom: 7%;
  width: 58%;
  height: 16%;
  border-radius: 50%;
  background: rgba(35, 90, 68, 0.16);
  filter: blur(18px);
  transform: rotate(-5deg);
  content: "";
}

.boot-pingo {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 39%;
  aspect-ratio: 0.92;
  border: 5px solid rgba(255, 255, 255, 0.88);
  border-radius: 47% 53% 44% 56% / 38% 42% 58% 62%;
  color: var(--ink-strong);
  background:
    radial-gradient(circle at 36% 25%, #fff 0 7%, transparent 8%),
    linear-gradient(150deg, #fff6b7, var(--sun));
  box-shadow:
    0 18px 32px rgba(64, 94, 51, 0.22),
    inset 0 -10px 18px rgba(202, 145, 36, 0.14);
  font-size: clamp(2.4rem, 8vw, 4.8rem);
  font-weight: 1000;
  transform: rotate(4deg);
}

.boot-orbit {
  position: absolute;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

.boot-orbit-one {
  inset: 9%;
  animation: orbit-spin 18s linear infinite;
}

.boot-orbit-two {
  inset: 20%;
  border-style: solid;
  opacity: 0.34;
  animation: orbit-spin 13s linear infinite reverse;
}

.boot-spark {
  position: absolute;
  z-index: 3;
  width: 18px;
  aspect-ratio: 1;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 8px 18px rgba(32, 80, 58, 0.22);
}

.boot-spark-one {
  top: 16%;
  right: 17%;
  animation: spark-bob 2.1s ease-in-out infinite;
}

.boot-spark-two {
  right: 10%;
  bottom: 26%;
  width: 13px;
  background: var(--coral);
  animation: spark-bob 2.6s ease-in-out 300ms infinite;
}

.boot-spark-three {
  bottom: 16%;
  left: 18%;
  width: 15px;
  background: var(--sky);
  animation: spark-bob 2.3s ease-in-out 600ms infinite;
}

.boot-copy {
  max-width: 560px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--leaf-dark);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.boot-copy h1 {
  max-width: 12ch;
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(2.4rem, 6.5vw, 5.2rem);
  font-weight: 1000;
  letter-spacing: -0.055em;
  line-height: 0.97;
}

.boot-copy > p:not(.eyebrow) {
  max-width: 46ch;
  margin: 22px 0 0;
  color: var(--soft);
  font-size: clamp(0.96rem, 2vw, 1.08rem);
  line-height: 1.65;
}

.loading-track {
  position: relative;
  width: min(100%, 430px);
  height: 12px;
  margin-top: 30px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(24, 49, 44, 0.09);
  box-shadow:
    inset 0 1px 3px rgba(24, 49, 44, 0.1),
    0 5px 14px rgba(38, 72, 58, 0.08);
}

.loading-track span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf-dark), var(--lime), var(--sun));
  animation: loading-move 1.45s ease-in-out infinite;
}

.boot-copy > small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.bottom-nav {
  position: fixed;
  right: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, minmax(62px, 84px));
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 25px;
  padding: 7px;
  background: rgba(255, 253, 247, 0.86);
  box-shadow: 0 20px 55px rgba(38, 72, 58, 0.2);
  backdrop-filter: blur(20px) saturate(150%);
  transform: translateX(50%);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 56px;
  border-radius: 18px;
  color: var(--soft);
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.bottom-nav a > span {
  font-size: 1.12rem;
  line-height: 1;
}

.bottom-nav a > small {
  font-size: 0.62rem;
  font-weight: 850;
}

.bottom-nav a:hover,
.bottom-nav a[aria-current="page"],
.bottom-nav a.is-active {
  color: var(--leaf-dark);
  background: rgba(84, 181, 111, 0.12);
}

.bottom-nav a:active {
  transform: scale(0.95);
}

.modal-root {
  position: relative;
  z-index: 100;
}

.modal-root:empty {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-height) + 30px + env(safe-area-inset-bottom));
  z-index: 120;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  padding: 13px 16px;
  color: #fff;
  background: var(--ink-strong);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-type="success"] {
  background: var(--leaf-dark);
}

.toast[data-type="error"] {
  background: var(--danger);
}

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

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

@keyframes spark-bob {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-7px) scale(1.08);
  }
}

@keyframes loading-move {
  0% {
    transform: translateX(-105%);
  }
  65%,
  100% {
    transform: translateX(275%);
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 66px;
  }

  .app-header {
    padding-bottom: 8px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 16px 19px 15px 20px;
  }

  .player-copy {
    display: none;
  }

  .app-view {
    padding-top: 22px;
  }

  .boot-screen {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 30px;
    min-height: calc(100dvh - var(--header-height) - 56px);
    text-align: center;
  }

  .boot-world {
    width: min(56vw, 260px);
  }

  .boot-copy {
    margin: 0 auto;
  }

  .boot-copy h1 {
    max-width: 13ch;
    margin-inline: auto;
    font-size: clamp(2.3rem, 11vw, 4rem);
  }

  .boot-copy > p:not(.eyebrow) {
    margin-inline: auto;
  }

  .loading-track {
    margin-inline: auto;
  }
}

@media (max-width: 420px) {
  .brand-copy small {
    display: none;
  }

  .bottom-nav {
    right: 12px;
    left: 12px;
    grid-template-columns: repeat(4, 1fr);
    transform: none;
  }

  .boot-world {
    width: min(62vw, 230px);
  }

  .boot-copy > p:not(.eyebrow) {
    font-size: 0.9rem;
  }

  .toast {
    right: 12px;
    bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
  }
}

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