:root {
  --space-xl: clamp(2.5rem, 2.167rem + 1.48vw, 3.5rem);
  --space-m: clamp(1.5rem, 1.286rem + 0.95vw, 2rem);
  --space-s: clamp(1.25rem, 1.143rem + 0.48vw, 1.5rem);
  --space-xs: clamp(1rem, 0.952rem + 0.24vw, 1.25rem);
}

@font-face {
  font-family: 'Campton';
  src: url('assets/fonts/campton_book.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Campton';
  src: url('assets/fonts/campton.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Campton', sans-serif;
  font-weight: 400;
  background: #000000;
  color: #ffffff;
}

#gameContainer {
  position: relative;
  width: auto;
  background: #000000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gadget .screen {
  min-height: 90dvh;
}

.screen {
  background: #000000;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0 0 0;
  position: relative;
  min-height: 100dvh;
  width: min(100%, 440px);
  max-width: 440px !important;
  margin-inline: auto;
}

@media (min-width: 769px) {
  .screen {
    /* Maximum width is 440px, no scaling */
    width: min(100vw, 440px);
    max-width: 440px !important;
  }
}

.hidden {
  display: none !important;
}

/* Character Selection Screen */
#characterSelection {
  max-width: 640px;
  background: #000000;
  z-index: 9;
}

/* Top Scores Display */
#topScoresDisplay {
  display: none;
}

#topScoresDisplay h3 {
  color: #00ffff;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#topScoresList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
}

.top-score-entry {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px 16px;
  transition: all 0.2s ease;
}

.top-score-entry:hover {
  border-color: #00ffff;
  background: rgba(0, 255, 255, 0.1);
}

.top-score-rank {
  font-size: 1.5rem;
  margin-right: 16px;
  min-width: 40px;
}

.top-score-info {
  flex: 1;
  text-align: left;
}

.top-score-score {
  font-size: 1.2rem;
  font-weight: bold;
  color: #00ffff;
  margin-bottom: 2px;
}

.top-score-details {
  font-size: 0.9rem;
  color: #ccc;
  text-transform: capitalize;
}

.no-top-scores {
  color: #888;
  font-style: italic;
  padding: 20px;
}

.loading-top-scores {
  color: #00ffff;
  font-style: italic;
  padding: 20px;
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite;
}

.character-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.character-option {
  background: #232323;
  border-radius: 0px;
  padding: 16px;
  padding-inline-start: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 4px solid #ffffff;
  box-sizing: border-box;
}

.character-option.selected,
.player-score {
  .corners--top {
    &::before {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%2300ffcc' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    }
    &::after {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%2300ffcc' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    }
  }
  .corners--bottom {
    &::before {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%2300ffcc' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    }
    &::after {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%2300ffcc' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    }
  }
}

.character-option:hover {
  transform: translateY(-5px);
}

.character-option.selected {
  border-color: #00ffcc !important;
  background: #000000 !important;
}

.character-option.highlighted {
  border-color: #00ffcc;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.character-description {
  display: block;
  text-align: left;

  p {
    margin-top: 4px;
  }
}

.character-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.character-preview {
  width: 56px;
  height: 56px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.character-canvas {
  border-radius: 8px;
  width: 100%;
  height: 100%;
}

/* Retro HUD */
#retroHUD {
  position: absolute;
  top: 16px;
  inset-inline: 16px;
  background-color: #000;
  color: #ffffff;
  font-family: 'Campton', sans-serif;
  font-size: 16px;
  z-index: 10;
  border: 4px solid #ffffff;
}

.hud-container {
  display: flex;
  align-items: center;
}

.hud-left,
.hud-right {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
}

.hud-left {
  .hud-item {
    border-right: 1px solid #ffffff;
    &:not(:last-child) {
      border-bottom: 1px solid #ffffff;
    }
  }
}

.hud-right {
  .hud-item {
    &:not(:last-child) {
      border-bottom: 1px solid #ffffff;
    }
  }
}

.hud-item {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
}

.hud-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

#retroHUD .hud-label {
  color: #ffffff;
  opacity: 1;
}

#retroHUD .hud-value {
  color: #ffffff;
  font-weight: bold;
  transition: all 0.3s ease;
}

#retroHUD .lives-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#retroHUD .life-sprite {
  width: 16px;
  height: 16px;
  display: inline-block;
  transition: opacity 0.3s ease;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

#overlayHUD {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#timer {
  position: absolute;
  top: 10px;
  right: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.8);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
}

/* Score and Streak HUD elements */
#scoreContainer,
#streakContainer {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
}

#scoreContainer {
  top: 50px;
  right: 10px;
}

#streakContainer {
  top: 120px;
  right: 10px;
}

#currentStreak {
  color: #ffaa00;
}

#tearContainer {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

#tearBar {
  width: 24px;
  height: 100px;
  background: transparent;
  border: 2px solid #00ffff;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

#tearFill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: #00ffff;
  border-radius: 0 0 10px 10px;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.9;
}

.tear-level {
  position: absolute;
  left: -3px;
  right: -3px;
  height: 1px;
  background: rgba(0, 255, 255, 0.4);
  z-index: 2;
}

#tearLabel {
  font-size: 0.8rem;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  font-weight: bold;
}

#tearCount {
  font-size: 0.9rem;
  color: #00ffff;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin-top: 0.5rem;
  opacity: 1;
}

#gameHeader {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 20;
  padding: 0.5rem;
  background: transparent;
}

.game-btn {
  background: #2a2a2a;
  border: 2px solid #00ffff;
  color: #00ffff;
  font-size: 1rem;
  font-weight: bold;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.game-btn:hover {
  background: #444444;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 255, 255, 0.3);
}

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

@keyframes tearShimmer {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.2);
  }
}

@keyframes tearBubble {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(-10px) scale(1.1);
    opacity: 0;
  }
}

.tear-in-bar {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  width: 6px;
  height: 8px;
}

.tear-in-bar svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 2px rgba(135, 206, 235, 0.8));
}

#gameCanvas {
  display: block;
  margin: 0;
  border: none;
  background: #000000;
  max-height: 100dvh;
  max-width: 440px !important;
  width: 100%;
  object-fit: contain;

  @media (min-width: 440px) {
    max-height: calc(100dvh - 8px);
  }
}

#difficultySelection {
  text-align: center;
  margin-top: 2rem;
}

#difficultySelection h2 {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  text-shadow: none;
  font-family: monospace;
  font-weight: normal;
}

.difficulty-options {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}

.difficulty-option {
  background: #000000;
  border-radius: 0px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid #ffffff;
  text-align: center;
  min-width: 80px;
  flex: 1;
  max-width: 100px;
}

.difficulty-option:hover {
  background: #444444;
  transform: translateY(-2px);
}

.difficulty-option.selected {
  border-color: #00ffff;
  background: #000000;
}

.difficulty-option h3 {
  color: #fff;
  font-size: 0.7rem;
  margin-bottom: 0.2rem;
  text-shadow: none;
  font-family: monospace;
  font-weight: normal;
}

.difficulty-option .difficulty-description {
  font-size: 0.5rem;
  color: #cccccc;
  font-style: normal;
  line-height: 1.1;
  font-family: monospace;
}

#controls {
  display: none;
}

#controls p {
  font-size: 1rem;
  line-height: 1.4;
  margin: 0 0 1.5rem 0;
  color: #ffffff;
}

#mobileControlsSelection {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 12px 16px;
  background: #000000;
  border: 2px solid #ffffff;
  border-radius: 12px;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  min-height: 80px;
  width: 300px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.mobile-controls {
  width: 100%;
  display: none;
  justify-content: space-between;
  align-items: center;
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  z-index: 15;
  height: 140px;
  padding-inline: clamp(1rem, 0.636rem + 1.82vw, 2rem);
  padding-block: 16px;
  gap: 16px;
}

@media (any-hover: none) and (any-pointer: coarse) {
  .mobile-controls {
    display: flex;
  }
}

.mobile-controls__buttons {
  background-color: #fff;
  border: 4px solid #000;
  display: flex;
  max-width: 320px;
  width: 100%;

  button {
    flex-grow: 1;
    height: 76px;
    font-size: 24px;
    display: grid;
    place-items: center;
    background-color: transparent;
    border: none;
  }
}

.mobile-controls__gift {
  height: 86px;
  background-color: transparent;
  border: 4px solid #000;
  width: auto;
  aspect-ratio: 1 / 1;
}

/* Game Over Screen */
#gameOver {
  background: #000101;
  color: white;
}

#gameScreen {
  position: relative;
  height: 100dvh;
  max-width: 440px !important;
  width: 100%;
  margin-inline: auto;
  justify-content: flex-end;
}
/* #gameOverContent is now inside .welcome-container, styles handled by that class */

#gameOverTitle {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-shadow: none;
  font-family: 'Campton', sans-serif;
  font-weight: 700;
  line-height: 1;
}

#gameOverMessage {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

/* Button styles are now handled by .btn class, these specific styles removed */

/* Mobile-first responsive design */
@media (max-width: 500px) {
  .welcome-logo {
    margin-bottom: 16px;
  }

  .welcome-text,
  .welcome-subtext,
  .welcome-question {
    font-size: 18px;
  }

  .welcome-question {
    margin-bottom: 20px;
  }

  .welcome-santa {
    position: absolute;
    top: 0;
    right: 0;
    width: 90px;
    bottom: 90px;
    right: 20px;
  }

  .welcome-footer {
    padding: 24px 20px;
    position: relative;
  }

  .instructions {
    font-size: 1rem;
  }

  .next-btn {
    padding: 1.2rem 2.5rem;
    font-size: 1.3rem;
    margin-top: 2rem;
  }

  #difficultySelection h2 {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
  }

  .difficulty-options {
    gap: 0.8rem;
    margin-bottom: 1rem;
  }

  .difficulty-option {
    min-width: 90px;
    max-width: 110px;
    padding: 0.8rem 0.5rem;
  }

  .difficulty-option h3 {
    font-size: 0.8rem;
  }

  .difficulty-option .difficulty-description {
    font-size: 0.6rem;
  }

  #sideHUD {
    flex-direction: row;
    gap: 1rem;
    min-width: auto;
    padding: 0.5rem 1rem;
  }

  #controls {
    padding: 1.5rem;
    margin-top: 1.5rem;
  }

  .heart {
    font-size: 1.3rem;
  }

  #controls p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  #gameOverContent {
    padding: 2rem 1rem;
  }

  #gameOverTitle {
    font-size: 2rem;
  }
}

/* Portrait orientation adjustments */
@media (max-width: 400px) and (orientation: portrait) {
  .welcome-logo {
    width: 50px;
    height: 50px;
  }

  .welcome-text,
  .welcome-subtext,
  .welcome-question {
    font-size: 16px;
  }

  .welcome-question {
    margin-bottom: 16px;
  }

  .welcome-santa {
    width: 70px;
    bottom: 80px;
    right: 15px;
  }

  .welcome-footer {
    padding: 20px 16px;
    position: relative;
  }

  .skip-story {
    font-size: 13px;
  }

  .difficulty-options {
    gap: 0.5rem;
  }

  .difficulty-option {
    min-width: 70px;
    max-width: 85px;
    padding: 0.6rem 0.3rem;
  }
}

/* #highscoreContent and #nameEntryContent are now inside .welcome-container, styles handled by that class */

h1 {
  color: #fff;
  font-size: clamp(2rem, 1.143rem + 3.81vw, 4rem);
  text-shadow: none;
  font-family: 'Campton', sans-serif;
  font-weight: 700;
  line-height: 1;
}

/* Game Over Score Display */
.game-over-score-display {
  color: #00ffcc;
  font-size: clamp(2rem, 1.143rem + 3.81vw, 4rem);
  font-family: 'Campton', sans-serif;
  font-weight: 700;
  text-align: center;
  margin: 1.5rem 0;
  text-shadow:
    0 0 20px rgba(0, 255, 204, 0.8),
    0 0 40px rgba(0, 255, 204, 0.4);
  letter-spacing: 0.05em;
}

/* Difficulty Filter */
#difficultyFilter {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: #3a3a3a;
  border: 2px solid #666;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.filter-btn:hover {
  border-color: #00ffff;
  background: #444;
}

.filter-btn.active {
  background: #00ffff;
  border-color: #00ffff;
  color: #000;
}

/* Highscore List */
#highscoreList {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 40svh;

  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* Webkit scrollbar (Chrome, Safari, Edge) */
#highscoreList::-webkit-scrollbar {
  width: 4px;
}

#highscoreList::-webkit-scrollbar-track {
  background: transparent;
}

#highscoreList::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

#highscoreList::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}
.highscores-container {
  position: relative;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: calc(100% + var(--space-s));
    height: 2px;
    background: #fff;
    transform: translateX(-50%);
  }
  &::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: calc(100% + var(--space-s));
    height: 2px;
    background: #fff;
    transform: translateX(-50%);
  }
}

.highscore-entry {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 15px 15px 15px 43px;
  margin: 0 0 5px 0;
  background: transparent;
  border-radius: 0;
  border: none;
  min-height: 66px;
  border: 4px solid #fff;
}

.highscore-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.highscore-rank {
  font-size: 1.25rem;
  font-weight: bold;
  color: #00ffcc;
  min-width: 26px;
  font-family: 'Campton', sans-serif;
  position: absolute;
  left: 15px;
  top: 15px;
}

.highscore-info {
  flex: 1;
  text-align: left;
  margin-left: 42px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.highscore-name {
  font-size: 1.25rem;
  font-weight: bold;
  color: #fff;
  font-family: 'Campton', sans-serif;
  line-height: 1.2;
}

.highscore-details {
  font-size: 0.875rem;
  color: #fff;
  font-family: 'Campton', sans-serif;
  line-height: 1.2;
}

.highscore-score {
  font-size: 1.25rem;
  font-weight: bold;
  color: #00ffcc;
  font-family: 'Campton', sans-serif;
  margin-left: auto;
  line-height: 1.2;
}

.player-score {
  background: transparent !important;
  animation: none;
  box-shadow: none;
  border: 4px solid #00ffcc;
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.8);
  }
}

.highscore-name-input {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding: 4px 8px;
  background: rgba(0, 255, 204, 0.2);
  border: 2px solid white;
}

.inline-name-input {
  background: transparent;
  border: none;
  padding: 0;
  color: #fff;
  font-size: 1.25rem;
  font-weight: bold;
  font-family: 'Campton', sans-serif;
  outline: none;
  transition: all 0.3s ease;
  min-width: 128px;
  max-width: 128px;
}

.inline-name-input:focus {
  background: transparent;
  border: none;
  box-shadow: none;
}

.inline-name-input::placeholder {
  color: #666;
}

.save-name-btn {
  background: rgba(0, 255, 204, 0.3);
  border: 1px solid #00ffcc;
  color: #00ffcc;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.save-name-btn:hover:not(:disabled) {
  background: rgba(0, 255, 204, 0.5);
  transform: scale(1.1);
}

.save-name-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.save-name-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  pointer-events: none;
}

#noScores {
  text-align: center;
  color: #888;
  font-size: 1.2rem;
  padding: 40px 20px;
}

.loading {
  text-align: center;
  color: #00ffff;
  font-size: 1.2rem;
  padding: 40px 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

.error {
  text-align: center;
  color: #ff6b6b;
  font-size: 1rem;
  padding: 20px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid #ff6b6b;
  border-radius: 8px;
  margin: 20px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Highscore Buttons */
#highscoreButtons {
  display: flex;
  gap: var(--space-s);
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--space-m);
}

/* Name Entry */
#finalScoreDisplay {
  margin: 1rem 0 2rem;
  padding: 20px;
  background: #1a1a1a;
  border-radius: 10px;
  border: 2px solid #00ffff;
}

#finalScoreDisplay h2 {
  color: #00ffff;
  font-size: 1.8rem;
  margin: 0;
}

#nameInputContainer {
  margin: 2rem 0;
}

#nameInputContainer label {
  display: block;
  margin-bottom: 10px;
  font-size: 1.1rem;
  color: #fff;
}

#playerName {
  width: 100%;
  max-width: 300px;
  padding: 12px;
  font-size: 1.1rem;
  border: 2px solid #666;
  border-radius: 8px;
  background: #333;
  color: #fff;
  text-align: center;
}

#playerName:focus {
  outline: none;
  border-color: #00ffff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

#newHighscoreValue {
  color: #00ffff;
  font-weight: bold;
}

/* Snowflakes */
.snowflakes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.snowflake {
  position: absolute;
  width: 16px;
  height: 16px;
  animation: fall linear infinite;
  user-select: none;
}

.snowflake:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
  animation-duration: 3s;
  top: -50px;
}

.snowflake:nth-child(2) {
  left: 20%;
  animation-delay: 1s;
  animation-duration: 4s;
  top: -50px;
}

.snowflake:nth-child(3) {
  left: 30%;
  animation-delay: 2s;
  animation-duration: 3.5s;
  top: -50px;
}

.snowflake:nth-child(4) {
  left: 70%;
  animation-delay: 0.5s;
  animation-duration: 3s;
  top: -50px;
}

.snowflake:nth-child(5) {
  left: 80%;
  animation-delay: 1.5s;
  animation-duration: 4s;
  top: -50px;
}

.snowflake:nth-child(6) {
  left: 90%;
  animation-delay: 2.5s;
  animation-duration: 3.5s;
  top: -50px;
}

.snowflake:nth-child(7) {
  left: 95%;
  animation-delay: 0.2s;
  animation-duration: 3.8s;
  top: -50px;
}

@keyframes fall {
  to {
    transform: translateY(100dvh);
  }
}

/* Close Button */
.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: white;
  color: black;
  border: none;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 10;
  font-family: monospace;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 30px;
  z-index: 5;
  flex-shrink: 0;
}

.welcome-container {
  margin-top: auto;
  width: min(100% - var(--space-m) * 2, 400px);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
  align-items: flex-start;
  margin-bottom: 64px;
}

.character-container {
  width: min(100% - var(--space-m) * 2, 400px);
  margin-inline: auto;
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  gap: var(--space-m);
  align-items: flex-start;
  justify-content: flex-end;
  padding-block: var(--space-m);
  padding-block-end: 64px;
}

.speech-bubble__content {
  z-index: 5;
  background: #000000;
  border: 4px solid #ffffff;
  padding: 24px;
  position: relative;
  margin-top: auto;

  &::after {
    content: '';
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='15' height='20' fill='none'><path fill='%23fff' d='M15 10h-5V5h5z'/><path fill='%23000' d='M15 5h-5V0h5zM10 5H5V0h5zM5 5H0V0h5z'/><path fill='%23fff' d='M15 15h-5v-5h5zM10 15H5v-5h5zM5 10H0V5h5zM15 20h-5v-5h5z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
    position: absolute;
    bottom: 0;
    right: 20%;
    width: 15px;
    height: 20px;
    transform: translateY(100%);
  }
}

.speech-bubble__controller {
  width: 100%;
  height: auto;
  margin-top: var(--space-s);
}

.no-speech-bubble {
  width: 100%;
  & > * + * {
    margin-top: var(--space-s);
  }
}

.corners {
  position: relative;
}

.corners--inverted {
  .corners--top,
  .corners--bottom {
    &::before,
    &::after {
      filter: invert(1);
    }
  }
}

.corners--top {
  &::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%23fff' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
  }

  &::after {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    transform: rotate(90deg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%23fff' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
  }
}

.corners--bottom {
  &::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -5px;
    width: 10px;
    height: 10px;
    transform: rotate(-90deg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%23fff' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
  }

  &::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    transform: rotate(180deg);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' width='10px' height='10px' fill='none'><path fill='%23fff' d='M10 5H5v5h5z'/><path fill='%23000' d='M10.002 0h-5v5h5zM5 0H0v5h5zM5 5.002H0v5h5z'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
  }
}

.speech-bubble__content h1 {
  color: #fff;
  font-size: clamp(2rem, 1.143rem + 3.81vw, 4rem);
  line-height: 100%;
  margin-bottom: var(--space-m);
  font-family: 'Campton', sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

.welcome-text {
  color: #fff;
  font-size: 20px;
  line-height: 120%;
  font-family: 'Campton', sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

.keyboard-label {
  color: #fff;
  font-size: 16px;
  line-height: 120%;
  font-family: 'Campton', sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  margin-top: 24px;
  margin-bottom: 12px;
  text-align: center;
}

.keyboard-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0;
  font-weight: 700;

  svg {
    width: 100%;
    height: auto;
  }
}

.keyboard-key {
  background: transparent;
  border: 2px solid #fff;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  font-family: 'Campton', sans-serif;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.keyboard-key:not(.space-key) {
  transform: translateY(-2px);
}

.keyboard-key.space-key {
  width: 120px;
  height: 50px;
  gap: 8px;
}

.keyboard-key.space-key span {
  font-size: 16px;
  text-transform: lowercase;
}

.keyboard-key .key-icon {
  width: 24px;
  height: auto;
}

.welcome-subtext {
  color: #fff;
  font-size: 20px;
  line-height: 120%;
  margin-bottom: 20px;
  font-family: 'Campton', sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

.welcome-question {
  color: #fff;
  font-size: 20px;
  line-height: 120%;
  margin-bottom: 30px;
  font-family: 'Campton', sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

.btn {
  background: #000000;
  color: #00ffcc;
  border: 2px solid #00ffcc;
  padding: 16px;
  font-size: 20px;
  font-weight: 700;
  border-radius: 0px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Campton', sans-serif;
  letter-spacing: 0;
  display: inline-block;
  text-decoration: none;
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

.btn--dark {
  color: #000;
  background: #fff;
  border-color: #000;
}

.btn:hover:not(:disabled) {
  background: #00ffcc;
  color: #000000;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.highscore-entry .highscore-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

#highscoreButtons {
  display: flex;
  gap: var(--space-s);
  flex-wrap: wrap;
  align-items: center;
}

.santa-stage {
  position: absolute;
  top: 0;
  right: calc(var(--space-m) + max(16px, (100vw - min(100%, 640px)) / 2));
  transform: translateY(-50%);
  z-index: -1;
}

.santa-head-container {
  position: absolute;
  inset: 22% 25% 46% 25%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.santa-head {
  position: absolute;
  top: 0;
  right: 0;
  transform: translateY(-90%) rotate(15deg);
  transform-origin: 100% 100%;
  animation: santaHeadBob 1.8s ease-in-out infinite;
  z-index: -1;
}

.santa-body-container {
  position: absolute;
  inset: 51% 28% 24% 22%;
}

.santa-footer-text {
  position: absolute;
  top: -40px;
  left: -56px;
  font-family: 'Campton', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

@keyframes santaHeadBob {
  0% {
    transform: translateY(-90%) rotate(15deg);
  }
  15% {
    transform: translateY(-90%) rotate(5deg);
  }
  25% {
    transform: translateY(-90%) rotate(12deg);
  }
  45% {
    transform: translateY(-90%) rotate(7deg);
  }
  55% {
    transform: translateY(-90%) rotate(13deg);
  }
  75% {
    transform: translateY(-90%) rotate(6deg);
  }
  100% {
    transform: translateY(-90%) rotate(15deg);
  }
}

.welcome-footer {
  width: 100vw;
  background: #ffffff;
  padding-block: var(--space-m) var(--space-xs);
  z-index: 5;
  box-sizing: border-box;
  flex-shrink: 0;
  position: relative;
  min-height: 140px;
  padding-inline: max(16px, (100vw - min(100%, 640px)) / 2 + var(--space-m));
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.scroll-indicator {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  animation: bounce 1.5s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(10px);
  }
}

.welcome-footer--game {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -1;
}

.skip-story {
  color: #000000;
  font-family: 'Campton', sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  transition: opacity 0.3s ease;
  display: inline-block;
}

.skip-story:hover {
  opacity: 0.7;
}

.gadget-info {
  background-color: #fff;
  position: relative;
  padding-inline: max(16px, (100% - 56ch) / 2);
  padding-block: 80px;
  overflow: hidden;
}

.gadget-info__container {
  color: #000;
  position: relative;
  z-index: 1001;

  h2 {
    font-size: clamp(2rem, 1.143rem + 3.81vw, 4rem);
  }

  & > * + * {
    margin-top: var(--space-xl);
  }

  p {
    font-size: 20px;
  }
}

.gadget-info__content {
  & > * + * {
    margin-top: var(--space-m);
  }
}

.gadget-info__list {
  margin-inline-start: 20px;
  margin-top: var(--space-s);
}

.gadget-info__svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 90%;
}

.gadget-info__controller {
  width: 100%;
  height: auto;
}

/* Share Overlay */
.share-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-m);
}

.share-overlay__content {
  background: #000000;
  border: 5px solid #ffffff;
  padding: var(--space-m);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.share-overlay__content h2 {
  color: #fff;
  font-size: clamp(1.5rem, 1.143rem + 1.81vw, 2.5rem);
  margin-bottom: var(--space-m);
  text-align: center;
  font-family: 'Campton', sans-serif;
  font-weight: 700;
}

.share-overlay__image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: var(--space-m) 0;
  background: #000000;
  padding: var(--space-s);
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.share-overlay__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 2px solid #ffffff;
}

.share-overlay__buttons {
  display: flex;
  gap: var(--space-s);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-m);
}

.share-overlay__close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  font-family: 'Campton', sans-serif;
}

.share-overlay__close:hover {
  color: #00ffcc;
}

/* Credits Overlay */
.credits-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1002;
  padding: var(--space-m);
}

.credits-overlay__content {
  background: #000000;
  border: 5px solid #ffffff;
  padding: var(--space-m);
  max-width: 500px;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.credits-overlay__content h2 {
  color: #fff;
  font-size: clamp(1.5rem, 1.143rem + 1.81vw, 2.5rem);
  margin-bottom: var(--space-m);
  text-align: center;
  font-family: 'Campton', sans-serif;
  font-weight: 700;
}

.credits-overlay__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  padding: var(--space-s) 0;
}

.credits-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  color: #fff;
  font-family: 'Campton', sans-serif;
}

.credits-label {
  color: #00ffcc;
  font-weight: 700;
  min-width: 120px;
}

.credits-link {
  color: #fff;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.credits-link:hover {
  color: #00ffcc;
}

.credits-overlay__close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  font-family: 'Campton', sans-serif;
}

.credits-overlay__close:hover {
  color: #00ffcc;
}

.star-container {
  position: absolute;
  bottom: -12px;
  right: 0;
  transform: translateY(100%);
  filter: drop-shadow(0 0 20px rgb(255, 215, 0));
  opacity: 0;
  visibility: hidden;
  --pulse-trigger: 0;
  --pulse-scale: 1;
  --pulse-glow: 20px;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease,
    visibility 0.3s ease;

  &:not(.hidden) {
    opacity: 1;
    visibility: visible;
  }

  .star-count {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: bold;
  }
}

.nav-footer {
  ul {
    display: flex;
    list-style: none;
    gap: var(--space-m);
    justify-content: center;
    flex-wrap: wrap;
  }

  a,
  button {
    color: #000;
    text-decoration: none;
    font-family: 'Campton', sans-serif;
    font-size: 14px;
    font-weight: 700;
    transition: opacity 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;

    &:hover {
      text-decoration: underline;
    }
  }
}

/* Nav footer after gadget-info */

.gadget {
  .nav-footer {
    padding: var(--space-m);
    position: relative;
    background-color: #fff;
  }
}

#gameCanvasContainer {
  position: relative;

  & > .corners--top {
    display: none;
  }
  @media (min-width: 440px) {
    border: 4px solid #fff;

    & > .corners--top {
      display: block;
    }
  }
}
