.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 60px);
  padding-top: 8px;
}

.screen {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------------- Menu screen ---------------- */
.screen-menu { padding-top: 8vh; }
.logo {
  font-family: 'Bungee', 'Poppins', sans-serif;
  font-size: clamp(38px, 11vw, 64px);
  line-height: 1.02;
  letter-spacing: .02em;
  text-shadow: 0 0 24px rgba(125, 211, 252, .35);
}
.logo-red {
  color: var(--brand-red);
  text-shadow: 0 0 26px rgba(239, 68, 68, .75), 0 0 60px rgba(239, 68, 68, .35);
}
.tagline {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 15px;
}

.mode-toggle {
  display: inline-flex;
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.mode-btn {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.mode-btn.active { background: var(--accent); color: #06202c; }

.btn {
  border-radius: 999px;
  padding: 16px 44px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .04em;
  background: linear-gradient(180deg, #38bdf8, #0ea5e9);
  color: #04202e;
  box-shadow: 0 10px 30px rgba(14, 165, 233, .35), inset 0 1px 0 rgba(255, 255, 255, .4);
  transition: transform .12s ease;
}
.btn:active { transform: scale(.96); }
.btn-play { margin-top: 26px; min-width: 220px; }
.btn-ghost {
  background: transparent;
  box-shadow: none;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  margin-top: 10px;
}

.best-line { margin-top: 16px; color: var(--text-dim); font-size: 14px; }
.best-line span { color: var(--text); font-weight: 700; }

.menu-links {
  display: flex;
  gap: 18px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn-link {
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 4px;
  border-bottom: 1px solid transparent;
}
.btn-link:hover { color: var(--text); border-color: var(--panel-border); }

/* ---------------- Game (HUD + board) ---------------- */
.hud {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 6px;
}
.hud-block {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 72px;
}
.hud-level { min-width: 46px; align-items: center; }
.hud-label { font-size: 10px; letter-spacing: .08em; color: var(--text-dim); }
.hud-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.icon-btn {
  margin-left: auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}

.combo-banner {
  height: 26px;
  font-family: 'Bungee', sans-serif;
  font-size: 20px;
  opacity: 0;
  transform: translateY(6px) scale(.9);
  transition: none;
  color: var(--accent);
  text-shadow: 0 0 14px currentColor;
}
.combo-banner.show {
  animation: bannerPop .9s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
.combo-banner.tier-2, .combo-banner.tier-3 { color: #fbbf24; }
.combo-banner.tier-4, .combo-banner.tier-5 { color: #f472b6; }
@keyframes bannerPop {
  0% { opacity: 0; transform: translateY(10px) scale(.7); }
  20% { opacity: 1; transform: translateY(0) scale(1.15); }
  35% { transform: translateY(0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scale(1); }
}

.combo-line {
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.combo-line.pulse { animation: comboPulse .25s ease; }
@keyframes comboPulse { 0% { transform: scale(1.12); color: var(--accent); } 100% { transform: scale(1); } }

.game-stage {
  position: relative;
  width: min(520px, calc(100vw - 24px));
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  background: linear-gradient(160deg, var(--panel), var(--bg2));
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  overflow: hidden;
  touch-action: manipulation;
}
.game-stage.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
.reduced-motion .game-stage.shake { animation: none; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.game-stage.flash-red::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(239, 68, 68, .38);
  animation: flashOut .26s ease forwards;
  pointer-events: none;
}
.reduced-motion .game-stage.flash-red::after { animation: none; opacity: 0; }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

.board {
  position: absolute;
  inset: 10px;
  display: grid;
  grid-template-columns: repeat(var(--grid, 3), 1fr);
  grid-template-rows: repeat(var(--grid, 3), 1fr);
  gap: 8px;
}
.fx-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tile {
  position: relative;
  border-radius: 14px;
  background: var(--tile-color, #3b82f6);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 6px 18px var(--tile-glow, transparent);
  min-height: 40px;
  min-width: 40px;
  -webkit-user-select: none;
  user-select: none;
  animation: tileAppear .22s cubic-bezier(.2, 1.2, .3, 1) both;
  animation-delay: var(--stagger, 0ms);
}
.reduced-motion .tile { animation: none; }
@keyframes tileAppear {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: scale(1); }
}
.tile:active { transform: scale(1.06); }

.hint-line {
  margin-top: 14px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------------- Pause overlay ---------------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(6, 9, 20, .72);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  backdrop-filter: blur(4px);
}
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 28px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-width: 240px;
}

/* ---------------- Game over screen ---------------- */
.screen-gameover { padding-top: 6vh; }
.go-title {
  font-family: 'Bungee', sans-serif;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--brand-red);
  text-shadow: 0 0 20px rgba(239, 68, 68, .5);
}
.go-badge {
  margin-top: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  color: #3a2600;
  font-weight: 700;
  font-size: 13px;
  animation: badgePop .5s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes badgePop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.go-stats {
  display: flex;
  gap: 14px;
  margin-top: 20px;
}
.go-stats > div {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 18px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 92px;
}
.stat-label { font-size: 10px; letter-spacing: .08em; color: var(--text-dim); }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.go-encourage {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 13px;
  min-height: 18px;
  max-width: 360px;
}

.nickname-form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}
.nickname-form label { font-size: 12px; color: var(--text-dim); }
.nickname-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--bg2);
  color: var(--text);
  text-align: center;
}
.nickname-status { font-size: 12px; color: var(--accent); min-height: 16px; }

.go-actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
