:root {
  --yellow: #FFD600;
  --purple: #7B2FBE;
  --green: #06D6A0;
  --ink: #1A1A2A;
  --paper: #FAF7F0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--paper);
  background-image: radial-gradient(circle, rgba(26, 26, 42, 0.28) 1.5px, transparent 1.6px);
  background-size: 24px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  position: relative;
  width: min(480px, 100vw);
  height: min(720px, 100vh);
  height: min(720px, 100dvh);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 8px 8px 0 var(--ink);
  background: var(--paper);
  touch-action: none;
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  background: rgba(250, 247, 240, 0.72);
  pointer-events: auto;
  border-radius: 18px;
  text-align: center;
  padding: 24px;
}

.hidden {
  display: none !important;
}

/* Comic title */
.comic-title {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  font-size: clamp(38px, 11vw, 58px);
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--ink), 7px 7px 0 rgba(26, 26, 42, 0.18);
  transform: rotate(-2deg);
  letter-spacing: 2px;
  line-height: 1.1;
}

.comic-title.small {
  font-size: clamp(30px, 8vw, 42px);
}

/* Badge pill */
.badge-pill {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1.5px;
  background: var(--purple);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 7px 18px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-1deg);
}

.subtitle {
  color: #555;
  font-size: 17px;
  font-weight: 600;
}

.controls-hint {
  color: #999;
  font-size: 13px;
  line-height: 1.6;
  font-weight: 600;
}

/* Comic button */
.comic-btn {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  font-size: 21px;
  padding: 14px 46px;
  color: var(--ink);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  letter-spacing: 1px;
}

.comic-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 3px 3px 0 var(--ink);
}

.comic-btn:active {
  transform: translate(5px, 5px);
  box-shadow: 0 0 0 var(--ink);
}

/* Score pill */
.score-pill {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 22px;
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 19px;
  color: var(--ink);
  min-width: 90px;
}

#menu-high-score {
  font-size: 15px;
  color: #888;
  font-weight: 700;
  min-height: 20px;
}

/* Card (game over / pause) */
.card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 34px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: rotate(-1deg);
}

#final-score, #high-score {
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

#high-score {
  color: #999;
  font-size: 17px;
}

#new-best {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  background: var(--green);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 15px;
  box-shadow: 3px 3px 0 var(--ink);
  animation: pulse 0.7s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.icon-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}
