:root {
  --bg-1: #2c1b3d;
  --bg-2: #3d2450;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-border: rgba(255, 255, 255, 0.14);
  --gold: #f3a53c;
  --gold-2: #ffcf7a;
  --teal: #5f8b93;
  --teal-light: #8fb6bd;
  --obstacle: #c9b7bb;
  --obstacle-shadow: #a8969a;
  --text: #f4ecf7;
  --text-dim: #c9b9d6;
  --danger: #e0567a;
  --success: #57c98a;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, var(--bg-2), var(--bg-1) 70%);
  font-family: 'Outfit', sans-serif;
  color: var(--text);
  touch-action: none;
}

h1,
h2,
h3,
.title-font {
  font-family: 'Orbitron', sans-serif;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Preloader ---------- */
#preloader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, var(--bg-2), var(--bg-1) 75%);
  z-index: 200;
  transition: opacity .6s ease;
}

.logo-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
  margin-bottom: 28px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#preloader h1 {
  font-size: 28px;
  letter-spacing: 2px;
  margin: 0 0 6px;
  color: var(--gold-2);
  text-shadow: 0 0 18px rgba(243, 165, 60, 0.5);
}

#preloader p {
  color: var(--text-dim);
  margin: 0 0 22px;
  font-size: 14px;
  letter-spacing: 1px;
}

.bar-track {
  width: 220px;
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width .18s ease;
}

/* ---------- Screens ---------- */
.screen {
  inset: 0;
  display: none;
  justify-content: center;
  z-index: 20;
  padding: 24px;
  overflow: hidden;          /* ← was overflow: scroll; max-height: 600px; */
}

.screen-inner {
  width: 100%;
  max-width: 480px;
  height: 100%;              /* ← was height: 100vh; */
  overflow: hidden;          /* ← was overflow-y: auto; overflow-x: hidden; */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen.active {
  display: flex;
}


.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 36px;
}

.brand .knot-icon {
  width: 74px;
  height: 74px;
  margin-bottom: 14px;
  filter: drop-shadow(0 6px 16px rgba(243, 165, 60, 0.35));
}

.brand h1 {
  font-size: 34px;
  margin: 0;
  letter-spacing: 2px;
  color: var(--text);
}

.brand h1 span {
  color: var(--gold);
}

.brand p {
  color: var(--text-dim);
  margin: 8px 0 0;
  font-size: 14px;
  letter-spacing: 1px;
}

.menu-btn {
  width: 100%;
  max-width: 280px;
  padding: 16px 20px;
  margin: 8px 0;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-family: 'Outfit';
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;

  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .18),
    /* top highlight */
    inset 0 -3px 0 rgba(0, 0, 0, .35),
    /* bottom depth */
    0 4px 0 rgba(0, 0, 0, .45),
    /* hard bottom edge */
    0 8px 18px rgba(0, 0, 0, .35),
    /* outer shadow */
    0 0 12px rgba(255, 215, 120, .08);
  /* subtle glow */
}


.menu-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;

  transform: skewX(-25deg);
  transition: .6s;
}



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

.menu-btn.primary {
  background: linear-gradient(135deg, var(--gold), #e08a2b);
  color: #3a2410;
  border: none;
  box-shadow: 0 8px 22px rgba(243, 165, 60, 0.35);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .35),
    inset 0 -3px 0 rgba(125, 90, 20, .55),
    0 5px 0 #6d4b14,
    0 10px 20px rgba(0, 0, 0, .4),
    0 0 15px rgba(255, 215, 0, .18);
}

.menu-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ---------- Level select ---------- */
#levelSelectGrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 360px;
  margin: 22px 0 10px;
}

.level-tile {
  aspect-ratio: 1/1;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform .12s ease;
}

.level-tile:active {
  transform: scale(0.94);
}

.level-tile .num {
  font-family: 'Orbitron';
  font-size: 22px;
  font-weight: 700;
}

.level-tile.locked {
  opacity: 0.4;
  cursor: default;
}

.level-tile.locked .num {
  display: none;
}

.level-tile .stars {
  position: absolute;
  bottom: 6px;
  display: flex;
  gap: 2px;
}

.level-tile .stars svg {
  width: 10px;
  height: 10px;
}

.level-tile.done {
  border-color: rgba(243, 165, 60, 0.6);
  background: rgba(243, 165, 60, 0.12);
}

/* ---------- Top bar (in-game) ---------- */
#gameScreen {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

#gameScreen.active {
  display: flex;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 8px;
  flex-shrink: 0;
}

#topbar .lvl-label {
  font-family: 'Orbitron';
  font-size: 18px;
  letter-spacing: 1px;
}

#topbar .icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#topbar .icon-btn svg {
  width: 18px;
  height: 18px;
}

#topbar .left-icons,
#topbar .right-icons {
  display: flex;
  gap: 8px;
  align-items: center;
}

#canvasWrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas#game {
  display: block;
  touch-action: none;
}

#bottombar {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px 18px 26px;
  flex-shrink: 0;
}

#bottombar .pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 24px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-family: 'Outfit';
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

#bottombar .pill-btn svg {
  width: 15px;
  height: 15px;
}

#bottombar .pill-btn:active {
  transform: scale(0.95);
}

/* ---------- Overlays (pause / win / howto) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 10, 28, 0.6);
  backdrop-filter: blur(3px);
  padding: 20px;
}

.overlay.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(160deg, #fff7ea, #fbeccc);
  border-radius: 22px;
  padding: 26px 22px 22px;
  color: #4a2f18;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  position: relative;
  animation: pop .35s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal .ribbon {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--danger), #c43a63);
  color: #fff;
  padding: 10px 26px;
  border-radius: 10px;
  font-family: 'Orbitron';
  font-size: 16px;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

.modal h2 {
  font-family: 'Orbitron';
  margin: 18px 0 4px;
  font-size: 20px;
  color: #4a2f18;
}

.modal p {
  margin: 0 0 6px;
  font-size: 13px;
  color: #7a5c3d;
}

.stars-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 6px;
}

.stars-row svg {
  width: 34px;
  height: 34px;
  opacity: 0.25;
  transform: scale(0.5);
  transition: transform .3s ease, opacity .3s ease;
}

.stars-row svg.lit {
  opacity: 1;
  transform: scale(1);
  filter: drop-shadow(0 2px 6px rgba(243, 165, 60, 0.6));
}

.modal-btns {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.round-btn svg {
  width: 22px;
  height: 22px;
}

.round-btn.home {
  background: linear-gradient(135deg, #5aa7e8, #3d7fc9);
  color: #fff;
}

.round-btn.retry {
  background: linear-gradient(135deg, #63d29a, #3fae78);
  color: #fff;
}

.round-btn.next {
  background: linear-gradient(135deg, #e373c9, #c94fae);
  color: #fff;
  width: 60px;
  height: 60px;
}

.htp-card {
  width: 100%;
  max-width: 380px;
  background: rgb(31 17 42);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 24px 22px;
  backdrop-filter: blur(8px);
}

.htp-card h2 {
  margin: 0 0 14px;
  font-size: 20px;
  text-align: center;
  color: var(--gold-2);
}

.htp-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.htp-step .dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold);
  color: #3a2410;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: 'Orbitron';
  font-size: 13px;
}

.htp-step p {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.4;
}

.htp-card .menu-btn {
  margin: 18px auto 0;
}

#pauseModal .modal {
  background: linear-gradient(160deg, #3d2450, #2c1b3d);
  color: var(--text);
}

#pauseModal .modal h2 {
  color: var(--text);
}

#pauseModal .modal p {
  color: var(--text-dim);
}

#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-40px);
  background: rgba(224, 86, 122, 0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  z-index: 150;
  opacity: 0;
  transition: all .25s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.footer-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 14px;
  text-align: center;
}