* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive, sans-serif;
  color: #2b1a00;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* the whole point: a stupidly, disproportionately stretched background */
.bg-stretch {
  position: fixed;
  inset: -10%;
  background-image: url("81GUrcrBQAL.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%; /* ignore aspect ratio on purpose, it's funnier */
  transform: scaleX(1.6) scaleY(1.15);
  transform-origin: center;
  z-index: -2;
  filter: saturate(1.3);
  animation: breathe 9s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scaleX(1.6) scaleY(1.15) skewY(0deg); filter: saturate(1.3) hue-rotate(0deg); }
  33% { transform: scaleX(1.75) scaleY(1.05) skewY(1deg); filter: saturate(1.6) hue-rotate(8deg); }
  66% { transform: scaleX(1.5) scaleY(1.25) skewY(-1deg); filter: saturate(1.1) hue-rotate(-8deg); }
}

.eye-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.float-eye {
  position: absolute;
  font-size: 34px;
  opacity: 0.55;
  filter: drop-shadow(0 0 6px rgba(0,0,0,0.6));
  animation: drift 14s linear infinite;
}
.float-eye:nth-child(1) { top: 8%;  left: 4%;  animation-duration: 11s; animation-delay: 0s; }
.float-eye:nth-child(2) { top: 20%; left: 85%; animation-duration: 16s; animation-delay: 1s; }
.float-eye:nth-child(3) { top: 60%; left: 10%; animation-duration: 13s; animation-delay: 2s; }
.float-eye:nth-child(4) { top: 75%; left: 80%; animation-duration: 18s; animation-delay: 0.5s; }
.float-eye:nth-child(5) { top: 45%; left: 50%; animation-duration: 10s; animation-delay: 3s; }
.float-eye:nth-child(6) { top: 88%; left: 45%; animation-duration: 15s; animation-delay: 1.5s; }

@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
  25%  { transform: translate(30px, -20px) rotate(15deg) scale(1.1); }
  50%  { transform: translate(-15px, 25px) rotate(-10deg) scale(0.9); }
  75%  { transform: translate(20px, 10px) rotate(8deg) scale(1.05); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

.bg-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.05), rgba(0,0,0,0.35) 90%);
  z-index: -1;
}

main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  text-align: center;
}

.wobble-title {
  font-size: clamp(28px, 6vw, 52px);
  color: #fff;
  -webkit-text-stroke: 2px #ff2e93;
  text-shadow:
    3px 3px 0 #ff2e93,
    -2px -2px 0 #2e6bff,
    0 0 18px rgba(0,0,0,0.5);
  display: inline-block;
  transform: rotate(-2deg);
  animation: wobble 3.2s ease-in-out infinite, glitch 6.5s steps(1) infinite;
  outline: none;
  cursor: text;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-2deg) scale(1); }
  50% { transform: rotate(2deg) scale(1.03); }
}

@keyframes glitch {
  0%, 92%, 100% {
    text-shadow: 3px 3px 0 #ff2e93, -2px -2px 0 #2e6bff, 0 0 18px rgba(0,0,0,0.5);
  }
  93% {
    text-shadow: -6px 2px 0 #ff2e93, 6px -2px 0 #2e6bff, 0 0 18px rgba(0,0,0,0.5);
  }
  95% {
    text-shadow: 6px -3px 0 #7CFC93, -6px 3px 0 #2e6bff, 0 0 18px rgba(0,0,0,0.5);
  }
  97% {
    text-shadow: -3px -3px 0 #ff2e93, 3px 3px 0 #ffe08a, 0 0 18px rgba(0,0,0,0.5);
  }
}

.sanity-meter {
  max-width: 480px;
  margin: 18px auto 8px;
}

.sanity-label {
  color: #fff;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 1px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
  margin-bottom: 4px;
}

.sanity-track {
  height: 16px;
  border: 3px solid #2b1a00;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  overflow: hidden;
}

.sanity-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7CFC93, #fff59d, #ff8a8a);
  transition: width 0.4s ease;
}

.subtitle {
  color: #fff;
  font-size: clamp(14px, 2.4vw, 20px);
  text-shadow: 1px 1px 4px rgba(0,0,0,0.6);
  margin-top: 4px;
  outline: none;
}

.toolbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 22px 0;
}

.tool-btn {
  font-family: inherit;
  font-weight: bold;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 3px dashed #2b1a00;
  background: #fff59d;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.35);
  transform: rotate(-1deg);
  transition: transform 0.15s ease;
}
.tool-btn:nth-child(2) { transform: rotate(1deg); background: #ffb3c6; }
.tool-btn:nth-child(3) { transform: rotate(-1.5deg); background: #b3e5ff; }
.tool-btn:hover { transform: scale(1.08) rotate(0deg); }
.tool-btn:active { transform: scale(0.95); }

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.card {
  position: relative;
  background: #fff;
  border: 4px solid #2b1a00;
  border-radius: 22px;
  padding: 20px 16px 24px;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.4);
  transform: rotate(var(--tilt, -1.5deg));
  transition: transform 0.15s ease;
}
.card:hover { transform: rotate(0deg) scale(1.02); }

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.4;
}
.remove-btn:hover { opacity: 1; }

.badge {
  font-size: 13px;
  font-weight: bold;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  background: #eee;
}

.name {
  font-size: 22px;
  margin: 4px 0 6px;
  outline: none;
  cursor: text;
  border-bottom: 2px dotted transparent;
}
.name:hover { border-bottom-color: #999; }

.count {
  font-size: 56px;
  font-weight: bold;
  line-height: 1;
  margin: 6px 0 14px;
  color: #ff2e93;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  cursor: default;
  user-select: none;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.plus-btn, .minus-btn {
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 12px;
  border: 3px solid #2b1a00;
}

.plus-btn {
  background: #7CFC93;
  padding: 12px 14px;
  font-size: 15px;
  width: 100%;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.35);
}
.plus-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0,0,0,0.35); }

.minus-btn {
  background: #ffe08a;
  padding: 4px 10px;
  font-size: 13px;
  align-self: flex-end;
}

.log-title {
  color: #fff;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.7);
  margin-top: 34px;
  font-size: 20px;
}

.log {
  list-style: none;
  padding: 0;
  margin: 10px auto 0;
  max-width: 560px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(255,255,255,0.85);
  border: 3px solid #2b1a00;
  border-radius: 14px;
}

.log li {
  padding: 8px 14px;
  border-bottom: 1px dashed #ccc;
  text-align: left;
  font-size: 14px;
}
.log li:last-child { border-bottom: none; }

footer {
  margin-top: 40px;
  color: #fff;
  font-size: 12px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

.shake {
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-6px, 4px) rotate(-1deg); }
  40% { transform: translate(6px, -4px) rotate(1deg); }
  60% { transform: translate(-5px, -3px) rotate(-1deg); }
  80% { transform: translate(5px, 3px) rotate(1deg); }
}

/* floating emoji burst */
.burst {
  position: fixed;
  font-size: 28px;
  pointer-events: none;
  z-index: 50;
  animation: rise 1s ease-out forwards;
}
@keyframes rise {
  0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-120px) scale(1.6) rotate(30deg); opacity: 0; }
}
