:root {
  color-scheme: dark;
  --forest-950: #06261c;
  --forest-900: #0a3928;
  --forest-700: #146342;
  --gold: #ffc44b;
  --gold-deep: #df8b0b;
  --sky: #2aa8d1;
  --cream: #fff8df;
  --ink: #13271e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(4, 30, 21, 0.62), rgba(4, 30, 21, 0.9)),
    url("magiczne-tlo.jpg") center 52% / cover fixed;
  color: var(--cream);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.page-shell {
  min-height: 100svh;
  display: grid;
  place-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: clamp(0.6rem, 2vw, 1.5rem);
}

.game-card {
  width: min(1120px, calc(100vw - 1.2rem));
  border: 1px solid rgba(255, 238, 171, 0.28);
  border-radius: clamp(1rem, 2vw, 1.6rem);
  overflow: hidden;
  background: rgba(4, 31, 22, 0.86);
  box-shadow:
    0 2rem 5rem rgba(0, 0, 0, 0.48),
    0 0 0 0.35rem rgba(255, 196, 75, 0.06);
}

.game-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem clamp(0.8rem, 2vw, 1.35rem);
  background:
    radial-gradient(circle at 28% 0%, rgba(255, 204, 88, 0.18), transparent 34%),
    linear-gradient(135deg, #0f5638, #082e22);
  border-bottom: 1px solid rgba(255, 239, 185, 0.18);
}

.brand-logo {
  width: 68px;
  aspect-ratio: 1;
  display: block;
  flex: 0 0 auto;
  object-fit: cover;
  border: 3px solid var(--gold);
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0.35rem 0.7rem rgba(0, 0, 0, 0.25),
    0 0 0 3px rgba(255, 255, 255, 0.16);
}

.eyebrow {
  margin: 0 0 0.12rem;
  color: #ffd978;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1;
  letter-spacing: -0.035em;
}

.header-hint {
  margin-left: auto;
  color: rgba(255, 248, 223, 0.76);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 320px;
  overflow: hidden;
  isolation: isolate;
  background: #7ba75c url("magiczne-tlo.jpg") center / cover;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.hud {
  position: absolute;
  z-index: 4;
  inset: clamp(0.65rem, 2vw, 1.1rem) clamp(0.65rem, 2vw, 1.1rem) auto;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.score-box {
  min-width: clamp(108px, 16vw, 154px);
  padding: 0.55rem 0.8rem 0.62rem;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 0.95rem;
  color: var(--ink);
  background: rgba(255, 249, 220, 0.86);
  box-shadow: 0 0.55rem 1.2rem rgba(14, 58, 34, 0.18);
  backdrop-filter: blur(10px);
}

.score-box--record {
  text-align: right;
}

.score-box span {
  display: block;
  color: #386047;
  font-size: clamp(0.68rem, 1.8vw, 0.78rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.score-box strong {
  display: block;
  margin-top: 0.1rem;
  color: #0b3f2b;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 1000;
  line-height: 1;
}

.overlay {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 5.8rem 1rem 1.4rem;
  background: linear-gradient(180deg, rgba(8, 56, 37, 0.1), rgba(3, 30, 20, 0.38));
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.overlay-panel {
  width: min(520px, 92%);
  padding: clamp(1.1rem, 3vw, 1.65rem);
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 1.4rem;
  text-align: center;
  color: var(--ink);
  background: rgba(255, 250, 229, 0.92);
  box-shadow:
    0 1.4rem 3rem rgba(2, 35, 22, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
}

.start-waffel {
  width: clamp(72px, 10vw, 96px);
  aspect-ratio: 1;
  display: block;
  margin: -0.2rem auto 0.6rem;
  object-fit: cover;
  object-position: center 11%;
  border: 4px solid #ffc44b;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.45rem 1rem rgba(17, 74, 45, 0.22);
}

.overlay-kicker {
  margin: 0 0 0.28rem;
  color: #8c5a00;
  font-size: 0.78rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.overlay h2 {
  margin: 0;
  color: #0d4a32;
  font-size: clamp(1.45rem, 4.5vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.overlay p:not(.overlay-kicker) {
  margin: 0.65rem auto 0;
  color: #3d5f4d;
  font-size: clamp(0.9rem, 2.4vw, 1rem);
  line-height: 1.38;
}

.primary-button {
  min-width: 180px;
  min-height: 54px;
  margin-top: 1rem;
  padding: 0.78rem 1.5rem;
  border: 0;
  border-radius: 999px;
  color: #17331f;
  background: linear-gradient(180deg, #ffdb70, #ffad21);
  box-shadow:
    0 0.42rem 0 #b56808,
    0 0.8rem 1.4rem rgba(139, 82, 4, 0.28);
  cursor: pointer;
  font-size: 1.08rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  transition: transform 100ms ease, filter 100ms ease, box-shadow 100ms ease;
}

.primary-button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0.3rem);
  box-shadow: 0 0.1rem 0 #b56808;
}

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

.controls-copy {
  font-size: 0.78rem !important;
  font-weight: 700;
  opacity: 0.82;
}

.jump-button {
  position: absolute;
  z-index: 5;
  right: clamp(0.75rem, 2vw, 1.3rem);
  bottom: clamp(0.75rem, 2vw, 1.3rem);
  display: none;
  min-width: 90px;
  min-height: 58px;
  padding: 0.55rem 1rem;
  border: 2px solid rgba(255, 255, 255, 0.64);
  border-radius: 999px;
  color: #17331f;
  background: rgba(255, 207, 83, 0.94);
  box-shadow: 0 0.55rem 1rem rgba(3, 30, 18, 0.28);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 1000;
  letter-spacing: 0.05em;
  touch-action: manipulation;
}

.jump-button span {
  display: inline-block;
  margin-right: 0.2rem;
  font-size: 1.25rem;
  transform: translateY(1px);
}

.game-stage.is-playing .jump-button {
  display: block;
}

.loading-message {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  color: #17331f;
  background: rgba(255, 249, 224, 0.92);
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 900;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.loading-message.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 1rem;
  max-width: 1120px;
  color: rgba(255, 248, 223, 0.78);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.legal-footer a {
  color: inherit;
  text-decoration-color: rgba(255, 196, 75, 0.55);
  text-underline-offset: 0.2em;
}

.legal-footer a:hover,
.legal-footer a:focus-visible {
  color: #fff4c2;
  text-decoration-color: var(--gold);
}

.home-link {
  font-weight: 900;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.85rem;
}

@media (max-width: 700px) {
  .page-shell {
    place-content: start center;
    padding: 0;
  }

  .game-card {
    width: 100%;
    height: 100svh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border: 0;
    border-radius: 0;
  }

  .game-header {
    min-height: 66px;
    padding-top: max(0.6rem, env(safe-area-inset-top));
  }

  .brand-logo {
    width: 54px;
    border-width: 2px;
  }

  .header-hint {
    display: none;
  }

  .game-stage {
    height: auto;
    min-height: 0;
    aspect-ratio: auto;
  }

  .overlay {
    padding-top: 6.4rem;
    padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
  }

  .overlay-panel {
    width: min(420px, 95%);
  }

  .jump-button {
    bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .legal-footer {
    width: 100%;
    padding: 0.85rem 1rem max(0.85rem, env(safe-area-inset-bottom));
    background: #06261c;
  }

  .legal-links {
    gap: 0.4rem 0.75rem;
  }
}

@media (orientation: landscape) and (max-height: 700px) {
  html,
  body {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
  }

  .page-shell {
    min-height: 100svh;
    height: auto;
    display: block;
    gap: 0;
    padding: 0;
  }

  .game-card {
    width: 100%;
    height: 100svh;
    min-height: 0;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
    border: 0;
    border-radius: 0;
  }

  .game-header {
    height: 52px;
    min-height: 52px;
    padding: 0.35rem max(0.65rem, env(safe-area-inset-right)) 0.35rem max(0.65rem, env(safe-area-inset-left));
  }

  .brand-logo {
    width: 44px;
    border-width: 2px;
  }

  .eyebrow {
    margin-bottom: 0.05rem;
    font-size: 0.6rem;
  }

  h1 {
    font-size: clamp(1.05rem, 3vw, 1.45rem);
  }

  .header-hint {
    display: none;
  }

  .game-stage {
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: auto;
  }

  .hud {
    right: max(0.65rem, env(safe-area-inset-right));
    left: max(0.65rem, env(safe-area-inset-left));
  }

  .overlay {
    padding: 4.1rem 0.75rem 0.5rem;
  }

  .overlay-panel {
    width: min(460px, 82%);
    padding: 0.6rem 1rem 0.7rem;
    border-radius: 1rem;
  }

  .start-waffel {
    width: 48px;
    margin: -0.1rem auto 0.25rem;
    border-width: 3px;
  }

  .overlay-kicker {
    margin-bottom: 0.12rem;
    font-size: 0.65rem;
  }

  .overlay h2 {
    font-size: clamp(1.1rem, 4vw, 1.45rem);
  }

  .overlay p:not(.overlay-kicker) {
    margin-top: 0.3rem;
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .primary-button {
    min-width: 150px;
    min-height: 42px;
    margin-top: 0.5rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.92rem;
  }

  .controls-copy {
    font-size: 0.66rem !important;
    line-height: 1.25;
  }

  .jump-button {
    right: max(0.6rem, env(safe-area-inset-right));
    bottom: max(0.6rem, env(safe-area-inset-bottom));
    min-width: 78px;
    min-height: 48px;
  }

  .legal-footer {
    display: none;
  }
}

@media (pointer: coarse) {
  .game-stage.is-playing .jump-button {
    display: block;
  }
}

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