* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Disable text selection and tap highlights on interactive elements */
button,
a,
.ui-btn,
.result-btn,
.pause-btn,
.settings-btn,
canvas {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  background-color: #7bbcff;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  outline: none;
}

/* Remove focus outline on buttons */
button:focus,
a:focus,
.ui-btn:focus {
  outline: none;
}

@font-face {
  font-family: BagelFatOne;
  /* Relative to this stylesheet, so the game works under any subpath. */
  src: url(../assets/fonts/BagelFatOne.ttf);
}

html {
  background-color: #7bbcff;
  height: 100%;
}

body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: url(../assets/images/bg-cover.png);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #7bbcff;
  overflow: hidden;
  touch-action: none;
}

body::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-color: rgba(20, 20, 80, 0.1);
}

a {
  text-decoration: none;
}

/* dvh, not vh: 100vh is the viewport with browser chrome hidden, so on mobile
   the bottom of the game sits behind the address/toolbar — and body's
   overflow: hidden means it cannot be scrolled into view. dvh tracks the
   viewport that is actually visible. On desktop the two are identical. */
.big-daddy {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.daddy {
  width: 100%;
  height: 100dvh;
  position: relative;
  z-index: 999;
}

/* An inline canvas sits on the text baseline, so the line box reserves a few
   px of descender space beneath it — enough to push the document past the viewport
   and overflow behind body's overflow: hidden. Block removes the gap. */
#kaplay-canvas {
  display: block;
}

.scoreboard {
  position: absolute;
  top: 50px;
  left: 0px;
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
}

.scoreboard .floors {
  color: #af2f28;
  display: flex;
  font-size: 1.25rem;
  line-height: 2rem;
  font-weight: 900;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff,
    1px 1px 0 #fff;
  letter-spacing: 1px;
}

#floor-score-text {
  font-family: BagelFatOne;
}

.scoreboard .floors .floor-number-images {
  display: flex;
  align-items: flex-end;
}

.scoreboard .floors .floor-number-images img {
  height: 70px;
  width: auto;
  object-fit: contain;
  margin-left: -35px;
}

.scoreboard .floors .floor-number-images img:first-child {
  margin-left: 0;
}

.scoreboard #score {
  min-width: 110px;
  height: max-content;
  color: #fff;
  background: rgba(70, 20, 20, 0.6);
  padding: 2px 12px 2px 45px;
  border-radius: 8px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 1px;
  position: relative;
  text-align: right;
}

.scoreboard #score img {
  position: absolute;
  width: 100%;
  max-width: 50px;
  top: 50%;
  left: 0;
  transform: translateY(-50%) translateX(-40%);
}

.scoreboard #hearts-container {
  display: flex;
  align-items: center;
  column-gap: 8px;
  margin-top: 14px;
}

.scoreboard #hearts-container img {
  width: 34px;
}

.result-main {
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, #7bbcff, #b8fdfd);
  position: relative;
}

.overlay {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(20, 20, 20, 0.3);
  top: 0;
  left: 0;
}

.resut-bg {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

.result-main footer {
  width: 100%;
  height: 90px;
  padding: 4px 20px;
  background: #e2e2e5;
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.result-main footer h1 {
  color: #11455d;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.result-main footer h1 a {
  color: #af2f28;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 18px;
}

.result-main footer .social-info {
  margin-top: 12px;
}

/* ===========================================
   UI Buttons (Pause, Sound, etc.)
   =========================================== */

.ui-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.ui-btn:hover {
  transform: scale(1.05);
}

.ui-btn:active {
  transform: scale(0.95);
}

.ui-btn img {
  width: 75px;
  height: 75px;
  object-fit: contain;
}

/* Pause Button - Bottom left */
.pause-btn {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 100;
}

/* Settings Button - Next to Pause */
.settings-btn {
  position: absolute;
  bottom: 20px;
  left: 100px;
  z-index: 100;
  transition: left 0.3s ease;
}

/* Settings button at pause position when game not started */
.settings-btn.settings-btn-left {
  left: 20px;
}

/* Fullscreen toggle — matches the pause-menu button styling. Sits under the
   start button (drawn at canvas centre + 80px, ~81px tall at 1/3 scale) so it
   stays clear of the bottom-left pause/settings row. Rules come after .ui-btn
   so the hover/active transforms keep the centring translate. */
.fullscreen-btn {
  position: absolute;
  top: calc(50% + 140px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 231, 201, 0.9);
  padding: 8px 22px;
  border-radius: 30px;
  border: 3px solid #af2f28;
}

.fullscreen-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #af2f28;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen-btn span {
  font-family: BagelFatOne;
  font-size: 20px;
  color: #af2f28;
  letter-spacing: 1px;
  line-height: 1;
  /* "Exit Fullscreen" is longer than "Fullscreen" — keep it on one line and
     let the pill widen instead of wrapping to two. */
  white-space: nowrap;
}

.fullscreen-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.fullscreen-btn:hover {
  transform: translateX(-50%) scale(1.05);
  background: rgba(255, 231, 201, 1);
}

.fullscreen-btn:active {
  transform: translateX(-50%) scale(0.98);
}

/* Generic hidden class */
.hidden {
  display: none !important;
}

/* ===========================================
   Pause Menu Overlay
   =========================================== */

.pause-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.pause-menu.hidden {
  display: none;
}

.pause-menu-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.pause-frame {
  width: auto;
  height: 420px;
}

.pause-buttons {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -40%);
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  justify-content: center;
}

.pause-buttons .ui-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 231, 201, 0.9);
  padding: 8px 20px 8px 10px;
  border-radius: 30px;
  border: 3px solid #af2f28;
  min-width: 160px;
}

.pause-buttons .ui-btn img {
  width: 45px;
  height: 45px;
}

.pause-buttons .ui-btn span {
  font-family: BagelFatOne;
  font-size: 24px;
  color: #af2f28;
  letter-spacing: 1px;
}

.pause-buttons .ui-btn:hover {
  transform: scale(1.05);
  background: rgba(255, 231, 201, 1);
}

.pause-buttons .ui-btn:active {
  transform: scale(0.98);
}

/* ===========================================
   Exit Confirmation Modal
   =========================================== */

.exit-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.exit-modal.hidden {
  display: none;
}

.exit-modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: BagelFatOne;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.exit-frame {
  width: auto;
  height: 420px;
  max-width: 90vw;
}

.exit-body {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.exit-body p {
  font-family: BagelFatOne;
  font-size: 24px;
  color: #af2f28;
  text-align: center;
  line-height: 1.3;
  margin: 0;
}

.exit-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}

.exit-buttons .ui-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 231, 201, 0.9);
  padding: 8px 20px 8px 10px;
  border-radius: 30px;
  border: 3px solid #af2f28;
  min-width: 120px;
  justify-content: center;
}

.exit-buttons .ui-btn span {
  font-family: BagelFatOne;
  font-size: 24px;
  color: #af2f28;
  letter-spacing: 1px;
}

.exit-buttons .ui-btn:hover {
  transform: scale(1.05);
  background: rgba(255, 231, 201, 1);
}

.exit-buttons .ui-btn:active {
  transform: scale(0.98);
}

/* ===========================================
   Settings Modal
   =========================================== */

.settings-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.settings-modal.hidden {
  display: none;
}

.settings-modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: BagelFatOne;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.settings-frame {
  width: auto;
  height: 300px;
  max-width: 90vw;
}

.settings-body {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 231, 201, 0.9);
  padding: 8px 20px;
  border-radius: 30px;
  border: 3px solid #af2f28;
  min-width: 180px;
  cursor: pointer;
  transition: transform 0.1s ease;
  justify-content: center;
}

.settings-toggle-row:active {
  transform: scale(0.95);
}

.settings-toggle-row span {
  font-family: BagelFatOne;
  font-size: 24px;
  color: #af2f28;
  letter-spacing: 1px;
  min-width: 60px;
}

.settings-toggle-row img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.settings-toggle-row.off {
  opacity: 0.5;
}

/* ===========================================
   Stability Meter
   =========================================== */

.stability-meter {
  position: absolute;
  bottom: 30px;
  right: 25px;
  width: 12px;
  height: 120px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  z-index: 100;
  overflow: hidden;
}

.stability-meter-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: #4ade80;
  border-radius: 6px;
  transition: height 0.3s ease, background-color 0.3s ease;
}

.scorecard-container {
  height: auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding-top: 15vh;
  font-family: BagelFatOne;
}

.scorecard-container img {
  width: 100%;
  max-width: 350px;
}

.scores {
  width: max-content;
  position: absolute;
  top: calc(15vh + 80px);
  left: 50%;
  transform: translateX(-50%);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
}

.floor-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  column-gap: 12px;
  background: #af2f28;
  border: 4px solid #f8884d;
  border-radius: 50px;
  padding: 12px 22px;
  color: #fff;
  letter-spacing: 2.5px;
  font-family: BagelFatOne;
}

.score-text {
  text-align: center;
  color: #af2f28;
  margin-top: 26px;
  letter-spacing: 1px;
  font-family: BagelFatOne;
}

#total-score {
  text-align: center;
  color: #af2f28;
  font-size: 60px;
  line-height: 65px;
  font-family: BagelFatOne;
}

.new-best-badge {
  position: absolute;
  top: 25%;
  left: 75%;
  text-align: center;
  rotate: 15deg;
  animation: pulse 1s ease-in-out infinite;
}

.new-best-badge img {
  width: 100px;
  height: auto;
}

.best-score-text {
  text-align: center;
  color: #11455d;
  font-size: 20px;
  margin-top: 12px;
  letter-spacing: 1px;
  font-family: BagelFatOne;
}

/* Result screen buttons - horizontal below card */
.result-buttons-horizontal {
  display: flex;
  gap: 25px;
  align-items: center;
  justify-content: center;
  padding-top: 24px;
}

.result-buttons-horizontal .ui-btn img {
  width: 90px;
  height: 90px;
}

.play-again-btn-new,
.home-btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===========================================
   Result/Game Over Overlay
   =========================================== */

.result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.result-overlay.hidden {
  display: none;
}

.result-overlay-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: BagelFatOne;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.result-frame {
  width: auto;
  height: 420px;
  max-width: 90vw;
}

.result-scores {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.result-scores .floor-score {
  font-size: 18px;
}

.result-scores .score-text {
  margin-top: 20px;
  font-size: 16px;
}

.result-scores #result-score {
  text-align: center;
  color: #af2f28;
  font-size: 55px;
  line-height: 55px;
  font-family: BagelFatOne;
}

.result-scores .best-score-text {
  margin-top: 8px;
  font-size: 18px;
}

.result-scores .new-best-badge {
  position: absolute;
  top: 20%;
  right: 25%;
}

.result-buttons {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.result-buttons .ui-btn img {
  width: 70px;
  height: 70px;
}

/* ===========================================
   Scoreboard Right Side Adjustments
   =========================================== */

.scoreboard-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* ===========================================
   Responsive
   =========================================== */

@media screen and (min-width: 451px) {
  .daddy {
    max-width: 450px;
  }
}

/* Tablet portrait (600px–767px) */
@media screen and (min-width: 600px) {
  .daddy {
    max-width: 580px;
  }

  .scoreboard {
    top: 60px;
    padding: 0 24px;
  }

  .scoreboard .floors .floor-number-images img {
    height: 80px;
  }

  .scoreboard #score {
    font-size: 2.2rem;
    min-width: 120px;
  }

  .scoreboard #hearts-container img {
    width: 38px;
  }

  .ui-btn img {
    width: 85px;
    height: 85px;
  }

  .pause-btn {
    bottom: 24px;
    left: 24px;
  }

  .settings-btn {
    bottom: 24px;
    left: 116px;
  }

  .stability-meter {
    width: 14px;
    height: 140px;
    right: 28px;
    bottom: 34px;
  }

  .pause-frame {
    height: 480px;
  }

  .result-frame,
  .exit-frame {
    height: 480px;
  }

  .settings-frame {
    height: 340px;
  }
}

/* Tablet landscape / large tablet (768px+) */
@media screen and (min-width: 768px) {
  .daddy {
    max-width: 680px;
  }

  .scoreboard {
    top: 70px;
    padding: 0 28px;
  }

  .scoreboard .floors .floor-number-images img {
    height: 90px;
  }

  .scoreboard #score {
    font-size: 2.4rem;
    min-width: 130px;
    padding: 2px 14px 2px 50px;
  }

  .scoreboard #hearts-container img {
    width: 42px;
  }

  .scoreboard #hearts-container {
    column-gap: 10px;
    margin-top: 16px;
  }

  .ui-btn img {
    width: 95px;
    height: 95px;
  }

  .pause-btn {
    bottom: 28px;
    left: 28px;
  }

  .settings-btn {
    bottom: 28px;
    left: 132px;
  }

  .settings-btn.settings-btn-left {
    left: 28px;
  }

  .stability-meter {
    width: 16px;
    height: 160px;
    right: 32px;
    bottom: 38px;
  }

  .pause-frame {
    height: 540px;
  }

  .result-frame,
  .exit-frame {
    height: 540px;
  }

  .settings-frame {
    height: 380px;
  }

  .pause-buttons .ui-btn span,
  .exit-buttons .ui-btn span,
  .settings-toggle-row span {
    font-size: 26px;
  }

  .pause-buttons .ui-btn,
  .exit-buttons .ui-btn {
    min-width: 180px;
    padding: 10px 24px 10px 12px;
  }

  .result-buttons .ui-btn img {
    width: 80px;
    height: 80px;
  }

  .scorecard-container img {
    max-width: 420px;
  }
}
