:root {
  color-scheme: light;
  --ink: #30254d;
  --paper: #fffaf0;
  --plum: #7452b8;
  --shadow-ink: #39295e;
  --star: #ffd84d;
  --star-line: #a86100;
  --tint: #fffaf0;
  --button: 56px;
  --gap: 12px;
  --press: cubic-bezier(.2, .9, .25, 1.6);
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
}

body[data-season="spring"] { --tint: #fff4f7; }
body[data-season="summer"] { --tint: #fffbe6; }
body[data-season="autumn"] { --tint: #fff3e6; }
body[data-season="winter"] { --tint: #f3f7ff; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #a9c6d8;
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
a { font: inherit; }

button,
#game-canvas {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
#game-canvas:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--plum);
}

#game-canvas:focus-visible { outline-offset: -8px; box-shadow: none; }

#game-shell {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  isolation: isolate;
  overflow: hidden;
}

#game-canvas,
#wind-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#game-canvas { cursor: grab; }
#game-canvas.dragging { cursor: grabbing; }
#wind-canvas { z-index: 5; pointer-events: none; }

svg { display: block; }
svg path,
svg circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg .fill { fill: currentColor; }

/* ---------------------------------------------------------------- HUD */

/* No z-index here: the HUD is not a stacking context, so the settings row (with the platform
   language slot) can sit above the celebration and error layers while the task panel stays below. */
.hud {
  position: absolute;
  inset: 0 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    0
    max(12px, env(safe-area-inset-left));
  pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud-actions {
  position: absolute;
  z-index: 950;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: var(--gap);
}

/* Declared spot for the platform language control (RU / EN / ET / MIX), first in the settings row. */
.lang-slot {
  display: flex;
  align-items: center;
  min-width: 86px;
  min-height: var(--button);
}

.icon-button,
.play-button,
.season-disc,
.celebrate-button {
  transition: transform 180ms var(--press), box-shadow 120ms ease-out;
}

.icon-button:active,
.play-button:active,
.season-disc:active,
.celebrate-button:active {
  transform: scale(.94);
  transition-duration: 80ms;
}

.icon-button {
  display: grid;
  place-items: center;
  width: var(--button);
  height: var(--button);
  min-height: 48px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--tint);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--shadow-ink);
  cursor: pointer;
}

.icon-button svg { width: 28px; height: 28px; }
#sound-button .icon-off,
#sound-button[aria-pressed="false"] .icon-on,
#fullscreen-button .icon-exit,
#fullscreen-button[aria-pressed="true"] .icon-enter { display: none; }
#sound-button[aria-pressed="false"] .icon-off,
#fullscreen-button[aria-pressed="true"] .icon-exit { display: block; }

.task-panel {
  position: absolute;
  z-index: 20;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 52px auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  width: max-content;
  max-width: min(480px, calc(100vw - 2 * (3 * var(--button) + 3 * var(--gap) + 86px + 28px)));
  padding: 9px 18px 10px 10px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--tint);
  box-shadow: 0 5px 0 var(--shadow-ink), 0 10px 22px rgba(31, 24, 51, .16);
}

.task-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  color: var(--plum);
}

.task-icon svg { width: 34px; height: 34px; }

.task-copy {
  display: grid;
  gap: 1px;
  line-height: 1.1;
}

.task-title {
  color: var(--plum);
  font-size: 16px;
  font-weight: 900;
}

#task-text {
  font-size: 21px;
  font-weight: 950;
  white-space: nowrap;
}

.progress-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  color: #fff;
  transition: transform 250ms var(--press), background 150ms ease-out;
}

.dot.filled {
  background: var(--plum);
  transform: scale(1.08);
}

.dot svg { width: 15px; height: 15px; }
.dot svg path { stroke-width: 3; }

.dot.friend {
  width: 30px;
  height: 30px;
  background: #fff;
  color: var(--ink);
}

.dot.friend svg { width: 22px; height: 22px; }
.dot.friend svg path,
.dot.friend svg circle { stroke-width: 2; }
.dot.friend svg .fill { fill: var(--ink); }
.task-panel:has(.dot.friend) .dot:not(.friend) { width: 30px; height: 30px; }

/* A drawn language tag, shown only in the mixed mode where seasons differ in language. */
.lang-badge {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 20px;
  margin-left: 4px;
  padding: 0 5px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .04em;
  line-height: 1;
  vertical-align: 2px;
}

.lang-badge[data-lang="ru"] { background: #ffe3e8; }
.lang-badge[data-lang="en"] { background: #e2ecff; }
.lang-badge[data-lang="et"] { background: #dff5e6; }

.disc-lang {
  position: absolute;
  top: -6px;
  left: -4px;
  margin: 0;
}

/* ---------------------------------------------------------------- start */

.start-screen {
  position: absolute;
  z-index: 15;
  inset: 0;
  pointer-events: none;
}

.start-screen > * { pointer-events: auto; }

.start-title {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 4px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 26px 12px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--shadow-ink);
  color: var(--ink);
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 950;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.start-controls {
  position: absolute;
  left: 50%;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 14px));
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 16px;
  width: max-content;
  max-width: calc(100vw - 24px);
}

.play-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 0 34px 0 24px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--star);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--shadow-ink);
  font-size: 26px;
  font-weight: 950;
  cursor: pointer;
}

.play-button svg { width: 34px; height: 34px; }

.season-wheel {
  display: flex;
  gap: var(--gap);
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--shadow-ink);
}

.season-disc {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 64px;
  min-height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.disc-face {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--shadow-ink);
}

.disc-face svg { width: 32px; height: 32px; }
.season-disc[data-season="spring"] .disc-face { background: #f8c6d9; }
.season-disc[data-season="summer"] .disc-face { background: #f7de6c; }
.season-disc[data-season="autumn"] .disc-face { background: #f2a865; }
.season-disc[data-season="winter"] .disc-face { background: #cfe0f7; }

.disc-label {
  font-size: 16px;
  font-weight: 900;
}

.disc-star {
  position: absolute;
  top: -6px;
  right: -2px;
  display: none;
  width: 28px;
  height: 28px;
}

.disc-star svg { width: 28px; height: 28px; }
.disc-star path,
.celebration-star path {
  fill: var(--star);
  stroke: var(--star-line);
  stroke-width: 1.6;
}

.season-disc.done .disc-star { display: block; }
.season-disc.suggested .disc-face { animation: suggest 1.4s cubic-bezier(.2, .9, .25, 1.2) infinite; }

@keyframes suggest {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 0 var(--shadow-ink), 0 0 0 0 rgba(255, 216, 77, .9); }
  50% { transform: scale(1.08); box-shadow: 0 4px 0 var(--shadow-ink), 0 0 0 8px rgba(255, 216, 77, .55); }
}

/* ---------------------------------------------------------------- celebration */

.celebration {
  position: absolute;
  z-index: 900;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    calc(max(12px, env(safe-area-inset-top)) + 96px)
    max(12px, env(safe-area-inset-right))
    calc(120px + env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background: rgba(48, 37, 77, .16);
}

.celebration-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(520px, 100%);
  padding: 18px 20px 22px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 8px 0 var(--shadow-ink), 0 22px 44px rgba(31, 24, 51, .24);
  text-align: center;
  animation: arrive 360ms cubic-bezier(.2, .9, .25, 1.2) both;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(18px) scale(.9); }
  to { opacity: 1; transform: none; }
}

.celebration-star {
  width: 112px;
  height: 112px;
  margin-top: -64px;
  filter: drop-shadow(0 5px 0 #e9a916);
  animation: star-pop 520ms cubic-bezier(.2, .9, .25, 1.4) both;
}

@keyframes star-pop {
  from { transform: scale(.3) rotate(-25deg); }
  to { transform: none; }
}

.celebration h2 {
  margin: 0;
  font-size: clamp(26px, 5vw, 32px);
  font-weight: 950;
}

.celebration-actions {
  display: flex;
  justify-content: center;
  gap: var(--gap);
  width: 100%;
}

.celebrate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 64px;
  min-height: 64px;
  padding: 0 18px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 var(--shadow-ink);
  font-size: 19px;
  font-weight: 950;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.celebrate-button svg { width: 28px; height: 28px; }
.celebrate-button.primary { background: var(--star); }

/* ---------------------------------------------------------------- misc */

.error-card {
  position: absolute;
  z-index: 100;
  inset: 50% auto auto 50%;
  display: grid;
  gap: 6px;
  padding: 24px 28px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--shadow-ink);
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.error-card strong { font-size: 26px; font-weight: 950; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Below this width the settings row (language slot + three buttons) leaves no room beside it. */
@media (max-width: 1000px) {
  .task-panel {
    top: calc(max(12px, env(safe-area-inset-top)) + var(--button) + 14px);
    max-width: calc(100vw - 24px);
  }
  .start-title { top: calc(max(12px, env(safe-area-inset-top)) + var(--button) + 14px); }
}

@media (max-width: 680px), (max-height: 560px) {
  :root { --button: 48px; --gap: 10px; }
  .lang-slot { min-width: 64px; }
  .icon-button { border-radius: 16px; }
  .icon-button svg { width: 26px; height: 26px; }
  .task-panel {
    top: calc(max(12px, env(safe-area-inset-top)) + var(--button) + 12px);
    grid-template-columns: 44px auto;
    padding: 7px 14px 8px 8px;
    column-gap: 10px;
    row-gap: 5px;
  }
  .task-icon { width: 44px; height: 44px; border-radius: 14px; }
  .task-icon svg { width: 30px; height: 30px; }
  #task-text { font-size: 18px; }
  .dot { width: 20px; height: 20px; }
  .start-title { top: calc(max(12px, env(safe-area-inset-top)) + var(--button) + 14px); font-size: 26px; }
  .play-button { min-height: 64px; font-size: 24px; }
  .season-wheel { gap: 8px; padding: 8px; }
  .season-disc { min-width: 60px; }
  .disc-face { width: 56px; height: 56px; }
  .celebration { padding-top: calc(max(12px, env(safe-area-inset-top)) + 150px); }
  .celebration-star { width: 92px; height: 92px; margin-top: -54px; }
  .celebrate-button {
    flex-direction: column;
    gap: 2px;
    min-width: 88px;
    min-height: 72px;
    padding: 6px 8px;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .season-disc.suggested .disc-face { box-shadow: 0 4px 0 var(--shadow-ink), 0 0 0 6px rgba(255, 216, 77, .8); }
}
