:root {
  --bg: #e9f5ef;
  --hud: #000;
  --hudShadow: #fff;
  --btn: #f8a3c5;
  --btnText: #2b2b2b;
  --areaBg: #ffdca8;
  /* playfield yellow */
  --wall: #e98a3a;
  /* orange walls */
  --limit: #ff4d5a;
  /* red dashed line */
  --queueBg: #ff9ac4;
  /* pink bar */
  --game-margin: 24px;
  /* configurable margin around the playfield */
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: system-ui, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at 8px 8px, rgba(255, 255, 255, .5) 2px, transparent 2px) 0 0/24px 24px,
    var(--bg);
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
  background: transparent;
  /* the canvas is transparent; we render everything via JS */
}

/* Avenir Next World font faces (from liquid-sort) */
@font-face {
  font-family: 'AvenirNextWorld-Medium';
  src: url('https://firebasestorage.googleapis.com/v0/b/sticky-20bca.appspot.com/o/fonts%2FAvenirNextWorld-Medium.otf?alt=media&token=6d0c0700-529c-45a3-bfd7-dc79b07030cd') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AvenirNextWorld-Bold';
  src: url('https://firebasestorage.googleapis.com/v0/b/sticky-20bca.appspot.com/o/fonts%2FAvenirNextWorld-Bold.otf?alt=media&token=8d06a955-d494-4533-b00f-f419be3a1781') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* HUD */
#hud {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  top: 0;
  display: block;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 0 0 0;
  /* top padding only */
  min-height: calc(38px + calc(8px + env(safe-area-inset-top, 0px)));
  /* height to accommodate button/score */
  pointer-events: none;
  /* clicks pass through to the canvas */
}

#hud .hud-left,
#hud .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.score-wrap {
  position: absolute;
  /* centered relative to the HUD */
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
  line-height: 100%;
}

.score-outline,
.score-fill {
  font-family: 'AvenirNextWorld-Bold', Arial, sans-serif;
  font-weight: 950;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.score-outline {
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke-width: 4px;
  -webkit-text-stroke-color: #000;
}

.score-fill {
  position: relative;
  display: inline-block;
  color: #E0EAF1;
  text-shadow: none;
}

.score-fill .score-num {
  color: #F891B2;
}

.hud-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btnText);
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}

.hud-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}

/* Back button (SVG) overrides and fixed placement */
#btn-back {
  left: calc(12px + env(safe-area-inset-left, 0px));
  top: 0;
  /* aligned with the usable area after HUD top padding */
  width: 61px;
  height: 38px;
  padding: 0;
  margin: 0;
  background: none;
  background-color: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
  /* clickable */
}

#btn-back svg {
  display: block;
  /* removes inline-gap */
  width: 61px;
  height: 38px;
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  z-index: 1000;
}

.screen.hidden {
  display: none;
}

.panel {
  background: rgba(255, 255, 255, .9);
  padding: 24px 28px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.title,
.subtitle {
  margin: 0;
  line-height: 100%;
}

.title {
  font-size: 42px;
}

.subtitle {
  font-size: 54px;
  margin-top: 6px;
}

.title-outline {
  position: absolute;
  color: transparent;
  -webkit-text-stroke: 6px #000;
  font-weight: 950;
}

.title-fill {
  position: relative;
  display: inline-block;
  color: #ff69b4;
  text-shadow: 0 4px 0 #000;
  font-weight: 950;
}

.sticky-btn {
  margin-top: 16px;
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  background: #22d3ee;
  color: #083344;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 0 #000;
}

.sticky-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #000;
}

/* Loading */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0);
  z-index: 2000;
}

.loading-screen.hidden {
  display: none;
}

.loading-content {
  width: min(70vw, 420px);
}

.loading-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, .5);
  border-radius: 12px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  width: 0%;
  background: #22d3ee;
}

.loading-text {
  color: #fff;
  text-align: center;
  margin-top: 8px;
  font-weight: 800;
  text-shadow: 0 2px 0 #000;
}

/* ========== Start Screen (custom) ========== */
#start-screen.screen {
  /* remove dark overlay to match screenshot */
  background: transparent;
}
#gameover-screen.screen {
  /* same visual as start screen */
  background: transparent;
}

.start-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* STICKY title (white) */
.start-title {
  position: relative;
  display: inline-block;
  margin: 8px 0 0;
  line-height: 1;
  font-family: 'AvenirNextWorld-Bold', Arial, sans-serif;
  font-weight: 950;
  letter-spacing: 1px;
  font-size: clamp(20px, 3.6vh, 32px);
}

.start-title .title-outline {
  -webkit-text-stroke: 4px #000;
}

.start-title .title-fill {
  color: #ffffff;
  text-shadow: 0 3px 0 #000;
}

/* Banner with gameplay visual: top/bottom walls + patterned middle */
.start-banner {
  width: 100%;
}

.start-banner .start-wall {
  height: 14px;
  background: var(--wall);
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
}

.start-banner .start-wall.top {
  border-top-width: 2px;
}

.start-banner .start-wall.bottom {
  border-bottom-width: 2px;
}

.start-banner .start-banner-mid {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(64px, 18vh, 140px);
  /* same pattern used by gameplay area */
  background:
    url('https://firebasestorage.googleapis.com/v0/b/sticky-20bca.appspot.com/o/sgm-asset%2Fe6e5ed69-b1bd-4152-8950-5cc6b7cfc4fd%2Fde8e100d-adc6-41ac-b551-266357c24272.png?alt=media&token=9b5758fb-37c7-4a92-a2ea-ad282655c24272') 0 0 / auto auto repeat,
    var(--areaBg);
}

.start-banner .start-banner-mid::before,
.start-banner .start-banner-mid::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #000;
}

.start-banner .start-banner-mid::before {
  top: 0;
}

.start-banner .start-banner-mid::after {
  bottom: 0;
}

/* MERGE text (pink) inside banner */
.start-merge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-block;
  line-height: 1;
  font-weight: 950;
  letter-spacing: 1px;
  font-size: clamp(44px, 9.5vh, 96px);
}

.start-merge .title-outline {
  -webkit-text-stroke: 6px #000;
}

.start-merge .title-fill {
  color: #F891B2;
  text-shadow: 0 4px 0 #000;
}

/* Play button (pink pill) */
.play-btn {
  margin-top: 18px;
  appearance: none;
  border-radius: 50px;
  border: 3px solid #192A27;
  padding: 12px 28px;
  background: #F891B2;
  color: #fff;
  font-family: 'AvenirNextWorld-Bold', Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(16px, 2.6vh, 22px);
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.25), 5px 0 0 0 rgba(255, 255, 255, 0.55) inset, 0 -6px 0 0 rgba(0, 0, 0, 0.33) inset, 0 5px 0 0 rgba(255, 255, 255, 0.55) inset, -4px 0 0 0 rgba(255, 255, 255, 0.55) inset;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
}

/* PLAY label uses same visual as STICKY */
.play-btn .title-outline {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: transparent;
  -webkit-text-stroke: 4px #000;
  font-weight: 950;
  pointer-events: none;
  white-space: nowrap;
  display: inline-block;
}
.play-btn .title-fill {
  position: relative;
  color: #ffffff;
  text-shadow: 0 3px 0 #000;
  font-weight: 950;
  pointer-events: none;
  white-space: nowrap;
  display: inline-block;
}

.play-btn:active {
  transform: translateY(1px);
}
