/* Bright, blocky colours: Minecraft sky and grass, Pokémon gold, hero colours. */
:root {
  --sky-top: #6ec6ff;
  --sky-bottom: #c8f0ff;
  --grass: #5dae3b;
  --grass-dark: #3f8a26;
  --dirt: #8b5a2b;
  --dirt-dark: #6b4220;
  --stone: #8a8a8a;
  --stone-dark: #5a5a5a;
  --panel: #fff8e6;
  --ink: #1b1b1b;
  --muted: #5d5548;
  --gold: #ffcb05;
  --gold-dark: #c79a00;
  --green: #2ba84a;
  --green-dark: #1d7a35;
  --red: #e3350d;
  --blue: #2a75bb;
  --blue-light: #dbe9f7;
  --purple: #7b4fb8;
  --purple-light: #ebe1f7;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(var(--sky-top), var(--sky-bottom)) fixed;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

h1,
h2,
button {
  font-family: var(--pixel);
}

/* Pixel pictures keep their blocky shape at any size. */
.art {
  display: inline-block;
  width: 1.4em;
  line-height: 0;
}

.art svg {
  width: 100%;
  height: auto;
}

/* A "block": thick outline plus a light top-left and dark bottom-right edge, like Minecraft. */
.block {
  border: 4px solid var(--ink);
  border-radius: 0;
  box-shadow:
    inset -4px -4px 0 rgba(0, 0, 0, 0.22),
    inset 4px 4px 0 rgba(255, 255, 255, 0.45);
}

.panel {
  background: var(--panel);
  padding: 16px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 20px;
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  color: #fff;
  text-shadow:
    3px 3px 0 var(--ink),
    -2px -2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px 2px 0 var(--ink);
}

/* --- Progress: 10 slots --- */

.progress {
  text-align: center;
}

.slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 340px;
  margin: 0 auto 12px;
}

.slot {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--stone-dark);
}

.slot .art {
  width: 70%;
  opacity: 0.15;
  filter: grayscale(1);
}

.slot.filled {
  background: var(--gold);
}

.slot.filled .art {
  opacity: 1;
  filter: none;
}

.slot.pop {
  animation: pop 0.5s ease-out;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* All 10 filled: the slots shimmer, waiting for the chest to be opened. */
.slots.ready .slot {
  animation: shimmer 1.2s ease-in-out infinite;
}

.slots.ready .slot:nth-child(odd) {
  animation-delay: 0.3s;
}

@keyframes shimmer {
  50% { background: #fff3a6; transform: translateY(-3px); }
}

.count {
  margin: 0;
  font: 700 1.6rem var(--pixel);
}

.extra {
  font-size: 1rem;
  color: var(--green-dark);
}

.hint {
  margin: 4px 0 0;
  font-weight: 600;
  color: var(--muted);
}

/* --- The big buttons --- */

.actions {
  display: flex;
  justify-content: center;
  margin: 8px 0 28px;
}

.big-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(100%, 320px);
  padding: 18px 16px 22px;
  background: var(--green);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  text-shadow: 2px 2px 0 var(--green-dark);
  cursor: pointer;
  transition: transform 0.08s;
  box-shadow:
    inset -6px -6px 0 rgba(0, 0, 0, 0.25),
    inset 6px 6px 0 rgba(255, 255, 255, 0.35),
    0 8px 0 var(--ink);
}

.big-button:active {
  transform: translateY(6px);
  box-shadow:
    inset -6px -6px 0 rgba(0, 0, 0, 0.25),
    inset 6px 6px 0 rgba(255, 255, 255, 0.35),
    0 2px 0 var(--ink);
}

.big-button:focus-visible,
.small-button:focus-visible,
.hero-choice:focus-visible,
.choice:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
}

.big-art {
  width: 72px;
}

.chest-button {
  background: var(--gold);
  color: var(--ink);
  text-shadow: none;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  50% { transform: translateY(-8px); }
}

.shake {
  animation: shake 0.35s;
}

@keyframes shake {
  25% { transform: translateX(-6px) rotate(-2deg); }
  75% { transform: translateX(6px) rotate(2deg); }
}

/* --- Heroes --- */

.heroes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.heroes .panel {
  margin: 0;
  padding: 12px;
}

.hero header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.hero header .art {
  width: 36px;
}

.hero h2 {
  margin: 0;
  font-size: 1.1rem;
}

.hero.roni {
  background: var(--blue-light);
}

.hero.varjo {
  background: var(--purple-light);
}

.hero ul,
.tasted ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hero li {
  padding: 6px 0;
  border-top: 2px dashed rgba(0, 0, 0, 0.15);
}

.hero li strong {
  display: block;
  font-family: var(--pixel);
  font-size: 1.05rem;
}

.hero li span {
  font-size: 0.85rem;
  color: var(--muted);
}

.hero .empty-hero {
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- Tasted foods --- */

.tasted ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tasted li {
  padding: 4px 10px;
  background: #fff;
  border: 3px solid var(--ink);
  font-weight: 600;
}

.tasted li small {
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

footer {
  text-align: center;
  padding: 8px 0 20px;
}

footer a {
  color: var(--ink);
  font-family: var(--pixel);
}

/* Grass and dirt along the bottom of the page. */
.ground {
  height: 56px;
  background:
    linear-gradient(var(--grass) 0 16px, var(--grass-dark) 16px 20px, transparent 20px),
    repeating-linear-gradient(90deg, var(--dirt) 0 16px, var(--dirt-dark) 16px 20px, var(--dirt) 20px 40px);
  border-top: 4px solid var(--ink);
}

/* --- Small buttons and dialogs --- */

.small-button {
  padding: 10px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.small-button.green {
  background: var(--green);
  color: #fff;
}

.small-button.grey {
  background: #e8e2d4;
  color: var(--ink);
}

.small-button.red {
  background: var(--red);
  color: #fff;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--ink);
  padding: 20px;
}

dialog::backdrop {
  background: rgba(10, 30, 60, 0.6);
}

dialog h2 {
  margin: 0 0 12px;
  font-size: 1.5rem;
  text-align: center;
}

dialog input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 4px solid var(--ink);
  font-size: 1.2rem;
  background: #fff;
}

.dialog-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

/* --- Unlocking a perk --- */

.choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.choice .art {
  width: 36px;
  flex: none;
}

.choice strong {
  display: block;
  font-size: 1.2rem;
}

.choice span {
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--muted);
}

.picked {
  text-align: center;
  font: 700 1.2rem var(--pixel);
  margin: 0 0 12px;
}

.hero-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hero-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.hero-choice .art {
  width: 64px;
}

.hero-choice.roni {
  background: var(--blue-light);
}

.hero-choice.varjo {
  background: var(--purple-light);
}

.reveal-chest {
  display: grid;
  place-items: center;
  padding: 20px 0;
}

.reveal-chest .art {
  width: 140px;
  animation: rattle 0.18s linear infinite;
}

@keyframes rattle {
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}

.reveal-card {
  text-align: center;
  animation: grow 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes grow {
  from { transform: scale(0.2); opacity: 0; }
}

.reveal-hero {
  margin: 0;
  font: 700 1.1rem var(--pixel);
  color: var(--muted);
}

.reveal-name {
  margin: 6px 0;
  font: 700 2rem var(--pixel);
}

.reveal-desc {
  margin: 0 0 18px;
  font-size: 1.1rem;
}

/* --- Toast and the flying star --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 16px;
  background: var(--panel);
  font: 700 1.05rem var(--pixel);
  z-index: 10;
}

.flyer,
.spark {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 20;
}

.flyer {
  width: 64px;
}

.spark {
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
  }
}

@media (max-width: 380px) {
  .heroes {
    grid-template-columns: 1fr;
  }
}
