:root {
  --bg-top: #163828;
  --bg-mid: #0f291e;
  --bg-bottom: #081710;
  --accent: #ffd452;
  --box-border: #9d6b3b;
  --panel-bg: rgba(18, 22, 28, 0.78);
  --text: #f8fafc;
  --muted: #cbd5e1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 52%, var(--bg-bottom) 100%);
}

.hidden {
  display: none !important;
}

.screen {
  width: 100%;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* Main Menu */
#menuScreen {
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  text-align: center;
  gap: 20px;
}

.logo-badge {
  width: 112px;
  height: 112px;
  border-radius: 28px;
  border: 3px solid var(--accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.logo-badge img {
  width: 100%;
  height: 100%;
  display: block;
}

.game-title {
  font-size: 2.35rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.game-subtitle {
  color: var(--muted);
  font-size: 0.96rem;
  margin-top: -12px;
}

.best-pill {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
}

.best-pill span {
  color: var(--accent);
  margin-left: 6px;
}

.menu-actions {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

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

.btn-primary {
  background: linear-gradient(180deg, #ffe066 0%, #f59f00 100%);
  color: #1b1200;
  box-shadow: 0 6px 18px rgba(245, 159, 0, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Gameplay Screen - Spacious Playfield */
#gameScreen {
  padding: 8px 10px 10px;
  gap: 6px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.score-box {
  background: var(--panel-bg);
  border: 2px solid var(--box-border);
  border-radius: 14px;
  padding: 6px 14px;
  min-width: 132px;
}

.score-main {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1.15;
}

.score-best {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.next-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 4px 10px;
}

.next-box span {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.hud-controls {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Large, spacious canvas wrapper */
#stageWrapper {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  border: 4px solid var(--box-border);
  border-radius: 18px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  touch-action: none;
  display: block;
}

.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  max-height: 85dvh;
  overflow-y: auto;
  background: #141a24;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.modal-card h2 {
  font-size: 1.45rem;
  color: var(--accent);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
}

.theme-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.theme-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.theme-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

.theme-info strong {
  display: block;
  font-size: 0.98rem;
}

.theme-info span {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.78);
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pet-card {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pet-card canvas {
  width: 58px;
  height: 58px;
}

.pet-card-label {
  text-align: center;
  line-height: 1.15;
}

.pet-card-label strong {
  display: block;
  font-size: 0.8rem;
  color: var(--accent);
}

.pet-card-label span {
  font-size: 0.62rem;
  color: var(--muted);
}
