:root {
  --bg: #ffffff;
  --fg: #191919;
  --accent: #ff5f8f;
  --card: rgba(255, 255, 255, 0.82);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Comic Sans MS", sans-serif;
  color: var(--fg);
  background: var(--bg);
  overflow-x: hidden;
  transition: background 500ms ease, color 500ms ease;
}

body.chaos-mode {
  background: linear-gradient(120deg, #ffd9e6, #ffeec2, #d9f0ff, #ffd9e6);
  background-size: 300% 300%;
  animation: gradientShift 8s ease infinite;
}

body.chaos-wild {
  background: linear-gradient(120deg, #ff7eb3, #ff758c, #ff9a44, #ffd66b, #7ad7f0);
  background-size: 240% 240%;
  animation: gradientShift 4s linear infinite;
}

body.chaos-cosmic {
  background: radial-gradient(circle at 20% 20%, #ffe28d, transparent 28%),
    radial-gradient(circle at 80% 20%, #89f7fe, transparent 32%),
    radial-gradient(circle at 50% 80%, #fca5f1, transparent 30%),
    #0e0e1f;
  color: #fefefe;
}

.app {
  width: min(900px, 92vw);
  margin: 5vh auto;
  text-align: center;
  position: relative;
  z-index: 3;
}

.card {
  background: var(--card);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 36px);
  box-shadow: 0 18px 45px rgba(20, 10, 40, 0.12);
  backdrop-filter: blur(8px);
}

.minimal .card {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.1;
}

p {
  font-size: clamp(1rem, 2.3vw, 1.35rem);
  line-height: 1.5;
}

.btn-row {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 64px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-weight: 700;
  font-size: 1rem;
  background: #131313;
  color: white;
  cursor: pointer;
  transition: transform 180ms ease, background 250ms ease, opacity 250ms ease;
}

button:hover {
  transform: scale(1.06);
}

button.secondary {
  background: #ff6ea8;
}

button.tiny {
  font-size: 0.8rem;
  padding: 7px 13px;
}

button.nope {
  position: relative;
  min-width: 130px;
  padding: 12px 22px;
}

#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.float-heart,
.confetti,
.floating-text,
.cursor-trail {
  position: fixed;
  pointer-events: none;
  will-change: transform, opacity;
}

.float-heart {
  font-size: 22px;
  animation: flyUp 1700ms ease-out forwards;
}

.confetti {
  width: 10px;
  height: 10px;
  animation: confettiDrop 1350ms ease-in forwards;
}

.floating-text {
  font-weight: 900;
  font-size: 1rem;
  color: #d81257;
  text-shadow: 0 2px 0 #fff;
  animation: floatText 1200ms ease-out forwards;
}

.cursor-trail {
  color: #ff3f88;
  animation: trailFade 850ms ease-out forwards;
}

.timeline {
  text-align: left;
  margin: 24px auto;
  max-width: 620px;
}

.timeline-item {
  opacity: 0;
  transform: translateY(10px);
  margin: 10px 0;
  padding: 10px 14px;
  border-left: 4px solid #ff6ea8;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
}

.timeline-item.show {
  opacity: 1;
  transform: translateY(0);
  transition: 420ms ease;
}

.playground {
  margin-top: 18px;
  border: 2px dashed rgba(0, 0, 0, 0.22);
  border-radius: 20px;
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(255, 255, 255, 0.25);
}

.counter {
  font-size: 0.95rem;
  margin-top: 12px;
  opacity: 0.9;
}

.shake {
  animation: shake 450ms linear;
}

.final {
  animation: softPop 700ms ease both;
}

@keyframes flyUp {
  from {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.8) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -180px) scale(1.5) rotate(20deg);
  }
}

@keyframes confettiDrop {
  from {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(620deg);
  }
}

@keyframes floatText {
  from {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.8);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -65px) scale(1.2);
  }
}

@keyframes trailFade {
  from {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.2);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
}

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

@keyframes shake {
  0% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-8px, 5px);
  }
  40% {
    transform: translate(7px, -4px);
  }
  60% {
    transform: translate(-6px, -3px);
  }
  80% {
    transform: translate(5px, 6px);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes softPop {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .app {
    margin-top: 2vh;
  }

  .playground {
    min-height: 190px;
  }
}

.memory-garden {
  margin-top: 16px;
  position: relative;
  min-height: 320px;
  border: 2px dashed rgba(0, 0, 0, 0.2);
  border-radius: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 203, 223, 0.5), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(184, 233, 255, 0.55), transparent 36%),
    rgba(255, 255, 255, 0.45);
  overflow: hidden;
}

.memory-node {
  position: absolute;
  width: 118px;
  height: 118px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.88);
  color: #222;
  display: grid;
  place-items: center;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  animation: memoryDrift 2.8s ease-in-out infinite;
  animation-delay: var(--drift-delay);
}

.memory-node span {
  font-size: 1.55rem;
}

.memory-node small {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #5a2c43;
}

.memory-node.found {
  opacity: 0.58;
  transform: scale(0.92);
  filter: grayscale(0.25);
}

.memory-status {
  margin-top: 14px;
  font-size: 0.95rem;
  font-weight: 700;
}

.memory-log {
  margin-top: 10px;
  min-height: 72px;
  text-align: left;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  background: rgba(255, 255, 255, 0.68);
  padding: 10px 12px;
}

.memory-challenge {
  margin-top: 10px;
  border-radius: 12px;
  border: 1px dashed rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.72);
  padding: 10px 12px;
  text-align: left;
}

.memory-options {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.memory-feedback {
  margin-top: 8px;
  font-size: 0.92rem;
  font-weight: 700;
}

.arcade-ruleline {
  font-size: 0.96rem;
  opacity: 0.88;
}

.wordle-hint {
  margin-top: 10px;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
}

.wordle-board {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  justify-content: center;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, 54px);
  gap: 8px;
}

.wordle-cell {
  height: 54px;
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.35rem;
  background: rgba(255, 255, 255, 0.75);
}

.wordle-cell.state-exact {
  background: #4caf50;
  color: #fff;
  border-color: #3f9a44;
}

.wordle-cell.state-present {
  background: #d9aa2e;
  color: #fff;
  border-color: #c29624;
}

.wordle-cell.state-miss {
  background: #6f7480;
  color: #fff;
  border-color: #656a75;
}

.wordle-keyboard {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.wordle-key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.wordle-key {
  min-width: 32px;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 0.82rem;
  background: #1f1f1f;
}

.wordle-key.state-exact {
  background: #4caf50;
}

.wordle-key.state-present {
  background: #d9aa2e;
}

.wordle-key.state-miss {
  background: #6f7480;
}

.wordle-input-row {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wordle-input {
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  padding: 10px 14px;
  min-width: 220px;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.12em;
  font-weight: 800;
  font-size: 0.95rem;
}

.wordle-status {
  margin-top: 10px;
  min-height: 26px;
  font-weight: 700;
}

.arcade-hud {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  font-weight: 800;
}

.arcade-hud > div {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 8px 10px;
}

.arcade-meter {
  margin-top: 10px;
  border-radius: 999px;
  height: 12px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.arcade-meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ff4f9a, #ffbf55, #59b2ff);
  transition: width 220ms ease;
}

.chaos-arena {
  margin-top: 14px;
  min-height: 330px;
  border-radius: 20px;
  border: 2px dashed rgba(0, 0, 0, 0.22);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 230, 190, 0.5), transparent 35%),
    radial-gradient(circle at 80% 80%, rgba(255, 210, 242, 0.5), transparent 36%),
    rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.arena-tip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  opacity: 0.7;
}

.chaos-target {
  position: absolute;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  transition: transform 120ms ease;
  z-index: 3;
}

.chaos-target:hover {
  transform: scale(1.08);
}

.chaos-target.heart {
  background: #ffe6f1;
}

.chaos-target.bomb {
  background: #ffe2d9;
  box-shadow: 0 10px 28px rgba(170, 30, 30, 0.28);
}

@keyframes memoryDrift {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
  100% {
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .memory-garden {
    min-height: 420px;
  }

  .memory-node {
    width: 100px;
    height: 100px;
  }

  .chaos-arena {
    min-height: 280px;
  }

  .arcade-hud {
    grid-template-columns: 1fr;
  }

  .memory-options {
    flex-direction: column;
  }

  .wordle-row {
    grid-template-columns: repeat(5, 46px);
    gap: 6px;
  }

  .wordle-cell {
    height: 46px;
    font-size: 1.1rem;
  }

  .wordle-key {
    min-width: 28px;
    padding: 7px 5px;
    font-size: 0.75rem;
  }
}
