:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --ink: #1e2a21;
  --leaf: #2f8f46;
  --leaf-dark: #17633d;
  --moss: #93bf44;
  --sun: #ffd36a;
  --coral: #ee6a5f;
  --cream: #fff7d8;
  --panel: rgba(255, 247, 216, 0.92);
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 211, 106, 0.6), transparent 26rem),
    linear-gradient(145deg, #62c8d8 0%, #9de2d7 46%, #f7d783 100%);
}

button {
  appearance: none;
  min-width: 3rem;
  min-height: 2.75rem;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--leaf-dark);
  box-shadow: 0 5px 0 #0c3f2f;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

button:hover {
  background: #1f7447;
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #0c3f2f;
}

button:focus-visible {
  outline: 3px solid #fffdf0;
  outline-offset: 3px;
}

.app {
  width: min(100vw, 35rem);
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 2vw, 1.25rem);
}

.game {
  position: relative;
  width: min(100%, calc(100dvh * 0.5833));
  max-width: 28rem;
  aspect-ratio: 7 / 12;
  overflow: hidden;
  border: 5px solid #123728;
  border-radius: 8px;
  background: #8ad9df;
  box-shadow:
    0 1.2rem 2.5rem rgba(18, 55, 40, 0.24),
    inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

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

.hud {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 0.5rem;
  padding: 0.75rem;
  pointer-events: none;
}

.mark,
.scores {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  border: 2px solid rgba(18, 55, 40, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 240, 0.82);
  box-shadow: 0 3px 0 rgba(18, 55, 40, 0.16);
  backdrop-filter: blur(8px);
}

.mark {
  padding: 0 0.75rem;
  font-size: clamp(0.78rem, 2.8vw, 0.94rem);
  font-weight: 900;
  white-space: nowrap;
}

.scores {
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.45rem;
  max-width: 9.5rem;
  padding: 0.35rem 0.55rem;
  font-size: clamp(0.72rem, 2.6vw, 0.84rem);
  font-weight: 800;
  line-height: 1.1;
}

.scores span {
  white-space: nowrap;
}

.scores strong {
  color: var(--leaf-dark);
  font-size: 1.14em;
}

.actions {
  display: inline-flex;
  gap: 0.4rem;
  pointer-events: auto;
}

.actions button {
  width: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.5rem;
  padding: 0;
  color: #123728;
  background: var(--sun);
  box-shadow: 0 4px 0 #b27b25;
  font-size: 0.82rem;
}

.actions button:active {
  box-shadow: 0 1px 0 #b27b25;
}

.actions button.is-muted {
  color: #ffffff;
  background: var(--coral);
  box-shadow: 0 4px 0 #a33a34;
}

.actions button.is-muted:active {
  box-shadow: 0 1px 0 #a33a34;
}

.panel {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 3;
  width: min(82%, 20rem);
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 1.35rem 1rem 1.2rem;
  border: 3px solid #123728;
  border-radius: 8px;
  text-align: center;
  background: var(--panel);
  box-shadow: 0 0.8rem 0 rgba(18, 55, 40, 0.28);
  transform: translate(-50%, -50%);
}

.panel[hidden] {
  display: none;
}

.panel h1,
.panel h2,
.panel p {
  margin: 0;
}

.panel h1,
.panel h2 {
  max-width: 100%;
  font-size: clamp(2rem, 9vw, 3.3rem);
  line-height: 0.92;
  color: #123728;
  text-wrap: balance;
}

.panel h2 {
  font-size: clamp(1.85rem, 8vw, 2.8rem);
}

.panel p {
  color: #4c5d38;
  font-size: clamp(0.95rem, 3.3vw, 1.05rem);
  font-weight: 800;
}

.panel button {
  width: min(100%, 10rem);
  margin-top: 0.15rem;
  padding: 0 1.3rem;
  font-size: 1rem;
}

.panel-art {
  position: relative;
  width: 6rem;
  height: 4.65rem;
  border: 3px solid #123728;
  border-radius: 45% 53% 42% 50% / 42% 45% 58% 56%;
  background:
    radial-gradient(circle at 41% 20%, #123728 0 4.2%, transparent 4.8%),
    radial-gradient(circle at 66% 24%, #123728 0 4.2%, transparent 4.8%),
    radial-gradient(ellipse at 37% 18%, #fffdf0 0 9.5%, transparent 10.3%),
    radial-gradient(ellipse at 65% 22%, #fffdf0 0 9.5%, transparent 10.3%),
    radial-gradient(ellipse at 37% 18%, #123728 0 15%, transparent 15.8%),
    radial-gradient(ellipse at 65% 22%, #123728 0 15%, transparent 15.8%),
    radial-gradient(ellipse at 43% 68%, #f2bd8f 0 31%, transparent 32%),
    linear-gradient(#99cb47, #5cab43 50%, #2f8345);
  box-shadow: inset 0 -0.4rem 0 rgba(18, 55, 40, 0.18);
}

.panel-art::before,
.panel-art::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.panel-art::before {
  left: 17%;
  bottom: 18%;
  width: 58%;
  height: 22%;
  border-bottom: 0.28rem solid #8f3d37;
  border-radius: 50%;
  background:
    linear-gradient(180deg, transparent 0 42%, #123728 43% 52%, transparent 53%),
    radial-gradient(ellipse at 50% 72%, #b64b43 0 46%, transparent 48%);
}

.panel-art::after {
  left: 25%;
  top: 22%;
  width: 55%;
  height: 18%;
  border-top: 0.16rem solid #467d33;
  border-radius: 50%;
  transform: rotate(6deg);
}

.is-compact {
  top: 50%;
}

@media (max-width: 420px) {
  .app {
    padding: 0;
  }

  .game {
    width: min(100vw, calc(100dvh * 0.5833));
    max-width: none;
    border-width: 0;
    border-radius: 0;
  }

  .hud {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .scores {
    grid-column: 1 / 2;
    grid-row: 2;
    justify-self: start;
  }

  .actions {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

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