:root {
  --bg1: #fff4e6;
  --bg2: #ffe9f2;
  --bg3: #e6f7ff;
  --ink: #2b2b2b;
  --muted: #6a6a6a;
  --accent: #ff7a00;
  --accent-2: #00a3ff;
  --ok: #34c759;
  --bad: #ff3b30;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: "Play", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: radial-gradient(1200px 800px at 20% 10%, var(--bg3), transparent),
    radial-gradient(900px 700px at 80% 20%, var(--bg2), transparent),
    radial-gradient(1200px 800px at 50% 90%, var(--bg1), transparent);
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

#loading-screen {
  justify-content: center;
  align-items: center;
}

.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: clamp(24px, 4vw, 40px);
}

.loading-word {
  display: flex;
  gap: clamp(4px, 1vw, 10px);
  font-size: clamp(34px, 9vw, 86px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
}

.loading-word span {
  display: inline-block;
  animation: loading-bounce 0.85s ease-in-out infinite;
}

.loading-word span:nth-child(2) {
  animation-delay: 0.08s;
}

.loading-word span:nth-child(3) {
  animation-delay: 0.16s;
}

.loading-word span:nth-child(4) {
  animation-delay: 0.24s;
}

.loading-word span:nth-child(5) {
  animation-delay: 0.32s;
}

.loading-word span:nth-child(6) {
  animation-delay: 0.4s;
}

.loading-word span:nth-child(7) {
  animation-delay: 0.48s;
}

.loading-word span:nth-child(8) {
  animation-delay: 0.56s;
}

@keyframes loading-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(-16px) scale(1.04);
  }
  60% {
    transform: translateY(4px) scale(0.98);
  }
}

.start-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2vw, 16px);
}

.logo {
  width: min(720px, 94vw);
  height: auto;
  display: block;
}

.start-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: clamp(16px, 3vw, 22px);
}

.start-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: min(720px, 94vw);
}

button {
  font-family: inherit;
  border: none;
  padding: 26px 28px;
  border-radius: 18px;
  font-size: clamp(26px, 5.2vw, 36px);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  text-transform: uppercase;
  color: #ffffff;
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), #ffb300);
  color: white;
  box-shadow: 0 12px 24px rgba(255, 122, 0, 0.3);
}

button.secondary {
  background: linear-gradient(135deg, var(--accent-2), #73e0ff);
  box-shadow: 0 12px 24px rgba(0, 163, 255, 0.25);
}

.top-bar button {
  width: 100%;
  border-radius: 0;
  padding: clamp(18px, 3.6vw, 26px);
}

button.ghost {
  background: #ffffffcc;
  color: var(--ink);
  border: 1px solid #e6e6e6;
}

#game-screen {
  flex-direction: column;
  gap: clamp(12px, 2.5vw, 20px);
  padding: clamp(16px, 3vw, 28px);
  padding-bottom: calc(clamp(90px, 14vw, 140px) + env(safe-area-inset-bottom));
}

.top-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: #ffffff;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
}

.prompt {
  background: transparent;
  border-radius: 0;
  padding: clamp(8px, 2vw, 14px) 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

#prompt-text {
  font-size: clamp(20px, 6vw, 54px);
  font-weight: 600;
}

#repeat-prompt img {
  width: clamp(32px, 5.5vw, 44px);
  height: clamp(32px, 5.5vw, 44px);
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.grid {
  width: min(980px, 94vw);
  height: min(720px, 68vh);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: clamp(12px, 2.5vw, 24px);
}

.card {
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: grid;
  padding: 0px;
  place-items: center;
  position: relative;
  overflow: hidden;
  border: 6px solid transparent;
  transition: border-color 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card img.mirrored {
  transform: scaleX(-1);
}

.card.correct {
  border-color: var(--ok);
}

.card.wrong {
  border-color: var(--bad);
  opacity: 0.45;
}

.card.disabled {
  pointer-events: none;
}

.grid.locked {
  pointer-events: none;
}

.card:hover {
  transform: translateY(-2px);
}

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.prompt,
.grid {
  position: relative;
  z-index: 1;
}

.top-bar {
  z-index: 4;
}
@media (max-width: 700px) {
  .grid {
    height: 62vh;
  }
  .top-bar {
    gap: 10px;
  }
}
