* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  background: linear-gradient(135deg, #ff00cc, #3333ff, #00ffcc);
  background-size: 400% 400%;
  animation: slop-gradient 12s ease infinite;
  color: #111;
  min-height: 100vh;
  padding: 24px 16px 48px;
}

@keyframes slop-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.hero {
  max-width: 720px;
  margin: 0 auto 20px;
  text-align: center;
  background: rgba(255, 255, 0, 0.85);
  border: 6px dashed #ff0066;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 8px 8px 0 #000;
}

.hero-title {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  color: #d10000;
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 #000;
  letter-spacing: 1px;
}

.hero-tagline {
  margin: 0 0 12px;
  font-weight: bold;
  font-style: italic;
  color: #0000cc;
}

.hero-blurb {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.versions {
  max-width: 720px;
  margin: 0 auto 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.version-link {
  display: inline-block;
  padding: 8px 14px;
  background: #fff;
  border: 3px solid #000;
  border-radius: 999px;
  color: #000;
  text-decoration: none;
  font-weight: bold;
  box-shadow: 3px 3px 0 #000;
}

.version-link:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}

.version-link.current {
  background: #00ff88;
}

.game {
  max-width: max-content;
  margin: 0 auto;
  background: #c0c0c0;
  border: 4px solid #7b7b7b;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.35);
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #bdbdbd;
  border: 3px inset #fff;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.hud-readout {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 1.5rem;
  background: #000;
  color: #ff2b2b;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 62px;
  text-align: center;
}

.hud-reset {
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
  border: 3px outset #fff;
  background: #c0c0c0;
  cursor: pointer;
}

.hud-reset:active {
  border-style: inset;
}

.game-controls {
  margin-bottom: 12px;
  font-weight: bold;
}

.game-controls select {
  font: inherit;
  padding: 4px;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 9), 30px);
  gap: 0;
  background: #7b7b7b;
  border: 3px inset #fff;
  width: max-content;
}

.cell {
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 1rem;
  line-height: 1;
  border: 3px outset #fff;
  background: #c0c0c0;
  cursor: pointer;
  user-select: none;
}

.cell.revealed {
  border: 1px solid #9b9b9b;
  background: #d6d6d6;
  cursor: default;
}

.cell[data-value="1"] { color: #0000ff; }
.cell[data-value="2"] { color: #008200; }
.cell[data-value="3"] { color: #ff0000; }
.cell[data-value="4"] { color: #000084; }
.cell[data-value="5"] { color: #840000; }
.cell[data-value="6"] { color: #008284; }
.cell[data-value="7"] { color: #000000; }
.cell[data-value="8"] { color: #808080; }

.game-hint {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: #333;
  max-width: 340px;
}

.site-footer {
  margin: 32px auto 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(0, 0, 0, 0.7);
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}

#toast-layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  padding: 22px 40px;
  font-family: "Comic Sans MS", "Trebuchet MS", sans-serif;
  font-weight: bold;
  font-size: clamp(2rem, 7vw, 4rem);
  text-align: center;
  color: #fff;
  background: hsl(var(--hue, 300), 90%, 55%);
  border: 6px solid #000;
  border-radius: 20px;
  box-shadow: 10px 10px 0 #000, 0 0 60px hsl(var(--hue, 300), 100%, 60%);
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000;
  white-space: nowrap;
  max-width: 92vw;
  margin-left: var(--nudge-x, 0px);
  margin-top: var(--nudge-y, 0px);
  transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
  animation-duration: 0.5s;
  animation-fill-mode: both;
}

.toast-big {
  font-size: clamp(2.8rem, 11vw, 6rem);
  padding: 32px 56px;
  border-width: 8px;
  box-shadow: 14px 14px 0 #000, 0 0 100px hsl(var(--hue, 300), 100%, 60%);
  animation-duration: 0.7s;
}

.toast-leave {
  animation: toast-out 0.5s both;
}

.toast-spin { animation-name: toast-spin; }
.toast-wobble { animation-name: toast-wobble; }
.toast-zoom { animation-name: toast-zoom; }
.toast-flip { animation-name: toast-flip; }

@keyframes toast-spin {
  0% { transform: translate(-50%, -50%) rotate(720deg) scale(0); opacity: 0; }
  70% { transform: translate(-50%, -50%) rotate(-20deg) scale(1.25); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); opacity: 1; }
}

@keyframes toast-wobble {
  0% { transform: translate(-50%, -50%) rotate(30deg) scale(0.2); opacity: 0; }
  50% { transform: translate(-50%, -50%) rotate(-12deg) scale(1.3); opacity: 1; }
  75% { transform: translate(-50%, -50%) rotate(8deg) scale(0.92); }
  100% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); opacity: 1; }
}

@keyframes toast-zoom {
  0% { transform: translate(-50%, -50%) scale(5) rotate(var(--tilt, 0deg)); opacity: 0; }
  55% { transform: translate(-50%, -50%) scale(0.75) rotate(var(--tilt, 0deg)); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(var(--tilt, 0deg)); opacity: 1; }
}

@keyframes toast-flip {
  0% { transform: translate(-50%, -50%) perspective(600px) rotateY(90deg) scale(1.4); opacity: 0; }
  100% { transform: translate(-50%, -50%) perspective(600px) rotateY(0) rotate(var(--tilt, 0deg)); opacity: 1; }
}

@keyframes toast-out {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(40deg) scale(2.2); }
}

.shake { animation: shake 0.4s; }
.shake-hard { animation: shake-hard 0.6s; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 3px); }
  50% { transform: translate(3px, -3px); }
  75% { transform: translate(-3px, -2px); }
}

@keyframes shake-hard {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-10px, 6px) rotate(-1deg); }
  40% { transform: translate(9px, -8px) rotate(1.5deg); }
  60% { transform: translate(-8px, -6px) rotate(-1deg); }
  80% { transform: translate(7px, 7px) rotate(1deg); }
}
