:root {
  color-scheme: light;
  --ink: #202020;
  --paper: #fff8ef;
  --sky: #a9dded;
  --mint: #d7efdf;
  --sun: #f4b63f;
  --rose: #cf6b7d;
  --violet: #7866d8;
  --teal: #2ba6a4;
  --coral: #f07855;
  --leaf: #6fba68;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 17% 18%, rgba(244, 182, 63, 0.28), transparent 24%),
    linear-gradient(180deg, var(--sky) 0%, var(--mint) 72%, #8fbf7b 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.directory-page {
  display: grid;
  align-items: start;
  justify-items: center;
  overflow: auto;
}

.directory-shell {
  width: min(100%, 1060px);
  padding: 16px 0 32px;
}

.directory-header {
  display: flex;
  align-items: end;
  justify-content: center;
  margin-bottom: 18px;
}

.directory-header h1 {
  width: 100%;
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
  text-align: center;
}

.game-directory {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(128px, 16vh);
  gap: 16px;
}

.game-tile {
  position: relative;
  display: flex;
  align-items: end;
  min-height: 128px;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 248, 239, 0.92), rgba(215, 239, 223, 0.88)),
    var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  text-decoration: none;
}

.game-tile[href] {
  cursor: pointer;
}

.game-tile[href]:hover,
.game-tile[href]:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.game-tile[href]:focus-visible {
  outline: 4px solid #fffdf6;
  outline-offset: 3px;
}

.game-tile--featured {
  background: var(--sky);
}

.game-tile::after {
  position: absolute;
  inset: auto 0 0 0;
  height: 58%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.68));
  content: "";
}

.game-tile:not(.game-tile--featured)::after {
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.34));
}

.game-tile span {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  padding: 14px 16px;
  color: #fffdf6;
  font-size: clamp(18px, 2vw, 28px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.48);
}

.game-tile:not(.game-tile--featured) span {
  color: #fffdf6;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.42);
}

.game-tile-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.game-tile-preview--spark {
  background:
    radial-gradient(circle at 78% 18%, rgba(244, 182, 63, 0.92) 0 42px, transparent 43px),
    linear-gradient(180deg, #8fcde8 0%, #d6ebc9 72%, #78a761 100%);
}

.game-tile-preview--stuffies {
  background:
    radial-gradient(circle at 77% 18%, rgba(244, 182, 63, 0.9) 0 44px, transparent 45px),
    linear-gradient(180deg, #9cdbec 0%, #d9efcf 72%, #78a761 100%);
}

.game-tile-preview--rings {
  background:
    radial-gradient(circle at 78% 22%, rgba(255, 248, 239, 0.34) 0 42px, transparent 43px),
    linear-gradient(135deg, #f39a7c 0%, #f5cf62 48%, #71c78a 100%);
}

.game-tile-preview--blocks {
  background:
    linear-gradient(90deg, rgba(255, 253, 246, 0.16) 0 8px, transparent 8px 40px),
    linear-gradient(150deg, #77c7e8 0%, #7866d8 58%, #2b2f6f 100%);
}

.game-tile-preview--waves {
  background:
    radial-gradient(circle at 16% 22%, rgba(255, 253, 246, 0.74) 0 28px, transparent 29px),
    linear-gradient(145deg, #50b9b6 0%, #9bddc8 50%, #f7d86e 100%);
}

.game-tile-preview--stars {
  background:
    radial-gradient(circle at 80% 24%, rgba(244, 182, 63, 0.9) 0 36px, transparent 37px),
    linear-gradient(135deg, #29366f 0%, #6551a8 56%, #c95c83 100%);
}

.game-tile-preview--orbits {
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 253, 246, 0.58) 0 52px, transparent 53px),
    linear-gradient(135deg, #111b3d 0%, #26507d 55%, #5cb7b7 100%);
}

.game-tile-preview--confetti {
  background:
    linear-gradient(135deg, rgba(255, 253, 246, 0.17) 0 25%, transparent 25% 50%, rgba(255, 253, 246, 0.17) 50% 75%, transparent 75%),
    linear-gradient(135deg, #ffcc66 0%, #f07855 48%, #cf6b7d 100%);
  background-size: auto, 100% 100%;
}

.game-tile-preview--ribbons {
  background:
    radial-gradient(circle at 22% 24%, rgba(255, 253, 246, 0.62) 0 28px, transparent 29px),
    linear-gradient(145deg, #d8f0ff 0%, #a2c8f4 46%, #8d6bd1 100%);
}

.spark {
  position: absolute;
  width: 68px;
  height: 68px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 4px 4px 0 rgba(32, 32, 32, 0.35);
}

.stuffie-card {
  position: absolute;
  display: grid;
  place-items: center;
  width: 74px;
  height: 64px;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background: #fffdf6;
  box-shadow: 5px 5px 0 rgba(32, 32, 32, 0.35);
  font-style: normal;
  font-size: 34px;
}

.stuffie-card--bear {
  left: 18%;
  top: 22%;
  transform: rotate(-8deg);
}

.stuffie-card--bunny {
  left: 35%;
  top: 31%;
  transform: rotate(7deg);
}

.stuffie-card--cat {
  right: 31%;
  top: 18%;
  transform: rotate(-5deg);
}

.stuffie-card--frog {
  right: 16%;
  top: 38%;
  transform: rotate(10deg);
}

.stuffie-card--panda {
  left: 44%;
  bottom: 18%;
  transform: rotate(-11deg);
}

.stuffie-card--fox {
  right: 41%;
  bottom: 27%;
  transform: rotate(9deg) scale(0.88);
}

.spark::before,
.spark::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 120%;
  height: 4px;
  border-radius: 999px;
  background: var(--ink);
  content: "";
  transform: translate(-50%, -50%);
}

.spark::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.spark--one {
  left: 20%;
  top: 20%;
}

.spark--two {
  right: 22%;
  top: 28%;
  transform: scale(0.7) rotate(18deg);
}

.spark--three {
  left: 46%;
  bottom: 18%;
  transform: scale(0.48) rotate(34deg);
}

.ring,
.block,
.wave,
.star,
.orbit,
.planet,
.confetti,
.ribbon {
  position: absolute;
  display: block;
}

.ring {
  border: 5px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 253, 246, 0.32);
  box-shadow: 4px 4px 0 rgba(32, 32, 32, 0.3);
}

.ring--one {
  left: 20%;
  top: 18%;
  width: 86px;
  height: 86px;
}

.ring--two {
  left: 42%;
  top: 34%;
  width: 58px;
  height: 58px;
}

.ring--three {
  right: 18%;
  top: 20%;
  width: 104px;
  height: 104px;
}

.block {
  width: 88px;
  height: 72px;
  border: 4px solid var(--ink);
  border-radius: 7px;
  box-shadow: 5px 5px 0 rgba(32, 32, 32, 0.38);
}

.block--one {
  left: 18%;
  top: 22%;
  background: var(--sun);
  transform: rotate(-10deg);
}

.block--two {
  left: 48%;
  top: 24%;
  background: #fffdf6;
  transform: rotate(8deg) scale(0.78);
}

.block--three {
  right: 18%;
  bottom: 18%;
  background: var(--coral);
  transform: rotate(-16deg) scale(0.64);
}

.wave {
  left: 12%;
  width: 76%;
  height: 36px;
  border: 5px solid var(--ink);
  border-color: var(--ink) transparent transparent transparent;
  border-radius: 50%;
}

.wave--one {
  top: 30%;
}

.wave--two {
  top: 45%;
  transform: scaleX(0.8);
}

.wave--three {
  top: 60%;
  transform: scaleX(0.62);
}

.star {
  width: 82px;
  height: 82px;
  background: var(--sun);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 56%, 79% 92%, 50% 70%, 21% 92%, 32% 56%, 2% 35%, 39% 35%);
  filter: drop-shadow(4px 4px 0 rgba(32, 32, 32, 0.38));
}

.star--one {
  left: 20%;
  top: 22%;
}

.star--two {
  right: 22%;
  top: 30%;
  transform: scale(0.62) rotate(16deg);
}

.star--three {
  left: 52%;
  bottom: 14%;
  transform: scale(0.46) rotate(-12deg);
}

.orbit {
  left: 50%;
  top: 50%;
  width: 250px;
  height: 86px;
  border: 4px solid rgba(255, 253, 246, 0.74);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-20deg);
}

.orbit--two {
  transform: translate(-50%, -50%) rotate(28deg);
}

.planet {
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 5px 5px 0 rgba(32, 32, 32, 0.34);
  transform: translate(-50%, -50%);
}

.confetti {
  width: 72px;
  height: 22px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: #fffdf6;
  box-shadow: 4px 4px 0 rgba(32, 32, 32, 0.28);
}

.confetti--one {
  left: 16%;
  top: 20%;
  transform: rotate(-20deg);
}

.confetti--two {
  right: 20%;
  top: 24%;
  background: var(--teal);
  transform: rotate(18deg) scale(0.78);
}

.confetti--three {
  left: 42%;
  bottom: 26%;
  background: var(--sun);
  transform: rotate(8deg) scale(0.68);
}

.confetti--four {
  right: 32%;
  bottom: 18%;
  background: var(--leaf);
  transform: rotate(-28deg) scale(0.54);
}

.ribbon {
  left: 50%;
  width: 68%;
  height: 26px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: #fffdf6;
  box-shadow: 4px 4px 0 rgba(32, 32, 32, 0.28);
  transform-origin: center;
}

.ribbon--one {
  top: 28%;
  transform: translateX(-50%) rotate(-12deg);
}

.ribbon--two {
  top: 46%;
  width: 52%;
  background: var(--rose);
  transform: translateX(-50%) rotate(10deg);
}

.ribbon--three {
  top: 62%;
  width: 42%;
  background: var(--sun);
  transform: translateX(-50%) rotate(-6deg);
}

.game-page {
  display: block;
  overflow: auto;
}

.home-link {
  position: fixed;
  left: 24px;
  top: 24px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: #fffdf6;
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
}

.home-link:hover,
.home-link:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.game-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px 0 34px;
}

.game-header {
  margin-bottom: 18px;
  text-align: center;
}

.game-header h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 76px);
  line-height: 1;
  text-shadow: 0 3px 0 rgba(32, 32, 32, 0.18);
}

.stuffie-stage {
  position: relative;
  min-height: 720px;
  overflow: hidden;
  border: 5px solid var(--ink);
  border-radius: 8px;
  background:
    radial-gradient(circle at 80% 18%, rgba(244, 182, 63, 0.92) 0 62px, transparent 63px),
    radial-gradient(circle at 22% 24%, rgba(255, 253, 246, 0.68) 0 28px, transparent 29px),
    linear-gradient(180deg, #95d6ea 0%, #cae8d4 70%, #6fa55f 70% 100%);
  box-shadow: 5px 5px 0 var(--ink);
}

.stuffie-stage::before,
.stuffie-stage::after {
  position: absolute;
  inset: auto 0 0;
  height: 30%;
  background:
    linear-gradient(90deg, rgba(32, 32, 32, 0.12) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 32, 32, 0.18), rgba(32, 32, 32, 0.02));
  background-size: 34px 100%, 100% 100%;
  content: "";
}

.stuffie-stage::after {
  inset: 0;
  height: auto;
  pointer-events: none;
  background:
    radial-gradient(circle at 28% 28%, rgba(255, 253, 246, 0.7) 0 20px, transparent 21px),
    radial-gradient(circle at 31% 28%, rgba(255, 253, 246, 0.7) 0 24px, transparent 25px),
    radial-gradient(circle at 35% 28%, rgba(255, 253, 246, 0.7) 0 20px, transparent 21px),
    radial-gradient(circle at 67% 24%, rgba(255, 253, 246, 0.66) 0 24px, transparent 25px),
    radial-gradient(circle at 71% 24%, rgba(255, 253, 246, 0.66) 0 29px, transparent 30px),
    radial-gradient(circle at 75% 24%, rgba(255, 253, 246, 0.66) 0 22px, transparent 23px);
}

.game-status,
.score-badge,
.leaderboard-panel,
.save-panel,
.center-dialog,
.game-actions button {
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.92);
  box-shadow: 5px 5px 0 rgba(32, 32, 32, 0.88);
}

.game-status {
  position: absolute;
  left: 24px;
  top: 24px;
  z-index: 3;
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 14px 18px;
  font-size: 18px;
}

.game-status strong,
.score-badge strong {
  font-size: 30px;
  line-height: 1;
}

.score-badge {
  position: absolute;
  right: 24px;
  top: 24px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 170px;
  padding: 14px 18px;
  text-transform: uppercase;
}

.score-badge span {
  font-size: 17px;
  font-weight: 900;
}

.stuffie-board {
  position: relative;
  z-index: 2;
  width: min(78%, 720px);
  height: clamp(340px, 40vw, 410px);
  margin: 132px auto 120px;
  border: 5px solid var(--ink);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(32, 32, 32, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, #fffdf6, #eee9db);
  background-size: 60px 100%, 100% 100%;
  box-shadow: 8px 8px 0 rgba(32, 32, 32, 0.88);
}

.stuffie-tile {
  position: absolute;
  display: grid;
  place-items: center;
  width: calc(var(--tile-width) + 10px);
  min-width: 58px;
  max-width: 112px;
  aspect-ratio: 1.12;
  padding: 4px;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 253, 246, 0.9), rgba(244, 214, 156, 0.92)),
    #fffdf6;
  box-shadow: 4px 4px 0 rgba(32, 32, 32, 0.48);
  cursor: pointer;
  transform: translate(calc(-50% + var(--lift)), calc(-50% - var(--lift)));
}

.stuffie-tile:hover:not(:disabled),
.stuffie-tile:focus-visible {
  box-shadow:
    0 0 0 4px rgba(244, 182, 63, 0.5),
    5px 5px 0 rgba(32, 32, 32, 0.55);
}

.stuffie-tile.is-selected {
  background:
    linear-gradient(135deg, rgba(255, 253, 246, 0.96), rgba(255, 215, 111, 0.96)),
    #fffdf6;
  box-shadow:
    0 0 0 5px rgba(43, 166, 164, 0.44),
    5px 5px 0 rgba(32, 32, 32, 0.58);
}

.stuffie-tile:disabled {
  cursor: not-allowed;
  filter: grayscale(0.22);
  opacity: 0.62;
}

.stuffie-tile span {
  display: block;
  width: 100%;
}

.stuffie-tile svg {
  display: block;
  width: 100%;
  height: auto;
}

.game-actions {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 4;
  display: flex;
  gap: 12px;
  transform: translateX(-50%);
}

.game-actions button,
.save-panel button,
.center-dialog button {
  min-height: 44px;
  padding: 8px 16px;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.game-actions button:hover,
.game-actions button:focus-visible,
.save-panel button:hover,
.save-panel button:focus-visible,
.center-dialog button:hover,
.center-dialog button:focus-visible {
  background: #ffe2a8;
}

.leaderboard-panel {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 4;
  width: min(270px, calc(100% - 48px));
  overflow: hidden;
}

.leaderboard-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 3px solid rgba(32, 32, 32, 0.22);
}

.leaderboard-panel h2,
.save-panel h2,
.center-dialog h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  text-transform: uppercase;
}

.leaderboard-panel header button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #fffdf6;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.leaderboard-panel ol {
  display: grid;
  gap: 6px;
  min-height: 82px;
  max-height: 176px;
  margin: 0;
  padding: 12px 16px 14px 32px;
  overflow: auto;
  font-weight: 900;
}

.leaderboard-panel li {
  padding-left: 2px;
}

.leaderboard-panel li span {
  display: inline-block;
  max-width: 136px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.leaderboard-panel li strong {
  float: right;
}

.save-panel {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 5;
  display: none;
  width: min(330px, calc(100% - 48px));
  padding: 14px;
}

.save-panel.is-visible {
  display: block;
}

.save-panel form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.save-panel input {
  min-width: 0;
  flex: 1;
  min-height: 44px;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fffdf6;
  color: var(--ink);
  font-weight: 900;
}

.center-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  display: none;
  width: min(360px, calc(100% - 48px));
  padding: 18px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.center-dialog.is-visible {
  display: grid;
  gap: 14px;
}

.center-dialog p {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

@media (max-width: 720px) {
  body {
    padding: 16px;
  }

  .game-directory {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(120px, 18vh);
  }

  .home-link {
    position: static;
    margin-bottom: 16px;
  }

  .game-shell {
    padding-top: 0;
  }

  .game-header h1 {
    font-size: 42px;
  }

  .stuffie-stage {
    min-height: 760px;
  }

  .game-status,
  .score-badge {
    top: 16px;
  }

  .game-status {
    left: 16px;
    min-width: 150px;
    padding: 10px 12px;
    font-size: 15px;
  }

  .score-badge {
    right: 16px;
    min-width: 128px;
    gap: 12px;
    padding: 10px 12px;
  }

  .score-badge span {
    font-size: 14px;
  }

  .game-status strong,
  .score-badge strong {
    font-size: 24px;
  }

  .stuffie-board {
    width: calc(100% - 28px);
    height: 430px;
    margin-top: 116px;
  }

  .stuffie-tile {
    width: clamp(50px, 17vw, 76px);
  }

  .leaderboard-panel,
  .save-panel {
    left: 16px;
    right: 16px;
    width: auto;
  }

  .leaderboard-panel {
    bottom: 86px;
  }

  .save-panel {
    bottom: 198px;
  }

  .game-actions {
    bottom: 16px;
    width: calc(100% - 32px);
    justify-content: center;
  }

  .game-actions button {
    flex: 1;
    padding-inline: 8px;
  }
}
