@import url('https://fonts.googleapis.com/css2?family=Bungee&display=swap');

/* ======= FULLSCREEN SCALE ROOT ======= */
/* base handled inline in index.html to guarantee load order */

/* === Force ALL game buttons to use white text === */
.start-btn,
.editor-btn,
.created-btn,
.back-btn,
.delete-all-btn,
.grid-small-btn,
.grid-medium-btn,
.grid-large-btn,
.save-map-btn,
.clear-map-btn,
.level-btn,
.control-btn {
  color: white !important;
}

/* ========= Mobile-proof centering shell ========= */
/* handled in index.html */

/* The logical stage container should fill the scaled box exactly */
.main-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  box-sizing: border-box;

  margin: 0 !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
}

/* Any fixed-size stage child must include its own border in the set size */
.start-screen,
.editor-screen,
.levels-wrapper,
.score-wrapper {
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ======= MOBILE CONTROLS: pinned bottom, no drift ======= */
.mobile-controls {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 0 20px;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  z-index: 3000;
  pointer-events: none;
}

.mobile-controls .nav-buttons {
  display: flex;
  gap: 14px;
  pointer-events: auto;
}

.control-btn {
  width: clamp(56px, 9vw, 72px);
  height: clamp(56px, 9vw, 72px);
  border: 3px solid #000;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: clamp(20px, 3.4vw, 28px);
  font-family: "Bungee", Arial, sans-serif;
  touch-action: none;
  pointer-events: auto;
  box-shadow: 0 6px 0 rgba(0,0,0,0.35);
}

/* Show controls only on touch devices in landscape */
@media (orientation: landscape) and (pointer: coarse) and (hover: none) {
  .mobile-controls { display: flex; }
}

/* ======= Canvas rendering ======= */
.game-screen {
  width: 1280px;               /* intrinsic stage size for crisp scaling */
  height: 480px;
  border: 1px solid black;
  border-top: none;
  background: url('../images/bg.png');
  display: none;               /* toggled by JS */
  margin: 0;
  image-rendering: pixelated;  /* crisp pixels when scaled */
}

/* ======= Start / Editor ======= */
.start-screen {
  width: 1280px;
  height: 530px;               /* matches BASE_H for scaler */
  border: 1px solid black;
  background: url('../images/bg2.webp');
  background-size: cover;
  position: relative;
}

/* NEW: Onboard-me-directly button (center bottom of start screen) */
.onboard-btn{
  position: absolute;
  bottom: 25px;
  left: 62%;
  transform: translateX(-50%);
  width: 280px;
  height: 54px;
  border: 4px solid white;
  border-radius: 20px;
  font-family: "Bungee", Arial, sans-serif;
  font-size: 21px;
  letter-spacing: .5px;
  cursor: pointer;
  background: linear-gradient(90deg, #ffde59, #ff914d);
  color: white;
  box-shadow: 0 5px 0 rgba(0,0,0,0.35);
}
@media (max-width: 600px) {
  .onboard-btn{
    width: 260px;
    height: 52px;
    bottom: calc(24px + env(safe-area-inset-bottom));
    font-size: 16px;
  }
}

.editor-screen {
  width: 1280px;
  height: 480px;
  border: 1px solid black;
  background: url('../images/bg.png');
  position: relative;
  overflow: hidden;
  display: none;
}

.menu-btn {
  width: 280px;
  height: 54px;
  border: 5px solid #fff;
  box-shadow:
    0 0 0 2px #000 inset,
    0 5px 0 rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  font-family: "Bungee", Arial, sans-serif;
  font-size: 18px;
  letter-spacing: .5px;
  cursor: pointer;
  background: linear-gradient(90deg, yellow, orange);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
  transition: transform .06s ease, filter .12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.menu-btn:hover { filter: brightness(1.05); }
.menu-btn:active { transform: translateY(2px); }

/* ======= Score Bar ======= */
.score-wrapper {
  width: 1280px;
  height: 50px;
  padding-left: 40px;
  display: none;
  border: 1px solid black;
  border-bottom: none;
  line-height: 50px;
  font-size: 20px;
  background-color: #add1f3;
  font-family: "Bungee";
  color: #ffffff;
  margin: 0;
}

.life-count {
  background: url('../images/mario-head.png') left center no-repeat;
  width: 100px;
  float: left;
  padding-left: 40px;
}

.coin-score {
  background: url('../images/coin.png') left center no-repeat;
  width: 150px;
  float: left;
  padding-left: 40px;
}

.level-num { width: 150px; float: left; }
.total-score { float: left; }

/* ======= Editor Grid & Elements ======= */
.cell   { width: 31px; height: 31px; border: 1px solid blue; }

.element-wrapper {
  width: 1280px;
  height: 130px;
  background: #d2d2d2;
  border: 1px solid black;
  display: none;
  margin: 0;
}

.platform      { width: 31px; height: 31px; background: url('../images/elements.png')   0    0; }
.coin-box      { width: 31px; height: 31px; background: url('../images/elements.png') -32px  0; }
.power-up-box  { width: 31px; height: 31px; background: url('../images/elements.png') -64px  0; }
.useless-box   { width: 31px; height: 31px; background: url('../images/elements.png') -96px  0; }
.flag-pole     { width: 31px; height: 31px; background: url('../images/elements.png') -128px 0; }
.flag          { width: 31px; height: 31px; background: url('../images/elements.png') -160px 0; }
.pipe-left     { width: 31px; height: 31px; background: url('../images/elements.png') -192px 0; }
.pipe-right    { width: 31px; height: 31px; background: url('../images/elements.png') -224px 0; }
.pipe-top-left { width: 31px; height: 31px; background: url('../images/elements.png') -256px 0; }
.pipe-top-right{ width: 31px; height: 31px; background: url('../images/elements.png') -288px 0; }
.goomba        { width: 31px; height: 31px; background: url('../images/enemies.png')      0  0; }

/* Arrows in level-editor */
.right-arrow { width: 60px; height: 60px; top: 215px; right: 0; background: url('../images/slider-right.png'); position: absolute; }
.left-arrow  { width: 60px; height: 60px; top: 215px; left: 0;  background: url('../images/slider-left.png');  position: absolute; }

.element-wrapper * { margin: 10px; float: left; }

.lvl-size { clear: both; float: left; width: 115px; height: 32px; background: url('../images/lvl-size.png'); margin-right: 10px; }
.grid-small-btn { float: left; width: 64px;  height: 32px; background: url('../images/grid-small-btn.png'); border: none; margin-right: 10px; }
.grid-medium-btn:selected { background: red; }
.grid-medium-btn { float: left; width: 96px;  height: 32px; background: url('../images/grid-medium-btn.png'); border: none; margin-right: 10px; }
.grid-large-btn  { float: left; width: 128px; height: 32px; background: url('../images/grid-large-btn.png');  border: none; margin-right: 10px; }

.save-map-btn  { float: right; width: 100px; height: 100px; background: url('../images/save-map-btn.png');  border: none; border: 2px solid black; margin-right: 10px; margin-top: -35px; }
.clear-map-btn { float: right; width: 100px; height: 100px; background: url('../images/clear-map-btn.png'); border: none; border: 2px solid black; margin-right: 10px; margin-top: -35px; }

/* ======= Levels List ======= */
.levels-wrapper {
  width: 1280px;
  height: 530px;
  border: 1px solid black;
  position: relative;
  overflow: hidden;
  display: none;
  background: url('../images/bg.png');
  margin: 0;
}

.start-btn {
  position: absolute;
  bottom: 25px;
  left: 38%;
  transform: translateX(-50%);
  width: 280px;
  height: 54px;
  border: 4px solid white;
  border-radius: 20px;
  font-family: "Bungee", Arial, sans-serif;
  font-size: 21px;
  letter-spacing: .5px;
  cursor: pointer;
  background: linear-gradient(90deg, #ffde59, #ff914d);
  color: black;
  box-shadow: 0 5px 0 rgba(0,0,0,0.35);
}
.editor-btn {
  display:none;
  position: absolute;
  bottom: 70px;
  left: 65%;
  transform: translateX(-50%);
  width: 280px;
  height: 54px;
  border: 2px solid #000;
  border-radius: 12px;
  font-family: "Bungee", Arial, sans-serif;
  font-size: 18px;
  letter-spacing: .5px;
  cursor: pointer;
  background: linear-gradient(#9da618, #15803d);
  color: black;
  box-shadow: 0 5px 0 rgba(0,0,0,0.35);
}
.created-btn {
  display: none;
  width: 200px;
  height: 50px;
  background: url('../images/saved-btn.png');
  position: absolute;
  bottom: 100px;
  left: 810px;
  color: #ffffff;
  border: 2px solid black;
}
/* Top-right Back button (inside the stage) */
.back-btn {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  width: clamp(120px, 16vw, 200px);
  height: clamp(40px, 6vw, 50px);
  background: url('../images/back-btn.png') center / contain no-repeat;
  color: #ffffff;
  border-radius: 15px;
  border: 2px solid #000;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35);
  margin: 0;                 /* no outer margin when absolutely positioned */
  display: none;             /* your JS toggles this to block */
  z-index: 2000;             /* above stage contents */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.back-btn:hover { filter: brightness(1.05); }
.back-btn:active { transform: translateY(1px); }


.level-btn {
  font-family: "Bungee";
  font-size: 25px;
  float: left;
  line-height: 50px;
  text-align: center;
  width: 248px;
  height: 50px;
  color: #ffffff;
  border: 2px solid black;
  margin: 2px;
  text-transform: uppercase;
  font-weight: bold;
  background: #15a7d9;
}
.delete-all-btn { width: 100px; height: 100px; background: url('../images/delete-all-btn.png'); color: #ffffff; border: 2px solid black; margin: 10px; position: absolute; bottom: 10px; right: 10px; }

.btn-wrapper { width: auto; height: auto; margin: 0; }

/* ======= Misc ======= */
.no-maps {
  width: 1000px;
  text-align: center;
  font-family: "Bungee";
  font-size: 25px;
  margin: 0 auto;
  color: #ffffff;
  background: #5fb952;
  border: 2px solid black;
}

.loading-percentage {
  font-size: 60px;
  font-family: "Bungee";
  text-align: center;
  padding: 100px;
}

.fb-comments { margin: 0 auto; }

/* ======= Rotate Overlay ======= */
.rotate-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-family: "Bungee", Arial, sans-serif;
  font-size: 18px;
  z-index: 6000;
  text-align: center;
  padding: 20px;
}

/* ========== Questionnaire Overlay (Mario Theme) ========== */
:root {
  --qf-accent: #ffcc00;
}

.qf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}
.qf-overlay.hidden { display: none; }

/* Make the panel a flex column so the action bar can stick on mobile */
.qf-box {
  width: min(720px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;

  background:
    linear-gradient(0deg, rgba(255,255,255,0.03), rgba(255,255,255,0.03)),
    url('../images/bg.png');
  background-size: cover;
  border: 3px solid #000;
  border-radius: 12px;
  padding: 18px 18px 14px;
  color: #ffffff;
  position: relative;
  box-shadow: 0 10px 0 #1b4b7a, 0 16px 40px rgba(0,0,0,0.45);
}

.qf-close {
  display: none;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid #000;
  background: #ffcc00;
  color: #000;
  font-size: 22px;
  font-family: "Lexend", Arial, sans-serif;
  cursor: not-allowed;
  box-shadow: 0 4px 0 #b38400;
}

.qf-title {
  font-family: "Lexend", sans-serif;
  font-size: 26px;
  letter-spacing: 1px;
  margin: 2px 0 10px;
  color: #fff;
}

.qf-type {
  min-height: 56px;
  font-family: "Lexend", sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.6;
  margin: 8px 0 10px;
  color: #fff;
  white-space: pre-wrap;
}

/* Scrollable content area so buttons stay visible */
.qf-body {
  margin-top: 4px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.qf-label {
  display: block;
  font-family: "Bungee", Arial, sans-serif;
  font-size: 14px;
  color: #fff;
  margin-bottom: 6px;
}

.qf-input {
  width: 60%;
  background: #0f172a;
  border: 2px solid #000;
  color: #fff;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
  box-shadow: inset 0 3px 0 #1b4b7a;
  font-family: Arial, sans-serif;
}
.qf-input:focus { border-color: #ffcc00; }

/* Sticky actions — always visible on mobile */
.qf-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;

  position: sticky;
  bottom: 0;
  padding-top: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.qf-btn {
  background: linear-gradient(#ff3b30, #c1271c);
  border: 3px solid #000;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-family: "Bungee", Arial, sans-serif;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 0 #6b0000;
  flex-shrink: 0;
}
.qf-btn:hover { filter: brightness(1.05); }

/* Options grid */
.qf-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

/* Option cards */
.qf-option {
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(#15a7d9, #0d87b1);
  border: 3px solid #000;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-weight: 700;
  font-family: "Bungee", Arial, sans-serif;
  box-shadow: 0 4px 0 #0b5672;
  box-sizing: border-box;
  min-height: 64px;
  display: flex;
  align-items: center;
}

.qf-option:hover { filter: brightness(1.08); }

.qf-option.selected,
.qf-option.active,
.qf-option:focus {
  outline: 3px solid var(--qf-accent);
  outline-offset: 0;
  box-shadow: 0 4px 0 #0b5672, 0 0 0 3px rgba(255, 204, 0, 0.35) inset;
}

/* Suggested list */
.qf-suggest {
  margin-top: 8px;
  border: 3px solid #000;
  border-radius: 10px;
  background: #0f172a;
  max-height: 220px;
  overflow: auto;
  box-shadow: inset 0 4px 0 #1b4b7a;
}
.qf-s-item { padding: 10px 12px; border-bottom: 2px solid #000; cursor: pointer; }
.qf-s-item:last-child { border-bottom: none; }
.qf-s-item:hover { background: #0b1220; }
.qf-s-name { font-family: "Bungee", Arial, sans-serif; font-size: 14px; color: #ffcc00; }
.qf-s-desc { font-size: 12px; color: #d1d5db; margin-top: 2px; font-family: Arial, sans-serif; }

.qf-hide { display: none; }

.qf-link {
  color: black;
  text-decoration: underline;
  font-family: "Bungee", Arial, sans-serif;
}

.qf-dev-otp {
  margin-top: 8px;
  font-size: 12px;
  color: #ffcc00;
  opacity: 0.9;
  font-family: "Bungee", Arial, sans-serif;
}

/* ===== Minimal Milestone Overlay ===== */
.ms-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.55);
  z-index: 5500;
}
.ms-overlay.hidden { display: none; }

.ms-box {
  width: min(900px, 94vw);
  border: 3px solid #000;
  border-radius: 14px;
  background:
    linear-gradient(0deg, rgba(255,255,255,0.03), rgba(255,255,255,0.03)),
    url('../images/bg.png');
  background-size: cover;
  box-shadow: 0 10px 0 #1b4b7a, 0 16px 40px rgba(0,0,0,0.45);
  padding: 18px;
  position: relative;
  color: #fff;
  text-align: center;
  z-index: 1;
}

.ms-title {
  font-family: "Lexend", sans-serif;
  font-size: 28px;
  color: #000;
  margin: 4px 2px 10px;
  font-weight: 700;
}

/* Celebration GIF under the title */
.ms-celebration {
  display: block;
  width: min(520px, 84%);
  max-height: 200px;
  margin: 8px auto 12px;
  object-fit: contain;
  image-rendering: auto;
}

/* Continue button */
.ms-next-btn {
  display: inline-block;
  margin: 6px auto 2px;
  padding: 10px 16px;
  border: 3px solid white;
  border-radius: 10px;
  background: linear-gradient(#ff3b30, #c1271c);
  color: #fff;
  font-family: "Bungee", Arial, sans-serif;
  box-shadow: 0 4px 0 #6b0000;
  letter-spacing: .5px;
  cursor: pointer;
  width: 180px;
}
.ms-next-btn:disabled { cursor: not-allowed; }

/* ===== Fullscreen Confetti Background ===== */
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}

/* OUTER: handles falling */
.confetti-piece {
  position: absolute;
  top: -12px;
  left: var(--c-left, 50%);
  width: var(--c-size, 10px);
  height: calc(var(--c-size, 10px) * 0.6);
  background: hsl(var(--c-hue, 40) 90% 60%);
  border: 2px solid rgba(0,0,0,0.25);
  border-radius: 2px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
  animation: confetti-fall var(--c-dur, 4s) linear var(--c-delay, 0s) forwards;
  transform: translate3d(0, 0, 0) rotate(0deg);
}

/* INNER: tilt/flips */
.confetti-piece > i {
  display: block;
  width: 100%;
  height: 100%;
  background: inherit;
  border-radius: inherit;
  border: inherit;
  box-shadow: inherit;
  animation: confetti-tilt var(--c-rot, 1s) ease-in-out var(--c-delay, 0s) infinite;
  transform: rotateY(0deg);
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, -12px, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--c-drift, 0px), 110vh, 0) rotate(680deg); opacity: 1; }
}

@keyframes confetti-tilt {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}
