:root {
  --bg-top: #fff4cc;
  --bg-bottom: #ffc0b9;
  --card: rgba(255, 255, 255, 0.78);
  --ink: #45311d;
  --shadow: rgba(128, 72, 29, 0.16);
  --stage-a: #ffe29b;
  --stage-b: #ffb26b;
  --stage-c: #ff7c8f;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Fredoka", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.55), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: -6rem;
  left: -4rem;
  background: rgba(116, 220, 199, 0.55);
}

body::after {
  right: -5rem;
  bottom: -8rem;
  background: rgba(255, 255, 255, 0.55);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100vw - 1rem));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0.45rem 0 0.6rem;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 0.65rem;
}

.hero-card,
.mode-panel,
.stage,
.keyboard-shell {
  border: 3px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 45px var(--shadow);
}

.hero-card,
.mode-panel,
.keyboard-shell {
  background: var(--card);
  backdrop-filter: blur(16px);
}

.hero-card {
  border-radius: 1.7rem;
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.hero-copy {
  min-width: 0;
}

.eyebrow,
.mode-label,
.keyboard-label {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #bd6d3e;
}

.hero-card h1 {
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: clamp(1.85rem, 3.4vw, 3.2rem);
  line-height: 0.95;
}

.subhead,
.mode-help,
.keyboard-help {
  margin: 0;
  font-size: clamp(0.92rem, 1.5vw, 1.08rem);
  line-height: 1.35;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.45rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  background: rgba(255, 247, 234, 0.96);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.05);
}

.mode-panel,
.keyboard-shell {
  border-radius: 1.7rem;
  padding: 0.75rem 0.95rem;
}

.mode-panel {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 0.8rem;
  align-items: center;
}

.mode-buttons,
.view-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.mode-button,
.view-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  color: #5b3a21;
  background: rgba(255, 247, 234, 0.92);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.05),
    0 8px 16px rgba(112, 67, 19, 0.08);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.mode-button:hover,
.mode-button:focus-visible,
.view-button:hover,
.view-button:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.mode-button.is-active,
.view-button.is-active {
  background: linear-gradient(180deg, #fff4d1, #ffd99f);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.06),
    0 12px 20px rgba(112, 67, 19, 0.12);
}

.mode-preview {
  font-size: 1.15rem;
  line-height: 1;
}

.game-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(310px, 0.82fr) minmax(0, 1.18fr);
  gap: 0.7rem;
}

.stage {
  position: relative;
  min-height: 0;
  border-radius: 2rem;
  overflow: hidden;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 244, 221, 0.74)),
    linear-gradient(135deg, var(--stage-a), var(--stage-b), var(--stage-c));
}

.stage-glow {
  position: absolute;
  inset: 8% 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.72), transparent 68%);
  animation: glowPulse 3.8s ease-in-out infinite;
}

.message,
.hint-row {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
}

#emoji-label {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: clamp(0.98rem, 1.9vw, 1.25rem);
  box-shadow: 0 10px 30px rgba(112, 67, 19, 0.1);
}

.emoji-frame {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
  padding: 0.25rem 0;
}

.emoji-display {
  font-size: clamp(6.5rem, 18vw, 15rem);
  line-height: 1;
  transform-origin: center;
  filter: drop-shadow(0 16px 12px rgba(110, 65, 20, 0.12));
  user-select: none;
}

.emoji-display.pop {
  animation: emojiPop 520ms cubic-bezier(0.2, 0.8, 0.24, 1);
}

.hint-badge {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(69, 49, 29, 0.86);
  color: #fff7eb;
}

.hint-key {
  display: inline-flex;
  min-width: 3.2rem;
  justify-content: center;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  background: #fff7eb;
  color: #8c522d;
  font-weight: 700;
}

.hint-text {
  font-size: clamp(0.92rem, 1.6vw, 1.12rem);
}

.mode-caption {
  position: relative;
  z-index: 2;
  margin: 0.45rem 0 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(69, 49, 29, 0.8);
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.float-emoji {
  position: absolute;
  font-size: clamp(1.8rem, 4vw, 3rem);
  opacity: 0;
  animation: floatUp 1.4s ease-out forwards;
}

.keyboard-shell {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.keyboard-copy {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.keyboard-panel {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0.45rem;
}

.keyboard-row {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: 0.45rem;
}

.tap-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}

.key-button {
  appearance: none;
  border: 0;
  border-radius: 1.25rem;
  min-height: 4.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.45rem 0.18rem;
  color: #4e321b;
  font-family: inherit;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(255, 231, 193, 0.98));
  box-shadow:
    inset 0 -6px 0 rgba(0, 0, 0, 0.07),
    0 10px 18px rgba(112, 67, 19, 0.1);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.key-button:hover,
.key-button:focus-visible {
  transform: translateY(-2px) scale(1.01);
  outline: none;
}

.key-button.is-active {
  transform: translateY(2px) scale(0.98);
  background: linear-gradient(180deg, #fff5db, #ffd78b);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.08),
    0 7px 16px rgba(112, 67, 19, 0.12);
}

.button-key {
  display: inline-flex;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.button-emoji {
  font-size: clamp(1.55rem, 2.2vw, 2.35rem);
  line-height: 1;
}

.button-name {
  font-size: clamp(0.55rem, 0.9vw, 0.8rem);
  font-weight: 600;
  text-align: center;
  line-height: 1.05;
}

@keyframes emojiPop {
  0% {
    transform: scale(0.4) rotate(-12deg);
  }

  60% {
    transform: scale(1.15) rotate(4deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes glowPulse {
  0%,
  100% {
    transform: scale(0.95);
    opacity: 0.72;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

@keyframes floatUp {
  0% {
    transform: translateY(1.6rem) scale(0.6) rotate(-18deg);
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  100% {
    transform: translateY(-8rem) scale(1.2) rotate(14deg);
    opacity: 0;
  }
}

@media (min-width: 821px) {
  body {
    overflow: hidden;
  }
}

@media (max-width: 980px) {
  .hero-card,
  .mode-panel {
    grid-template-columns: 1fr;
  }

  .hero-badges {
    justify-content: start;
  }
}

@media (max-width: 820px) {
  body {
    overflow-y: auto;
  }

  .app-shell {
    min-height: auto;
    grid-template-rows: auto auto auto;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 42vh;
  }

  .keyboard-copy {
    flex-direction: column;
    align-items: start;
  }

  .tap-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 0.65rem, 100%);
    padding: 0.35rem 0 0.5rem;
    gap: 0.5rem;
  }

  .hero-card,
  .mode-panel,
  .stage,
  .keyboard-shell {
    border-radius: 1.35rem;
  }

  .hero-card,
  .mode-panel,
  .keyboard-shell {
    padding: 0.7rem 0.75rem;
  }

  .hero-badge {
    font-size: 0.78rem;
    padding: 0.35rem 0.55rem;
  }

  .view-button,
  .mode-button {
    font-size: 0.88rem;
    padding: 0.45rem 0.7rem;
  }

  .stage {
    padding: 0.75rem;
    min-height: 38vh;
  }

  .emoji-display {
    font-size: clamp(5.5rem, 32vw, 8.5rem);
  }

  .tap-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .key-button {
    min-height: 4.7rem;
    padding: 0.38rem 0.1rem;
  }

  .button-name {
    display: none;
  }
}
