:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --ink: #1e293b;
  --paper: #fcf9ee;
  --green: #65d328;
  --green-dark: #3b9a12;
  --orange: #f97316;
  --orange-dark: #c2410c;
  --red: #ef4444;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  font-family: 'Comic Sans MS', 'Trebuchet MS', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  touch-action: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

.screen-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px calc(22px + var(--safe-bot));
  z-index: 10;
  pointer-events: none;
}

.top-bar {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 2.5px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.stats-pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: #ffffff;
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.lobby-card {
  width: 100%;
  max-width: 390px;
  background: rgba(255, 253, 245, 0.94);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 7px 0 var(--ink);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  pointer-events: auto;
  margin-bottom: auto;
  margin-top: auto;
}

.logo-wrap {
  text-align: center;
}

.logo-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: #fef08a;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 4px;
}

.game-logo {
  margin: 0;
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
  color: #3f9c14;
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  letter-spacing: 0.02em;
}

.game-logo span {
  color: #f97316;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 11.5px;
  font-weight: 800;
  color: #475569;
  letter-spacing: 0.04em;
}

.skins-section {
  background: rgba(241, 245, 249, 0.72);
  border: 2px dashed #94a3b8;
  border-radius: 14px;
  padding: 9px 10px;
}

.skins-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #334155;
  margin-bottom: 7px;
  text-align: center;
}

.skins-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.skin-btn {
  border: 2px solid var(--ink);
  background: #ffffff;
  border-radius: 12px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 900;
  color: var(--ink);
}

.skin-btn.active {
  background: #dcfce7;
  border-color: #16a34a;
  box-shadow: 0 3px 0 #16a34a;
}

.skin-btn.locked {
  opacity: 0.58;
  background: #e2e8f0;
}

.skin-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}

.skin-sub {
  font-size: 9px;
  color: #64748b;
  font-weight: 800;
}

.btn-primary-doodle,
.btn-jet-doodle,
.btn-ghost-doodle,
.btn-danger-doodle {
  width: 100%;
  border-radius: 15px;
  border: 2.5px solid var(--ink);
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 16px;
  transition: transform 0.08s;
}

.btn-primary-doodle {
  background: linear-gradient(180deg, #84e83a 0%, var(--green) 100%);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}

.btn-jet-doodle {
  background: linear-gradient(180deg, #fbbf24 0%, var(--orange) 100%);
  color: #ffffff;
  text-shadow: 0 1px 0 var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 14.5px;
  padding: 11px 14px;
}

.btn-ghost-doodle {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 14px;
  padding: 10px 14px;
}

.btn-danger-doodle {
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 14px;
  padding: 10px 14px;
}

.btn-primary-doodle:active,
.btn-jet-doodle:active,
.btn-ghost-doodle:active,
.btn-danger-doodle:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.controls-hint {
  margin: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  line-height: 1.35;
}

/* HUD */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.hud-left {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-score {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.hud-buff {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fef08a;
  border: 2px solid var(--ink);
  font-size: 11.5px;
  font-weight: 900;
}

.hud-right {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: 14px;
  pointer-events: auto;
}

.hud-hint {
  position: absolute;
  left: 50%;
  bottom: calc(82px + var(--safe-bot));
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.85);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.45s;
}

.hud-hint.faded {
  opacity: 0;
}

/* Zone / record banner (shown for ~2 s when entering a new zone or passing the best height) */
.hud-zone {
  position: absolute;
  left: 50%;
  top: calc(70px + var(--safe-top));
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.94);
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: zone-pop 0.35s ease-out;
}

@keyframes zone-pop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

.shoot-fab {
  position: absolute;
  right: 16px;
  bottom: calc(18px + var(--safe-bot));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fde047, #f97316);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 25px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shoot-fab:active {
  transform: scale(0.92);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.modal-card {
  width: 100%;
  max-width: 350px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 7px 0 var(--ink);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.modal-emoji {
  font-size: 40px;
  line-height: 1;
}

.modal-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.modal-sub {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  color: #475569;
}

.record-badge {
  background: #fef08a;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 900;
}

.summary-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.summary-cell {
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 13px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-lbl {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
}

.cell-val {
  font-size: 20px;
  font-weight: 900;
}

.skin-goal {
  width: 100%;
  font-size: 12.5px;
  font-weight: 900;
  color: var(--ink);
  background: #ffffff;
  border: 2px dashed var(--ink);
  border-radius: 12px;
  padding: 6px 10px;
}

.skin-goal:empty {
  display: none;
}

.subradar-pill {
  font-size: 11.5px;
  font-weight: 900;
  color: #065f46;
  background: #d1fae5;
  border: 2px solid #059669;
  border-radius: 999px;
  padding: 4px 12px;
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(16px + var(--safe-top));
  transform: translateX(-50%);
  background: var(--ink);
  color: #ffffff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 800;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* ==================== CHALKBOARD THEME (sprites pack, 04.12) ====================
   Dark green board instead of a light notebook. Overrides only colours above;
   remove this block to get the notebook look back. */
:root {
  --chalk: #f5f1e3;
  --board: #20322b;
  --board-card: rgba(27, 43, 37, 0.95);
  --chalk-soft: #cdd8cf;
}

html, body {
  background: var(--board);
  color: var(--chalk);
}

.lobby-card,
.modal-card {
  background: var(--board-card);
  border-color: var(--chalk);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.45);
  color: var(--chalk);
}

.game-logo {
  color: #b8f28b;
  text-shadow: 2px 2px 0 #0f1a15, -1px -1px 0 #0f1a15, 1px -1px 0 #0f1a15, -1px 1px 0 #0f1a15;
}

.game-logo span {
  color: #ffd166;
}

.logo-badge,
.hud-buff,
.record-badge {
  color: var(--ink);
}

.brand-sub,
.modal-sub,
.skin-sub,
.cell-lbl,
.controls-hint {
  color: var(--chalk-soft);
}

.skins-section {
  background: rgba(245, 241, 227, 0.06);
  border-color: rgba(245, 241, 227, 0.45);
}

.skins-title {
  color: var(--chalk);
}

.skin-btn {
  background: rgba(245, 241, 227, 0.08);
  border-color: var(--chalk);
  color: var(--chalk);
}

.skin-btn.active {
  background: rgba(184, 242, 139, 0.22);
  border-color: #b8f28b;
  box-shadow: 0 3px 0 #7fbf5a;
}

.skin-btn.locked {
  background: rgba(0, 0, 0, 0.25);
}

.summary-cell,
.skin-goal {
  background: rgba(245, 241, 227, 0.08);
  border-color: var(--chalk);
  color: var(--chalk);
}

.hud-score,
.hud-zone {
  background: rgba(27, 43, 37, 0.9);
  border-color: var(--chalk);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  color: var(--chalk);
}

.btn-ghost-doodle {
  background: rgba(245, 241, 227, 0.1);
  border-color: var(--chalk);
  color: var(--chalk);
}

.stats-pill {
  color: var(--ink);
}

/* Skin picker: chalk hero sprite instead of a colour dot (main.js applySkinArt) */
.skin-art {
  width: 34px;
  height: 34px;
  display: block;
}
