:root {
  color-scheme: light;
  font-family: Inter, Germania One, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #101711;
  color: #fff8e8;
}

@property --cooldown {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@property --evolution-progress {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
}

button {
  font: inherit;
}

.desktop-backdrop {
  display: none;
}

.game-page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 230, 166, 0.2), transparent 34%),
    radial-gradient(circle at 50% 92%, rgba(86, 111, 66, 0.32), transparent 42%),
    linear-gradient(180deg, #0d1412 0%, #202d22 100%);
}
/* ========================================
   Countdown
======================================== */

.countdown-overlay{
    position:absolute;
    inset:0;

    display:flex;
    justify-content:center;
    align-items:center;

    z-index:999;

    background:rgba(0,0,0,.12);

    backdrop-filter:blur(2px);

    pointer-events:none;
}

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

.countdown-text{

    font-size:clamp(80px,22vw,130px);

    font-weight:900;

    line-height:1;

    color:#ffffff;

    text-shadow:
        0 4px 0 rgba(60,45,20,.8),
        0 12px 30px rgba(0,0,0,.35);

    transform:scale(.5);

    opacity:0;
}

.countdown-text.show{
    animation:countdownPop .5s ease both;
}

.countdown-text.go{

    color:#ffe46d;

    text-shadow:
        0 4px 0 rgba(110,70,0,.9),
        0 0 30px rgba(255,220,90,.45);

    animation:countdownGo .55s ease both;
}

@keyframes countdownPop{

0%{
opacity:0;
transform:scale(.45);
}

30%{
opacity:1;
transform:scale(1.15);
}

100%{
opacity:0;
transform:scale(.95);
}

}

@keyframes countdownGo{

0%{
opacity:0;
transform:scale(.6);
}

35%{
opacity:1;
transform:scale(1.25);
}

100%{
opacity:0;
transform:scale(1.55);
}

}
.game-shell {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  max-width: 430px;
  max-height: 932px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #a6d9ec;
  border: 1px solid rgba(255, 248, 220, 0.3);
  box-shadow:
    0 28px 74px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(20, 27, 21, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.ability-button {
  --cooldown: 0%;
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(112px, calc(env(safe-area-inset-bottom) + 92px));
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  color: #fff8e8;
  background: rgba(18, 24, 20, 0.18);
  box-shadow:
    0 15px 32px rgba(17, 22, 18, 0.34),
    0 5px 10px rgba(255, 236, 178, 0.08),
    0 0 0 1px rgba(255, 247, 218, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px) saturate(1.2);
  cursor: pointer;
  touch-action: none;
  transition:
    filter 160ms ease,
    transform 160ms ease,
    box-shadow 180ms ease;
}

.ability-button[disabled] {
  opacity: 1;
  cursor: default;
}

.ability-button:active:not([disabled]) {
  transform: translateY(1px) scale(0.97);
}

.ability-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 25%, rgba(255, 255, 239, 0.32), transparent 28%),
    conic-gradient(from -90deg, rgba(28, 34, 29, 0.7) var(--cooldown), rgba(255, 220, 105, 0.98) 0),
    linear-gradient(180deg, rgba(255, 248, 220, 0.36), rgba(43, 31, 18, 0.24));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -10px 18px rgba(41, 25, 14, 0.24);
  transition: --cooldown 220ms linear, filter 180ms ease;
}

.ability-button[data-state="disabled"] .ability-ring {
  background:
    radial-gradient(circle at 34% 25%, rgba(255, 255, 239, 0.14), transparent 30%),
    conic-gradient(from -90deg, rgba(22, 28, 24, 0.72) 100%, rgba(255, 219, 113, 0.98) 0),
    linear-gradient(180deg, rgba(168, 178, 148, 0.3), rgba(31, 42, 31, 0.52));
  filter: saturate(0.78);
}

.ability-button[data-state="cooldown"] .ability-ring {
  background:
    radial-gradient(circle at 34% 25%, rgba(225, 241, 255, 0.26), transparent 30%),
    conic-gradient(from -90deg, rgba(23, 28, 24, 0.74) var(--cooldown), rgba(116, 183, 226, 0.96) 0),
    linear-gradient(180deg, rgba(225, 241, 255, 0.28), rgba(23, 41, 54, 0.28));
}

.ability-core {
  position: absolute;
  inset: 6px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  place-items: center;
  padding: 5px 3px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 23%, rgba(255, 250, 218, 0.5), transparent 31%),
    linear-gradient(180deg, rgba(230, 137, 61, 0.96), rgba(105, 52, 30, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -8px 14px rgba(35, 20, 12, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.12);
  transition: filter 160ms ease, transform 160ms ease;
}

.ability-button[data-animal="rabbit"] .ability-core {
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 247, 0.48), transparent 31%),
    linear-gradient(180deg, rgba(238, 221, 196, 0.98), rgba(138, 113, 91, 0.96));
}

.ability-button[data-animal="bear"] .ability-core {
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 222, 160, 0.36), transparent 31%),
    linear-gradient(180deg, rgba(124, 82, 49, 0.98), rgba(62, 41, 30, 0.98));
}

.ability-button[data-animal="eagle"] .ability-core {
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 247, 218, 0.46), transparent 31%),
    linear-gradient(180deg, rgba(132, 169, 198, 0.98), rgba(64, 72, 86, 0.98));
}

.ability-button[data-state="disabled"] .ability-core {
  filter: saturate(0.72) brightness(0.84);
  transform: scale(0.96);
}

.ability-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 18px;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  transform: translateY(1px);
  text-shadow: 0 2px 4px rgba(35, 22, 12, 0.34);
}

.ability-text {
  position: relative;
  z-index: 1;
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(30, 20, 12, 0.55);
}

.ability-status {
  margin-top: 1px;
  font-size: 6.8px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  color: rgba(255, 248, 226, 0.78);
  text-shadow: 0 1px 2px rgba(30, 20, 12, 0.52);
}

.mute-button {
  position: absolute;
  top: max(54px, calc(env(safe-area-inset-top) + 54px));
  right: max(12px, env(safe-area-inset-right));
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 247, 218, 0.24);
  border-radius: 50%;
  color: #fff8e8;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 248, 220, 0.26), transparent 36%),
    linear-gradient(180deg, rgba(42, 56, 45, 0.5), rgba(16, 25, 21, 0.44));
  box-shadow:
    0 9px 20px rgba(17, 27, 21, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px) saturate(1.15);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 140ms ease, background 180ms ease, color 180ms ease;
}

.mute-button span {
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.mute-button[aria-pressed="true"] {
  color: rgba(255, 248, 232, 0.62);
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 248, 220, 0.1), transparent 36%),
    rgba(22, 28, 24, 0.58);
}

.hud {
  --evolution-progress: 0%;
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(9px, env(safe-area-inset-left));
  right: max(9px, env(safe-area-inset-right));
  min-height: 35px;
  display: grid;
  grid-template-columns: minmax(68px, 0.8fr) minmax(55px, 0.54fr) minmax(66px, 0.64fr) minmax(94px, 0.92fr);
  grid-template-rows: auto;
  align-items: center;
  gap: 5px;
  padding: 5px 8px 7px;
  pointer-events: none;
  color: #fff9e8;
  text-shadow: 0 1px 2px rgba(16, 22, 18, 0.56);
  background:
    linear-gradient(180deg, rgba(255, 253, 235, 0.18), rgba(255, 248, 224, 0.04) 44%, transparent 52%),
    linear-gradient(180deg, rgba(35, 51, 42, 0.62), rgba(13, 23, 20, 0.48));
  border: 1px solid rgba(255, 247, 218, 0.24);
  border-radius: 999px;
  box-shadow:
    0 10px 26px rgba(14, 22, 18, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 0 rgba(13, 20, 17, 0.16);
  backdrop-filter: blur(12px) saturate(1.18);
  transition: --evolution-progress 260ms ease;
}

.hud::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 3px;
  height: 2px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 218, 105, 0.95) var(--evolution-progress), rgba(255, 247, 218, 0.16) 0);
  box-shadow: 0 0 8px rgba(255, 217, 107, 0.2);
}

.hud > div {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 4px;
}

.hud-primary {
  grid-row: auto;
}

.hud-next {
  grid-column: auto;
  grid-template-columns: minmax(0, 1fr);
}

.hud-chip {
  align-self: center;
}

.hud-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: #ffe291;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 239, 0.28), transparent 34%),
    linear-gradient(180deg, rgba(255, 222, 122, 0.18), rgba(37, 54, 43, 0.24));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 1px 4px rgba(0, 0, 0, 0.16);
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
}

.hud-label {
  display: block;
  font-size: 6.2px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  color: rgba(255, 248, 224, 0.62);
}

.hud strong {
  display: block;
  margin-top: 2.5px;
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  font-size: 9.2px;
  line-height: 1;
  font-weight: 850;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hud-primary strong {
  font-size: 13.5px;
}

.hud-next strong {
  font-size: 9px;
}

.game-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 221, 145, 0.16), transparent 34%),
    rgba(18, 22, 20, 0.68);
  color: #ffffff;
  text-align: center;
  backdrop-filter: blur(7px) saturate(1.05);
}

.game-over.hidden {
  display: none;
}

.game-over h1,
.game-over p {
  margin: 0;
}

.game-over h1 {
  font-size: 34px;
  line-height: 1.05;
}

.game-over p {
  font-size: 18px;
}

#restartButton {
  min-width: 128px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  color: #17221e;
  background: linear-gradient(180deg, #ffe071, #e8aa30);
  box-shadow:
    0 9px 20px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

#restartButton:active {
  transform: translateY(1px);
}

@media (min-width: 601px) {
  .desktop-backdrop {
    position: fixed;
    inset: -24px;
    z-index: 0;
    display: block;
    width: calc(100vw + 48px);
    height: calc(100dvh + 48px);
    filter: blur(22px) saturate(1.08) brightness(0.78);
    transform: scale(1.04);
    transform-origin: center;
    pointer-events: none;
  }

  .game-page {
    background:
      radial-gradient(circle at 50% 44%, rgba(255, 244, 206, 0.12), transparent 34%),
      radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 0%, rgba(7, 10, 9, 0.2) 58%, rgba(3, 5, 5, 0.62) 100%);
  }
}
