@import url('https://fonts.googleapis.com/css2?family=Londrina+Shadow&display=swap');

:root {
  --bg: #07080f;
  --bg2: #111423;
  --neon-cyan: #00e7ff;
  --neon-orange: #ff7e39;
  --neon-pink: #ff3fd2;
  --text: #eef6ff;
  --muted: #9fb4d6;
  --panel: rgba(10, 16, 33, 0.78);
  --line: rgba(129, 158, 207, 0.3);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(0, 231, 255, 0.28), transparent 36%),
    radial-gradient(circle at 80% 15%, rgba(255, 63, 210, 0.26), transparent 34%),
    radial-gradient(circle at 50% 100%, rgba(255, 126, 57, 0.26), transparent 45%),
    linear-gradient(155deg, var(--bg), var(--bg2));
  overflow-x: hidden;
}

.page-glow,
.page-grid,
.page-noodles,
.page-beams {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
}

.page-glow {
  background:
    radial-gradient(circle at 30% 45%, rgba(0, 231, 255, 0.25), transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(255, 126, 57, 0.23), transparent 30%);
  animation: pulse 6s ease-in-out infinite alternate;
}

.page-grid {
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 90%);
}

.page-noodles {
  z-index: -1;
  background:
    radial-gradient(circle at 8% 85%, rgba(255, 126, 57, 0.45), transparent 40%),
    radial-gradient(circle at 90% 22%, rgba(0, 231, 255, 0.42), transparent 42%),
    conic-gradient(
      from 90deg at 30% 65%,
      transparent 0 12%,
      rgba(255, 63, 210, 0.36) 15% 20%,
      transparent 23% 33%,
      rgba(0, 231, 255, 0.28) 36% 42%,
      transparent 45% 100%
    );
  mix-blend-mode: screen;
  opacity: 1;
  animation: drift 14s ease-in-out infinite alternate;
}

.page-beams {
  z-index: -1;
  background:
    linear-gradient(115deg, rgba(0, 231, 255, 0.16), transparent 35%),
    linear-gradient(210deg, rgba(255, 63, 210, 0.14), transparent 40%),
    linear-gradient(15deg, rgba(255, 126, 57, 0.15), transparent 38%);
  filter: blur(16px);
  animation: beams 10s ease-in-out infinite alternate;
}

.app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 18px 14px 32px;
  display: grid;
  gap: 14px;
}

.topbar {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 126, 57, 0.45);
  background: linear-gradient(90deg, rgba(255, 126, 57, 0.2), rgba(255, 63, 210, 0.22));
  box-shadow: 0 0 26px rgba(255, 126, 57, 0.32);
}

.brand {
  margin: 0;
  font-family: 'Londrina Shadow', 'Trebuchet MS', sans-serif;
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 0 20px rgba(0, 231, 255, 0.35),
    0 0 28px rgba(255, 63, 210, 0.3);
}

.hero {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(0, 231, 255, 0.42);
  background:
    linear-gradient(145deg, rgba(3, 16, 32, 0.88), rgba(32, 8, 36, 0.78)),
    radial-gradient(circle at 15% 15%, rgba(0, 231, 255, 0.22), transparent 40%);
  box-shadow:
    0 0 32px rgba(0, 231, 255, 0.16),
    inset 0 0 34px rgba(255, 63, 210, 0.06);
}

.eyebrow {
  margin: 0;
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 6vw, 2.45rem);
  line-height: 1.05;
  text-shadow: 0 0 26px rgba(0, 231, 255, 0.28);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.97rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  margin: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(129, 158, 207, 0.26);
  background: rgba(8, 14, 31, 0.7);
}

.stat-value {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 800;
}

.stat-label {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.ticker {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(129, 158, 207, 0.24);
  background: rgba(8, 13, 27, 0.75);
}

.ticker-track {
  display: flex;
  width: max-content;
  gap: 18px;
  padding: 9px 12px;
  animation: ticker 22s linear infinite;
}

.ticker-track span {
  color: #d8e8ff;
  font-size: 0.86rem;
}

.game-shell,
.reward-panel,
.final-cta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow:
    0 0 26px rgba(0, 0, 0, 0.3),
    inset 0 0 20px rgba(0, 231, 255, 0.05);
  padding: 14px;
  backdrop-filter: blur(10px);
}

.mode-head {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.mode-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.hud-item {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(129, 158, 207, 0.25);
  background: rgba(2, 9, 24, 0.55);
}

.hud-label {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hud-value {
  font-size: 1.14rem;
  font-weight: 700;
}

.goal {
  margin-bottom: 10px;
}

.goal-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(129, 158, 207, 0.28);
}

.goal-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-orange));
  box-shadow: 0 0 20px rgba(0, 231, 255, 0.4);
  transition: width 0.2s linear;
}

.goal-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.mode-screen {
  margin-bottom: 10px;
}

.game-stage-wrap,
.memo-stage-wrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(129, 158, 207, 0.28);
  background: linear-gradient(180deg, rgba(2, 10, 22, 0.9), rgba(7, 17, 34, 0.96));
}

.game-stage {
  position: relative;
  width: 100%;
  height: min(56vh, 360px);
  min-height: 280px;
  overflow: hidden;
  touch-action: none;
}

.game-stage::before,
.game-stage::after,
.memo-stage-wrap::before,
.memo-stage-wrap::after {
  content: "";
  position: absolute;
  width: 36%;
  height: 62%;
  filter: blur(44px);
  opacity: 0.35;
}

.game-stage::before,
.memo-stage-wrap::before {
  left: -8%;
  top: 12%;
  background: rgba(0, 231, 255, 0.42);
}

.game-stage::after,
.memo-stage-wrap::after {
  right: -10%;
  top: 25%;
  background: rgba(255, 63, 210, 0.4);
}

.bowl {
  position: absolute;
  bottom: 10px;
  left: calc(50% - 48px);
  width: 96px;
  height: 62px;
  border-radius: 8px 8px 42px 42px;
  background:
    linear-gradient(180deg, rgba(255, 223, 192, 0.96), rgba(255, 176, 123, 0.96)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), transparent 55%);
  box-shadow:
    0 7px 22px rgba(0, 0, 0, 0.42),
    0 0 22px rgba(255, 126, 57, 0.4);
}

.bowl::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: -5px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 240, 214, 0.95);
}

.bowl::after {
  content: "";
  position: absolute;
  left: 34px;
  top: -38px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.56), transparent 66%);
  animation: steam 1.8s linear infinite;
}

.item {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
  user-select: none;
}

.item.good,
.memo-card.matched {
  background: radial-gradient(circle, rgba(0, 231, 255, 0.25), rgba(0, 231, 255, 0.05));
  box-shadow: 0 0 18px rgba(0, 231, 255, 0.25);
}

.item.bad {
  background: radial-gradient(circle, rgba(255, 63, 210, 0.25), rgba(255, 63, 210, 0.05));
  box-shadow: 0 0 18px rgba(255, 63, 210, 0.25);
}

.memo-stage-wrap {
  padding: 12px;
  position: relative;
}

.memo-stage-wrap::before,
.memo-stage-wrap::after {
  pointer-events: none;
}

.memo-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 280px;
}

.memo-start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 3;
  background: radial-gradient(circle, rgba(2, 10, 22, 0.16), rgba(2, 10, 22, 0.46));
}

.memo-card {
  position: relative;
  border: 1px solid rgba(129, 158, 207, 0.45);
  background: rgba(9, 16, 34, 0.88);
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.25s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.memo-card.open {
  transform: rotateY(180deg);
  border-color: rgba(0, 231, 255, 0.6);
  box-shadow: 0 0 18px rgba(0, 231, 255, 0.25);
}

.memo-card.matched {
  transform: rotateY(180deg);
  border-color: rgba(0, 231, 255, 0.8);
}

.memo-front,
.memo-back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  backface-visibility: hidden;
  border-radius: inherit;
}

.memo-front {
  color: #d6e7ff;
}

.memo-back {
  transform: rotateY(180deg);
  background: radial-gradient(circle, rgba(0, 231, 255, 0.22), rgba(255, 63, 210, 0.14));
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.controls.hidden-start-btn #startBtn {
  display: none;
}

.hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-mini {
  padding: 8px 10px;
  font-size: 0.78rem;
  border-radius: 10px;
}

.mode-btn-active {
  color: #09111f;
  background: linear-gradient(90deg, var(--neon-cyan), #a0f5ff);
  border-color: rgba(0, 231, 255, 0.8);
  box-shadow: 0 0 16px rgba(0, 231, 255, 0.35);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  color: #09111f;
  background: linear-gradient(90deg, var(--neon-cyan), #a0f5ff);
  box-shadow: 0 0 20px rgba(0, 231, 255, 0.42);
}

.btn-secondary {
  color: var(--text);
  background: rgba(129, 158, 207, 0.16);
  border: 1px solid rgba(129, 158, 207, 0.34);
}

.btn-claim {
  display: inline-block;
  color: #fff;
  background: linear-gradient(90deg, var(--neon-orange), #ffb061);
  box-shadow: 0 0 24px rgba(255, 126, 57, 0.45);
}

.reward-panel {
  text-align: center;
}

.reward-panel h2,
.final-cta h2 {
  margin: 0;
  font-size: 1.36rem;
}

.reward-text,
.final-cta p {
  color: var(--muted);
  margin: 8px 0 14px;
  line-height: 1.42;
}

.final-cta {
  text-align: center;
}

.hidden {
  display: none;
}

.spark {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 16px var(--neon-cyan);
  pointer-events: none;
  animation: sparkFly 1.6s linear forwards;
}

@keyframes pulse {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 0.9;
  }
}

@keyframes drift {
  from {
    transform: translate3d(-2%, 0, 0) scale(1);
  }
  to {
    transform: translate3d(2%, -2%, 0) scale(1.08);
  }
}

@keyframes beams {
  from {
    opacity: 0.65;
    transform: translate3d(-1%, -1%, 0) scale(1);
  }
  to {
    opacity: 1;
    transform: translate3d(1.5%, 1%, 0) scale(1.08);
  }
}

@keyframes steam {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.78;
  }
  100% {
    transform: translateY(-22px) scale(1.5);
    opacity: 0;
  }
}

@keyframes ticker {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes sparkFly {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.85;
  }
  100% {
    transform: translate3d(var(--sparkX), var(--sparkY), 0) scale(0.1);
    opacity: 0;
  }
}

@media (min-width: 760px) {
  .app {
    padding-top: 28px;
  }

  .game-stage {
    height: 420px;
  }

  .memo-grid {
    min-height: 420px;
  }
}
