#screen{
  width: 320px;
  height: 288px;
  border:1px solid black;
  margin-left: auto;
  margin-right: auto;
  margin-top: 154px; /* Move down to align with Game Boy screen */
  overflow:hidden;
  position: relative;

  /* Ensure crisp pixel rendering even when scaled */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

#location{
  background-image:url("../tiles/ground.png");
  position:relative;
}

#blackScreen{
  position:absolute;
  background-color: black;
  opacity: 0;
  width:0;
  height:0;
  z-index: 1700;
}

#up,#down{
  position: relative;
  float: left;
  background-image:url("../tiles/ground.png");
}

#player{
  background-image:url("../sprites/down.png");
  width:28px;
  height:32px;
  position: relative;
  z-index: 999;
}

#borderTop{
  height:160px;
  position:relative;
  float: left;
}

#borderLeft{
  width:128px;
  position:relative;
  float: left;
}

#borderRight{
  width:160px;
  position:relative;
  float: left;
}

#borderDown{
  height:128px;
  position:relative;
  float: left;
}

body{
  text-align:center;
}

.shadow {
    position: absolute;
    width: 28px;
    height: 14px;
    background: black;
    z-index: 998;
    border-radius: 50%;
}

/* ======================= */
/* Pokémon-style dialog UI */
/* ======================= */

#dialog{
  position:absolute;
  left:0;
  bottom:0;
  width:320px;  /* full Game Boy width ×2 */
  height:96px;  /* 6 tiles (16px) ×2 */
  display:none;
  z-index:1500;
  image-rendering:pixelated;
}

#dialog-inner{
  position:absolute;
  top:16px;      /* inner margin = border thickness (1 tile) */
  left:16px;
  right:16px;
  bottom:16px;
  overflow:hidden;
  z-index: 10;
}

.dialog-char{
  width:16px;
  height:16px;
  display:inline-block;
  image-rendering:pixelated;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.typing-cursor{
  width:4px;
  height:16px;
  display:inline-block;
  background-color: rgba(0, 0, 0, 0.3);
  animation: cursor-blink 1.0s ease-in-out infinite;
}

@keyframes cursor-blink{
  0%, 50% { opacity: 0.3; }
  51%, 100% { opacity: 0.1; }
}

/* Ensure hyperlinks inside the dialog indicate interactivity */
#dialog-inner a {
  cursor: pointer;
  /* Allow mobile interactions for dialog links */
  -webkit-user-select: auto !important;
  -moz-user-select: auto !important;
  -ms-user-select: auto !important;
  user-select: auto !important;
  -webkit-touch-callout: default !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
  pointer-events: auto !important;
  touch-action: auto !important;
  /* Better touch target size for mobile */
  min-height: 16px;
  display: inline-block;
}

/* Make dialog link characters more visually distinct on mobile */
@media (max-width: 768px) {
  #dialog-inner a {
    /* Slightly larger touch target on mobile */
    min-height: 20px !important;
    /* Add subtle background on hover/active */
    transition: background-color 0.1s ease;
  }
  
  #dialog-inner a:active {
    background-color: rgba(0, 100, 255, 0.1) !important;
    border-radius: 2px;
  }
}

#dialog-caret{
  position:absolute;
  width:16px;
  height:16px;
  bottom:16px;
  right:16px;
  display:none;
  image-rendering:pixelated;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  animation: caret-blink 0.6s steps(1) infinite;
  z-index: 20;
}

@keyframes caret-blink{
  50%{ opacity:0; }
}

/* tiles injected by script */
.dialog-tile{
  position:absolute;
  image-rendering:pixelated;
  z-index: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin: -0.5px 0 0 -0.5px;
  padding: 0;
  border: none;
  box-sizing: border-box;
  outline: none;
  box-shadow: none;
  transform: translateZ(0);
  /* Increase overlap to eliminate sub-pixel gaps */
  width: 17px;
  height: 17px;
}

/* Fade-in overlay image for Route 1 */
#erenImage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;      /* fill 80% of the viewport width */
  height: auto;    /* preserve aspect ratio */
  max-height: 90%; /* prevent overflow on very wide screens */
  opacity: 0;      /* start invisible; JS will control */
  z-index: 1200;   /* above the player (≈999) and below dialog (1500) */
  pointer-events: none; /* allow clicks to pass through */
}

/* ===================== */
/* Mute/Unmute Button     */
/* ===================== */
#mute-button {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  z-index: 2500; /* above everything including game boy overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #000;
  border-radius: 4px;
  transition: all 0.2s ease;
  user-select: none;
}

#mute-button:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

#mute-button:active {
  transform: scale(0.95);
}

#speaker-icon {
  color: #000;
  width: 20px;
  height: 20px;
}

#mute-line {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 4px;
  background: #ff0000;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 2px;
  display: none; /* Hidden by default (unmuted state) */
  z-index: 1;
}

/* Show mute line when muted */
#mute-button.muted #mute-line {
  display: block;
}

/* Change speaker icon opacity when muted */
#mute-button.muted #speaker-icon {
  opacity: 0.5;
}

/* ===================== */
/* Player Position Display */
/* ===================== */
#position-display {
  position: fixed;
  top: 8px;
  left: 50px; /* Offset to avoid mute button */
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #000;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  color: #000;
  z-index: 2600; /* Above mute button and everything else */
  margin: 0;
  pointer-events: none; /* Allow clicks to pass through */
  user-select: none;
}

/* ===================== */
/* Music player overlay   */
/* ===================== */
#music-player-inner {
  font-family: sans-serif;
  color: #000;
  z-index: 10; /* above the frame tiles */
}
.song-row {
  display: flex;
  align-items: center;
  position: relative;
  height: 24px;
  line-height: 24px;
  padding-right: 4px;
  gap: 4px;
  overflow: hidden;  /* clip scrolling text within the bordered row */
}
.song-row.selected {
  background: none;
  border: 1px solid #000;
  z-index: 5;
}
.song-thumb {
  width: 24px;
  height: 24px;
  margin-right: 6px;
  image-rendering: pixelated;
  position: absolute;
  z-index: 2;
}
.song-title{
  flex:0 0 auto;       /* grow naturally, never shrink */
  text-align:left;
  font-size:16px;
  white-space:nowrap;  /* stay on one line */
  overflow:hidden;    /* no clipping */
  text-overflow:unset; /* disable ellipsis */
  position:relative;
  z-index:1;
  pointer-events:none;
  margin-left: 30px;
}
.song-title.truncated::after {
  content: '';
  position: absolute;
  top: 4px;          /* vertically align with sprite row */
  right: 64px;       /* sit directly to the left of the fixed-width length column */
  width: 48px;       /* 3 × 16px full-stop tiles */
  height: 16px;
  background-image: url('../tiles/dialog/characters/fullstop_character.png');
  background-repeat: repeat-x;
  background-size: 16px 16px;
  pointer-events: none;
  z-index: 3;
}
.song-length {
  font-size: 5px;
  position: absolute;
  right: 0;
  display: flex;
  width: 64px; /* Fixed width based on the comment in musicPlayer.js */
  text-align: right;
  z-index: 2;
}

.song-list {
  position:absolute;
  top:0;
  left:0;
  right:0;
}

/* Scrolling effect for overflowing song titles */
.song-title.scrolling {
  text-overflow: clip;
  padding-right: 48px;
  animation: scroll-title var(--scroll-duration) linear infinite alternate;
}

@keyframes scroll-title {
  0%   { transform: translateX(0); }
  100% { transform: translateX(calc(-1 * var(--scroll-distance))); }
}

.song-row.truncated::after {
  content: '';
  position: absolute;
  top: 4px;          /* vertically align with sprite row */
  right: 64px;       /* sit directly to the left of the fixed-width length column */
  width: 48px;       /* 3 × 16px full-stop tiles */
  height: 16px;
  background-image: url('../tiles/dialog/characters/fullstop_character.png');
  background-repeat: repeat-x;
  background-size: 16px 16px;
  pointer-events: none;
  z-index: 3;
}

/* ===================== */
/*  User menu overlay     */
/* ===================== */
#user-menu{
  image-rendering: pixelated;
  display:none;
}

#user-menu-inner{
  position:absolute;
  top:16px;
  left:16px;
  right:16px;
  bottom:16px;
  overflow:hidden;
  z-index:10;
}

.menu-row{
  display:flex;
  align-items:center;
  height:16px;
  line-height:16px;
}

.menu-cursor{
  width:16px;
  height:16px;
  margin-right:4px;
  background-image:url('../tiles/dialog/characters/cursor_down_character.png');
  background-repeat:no-repeat;
  background-size:100% 100%;
  transform: rotate(-90deg); /* point to the right */
  image-rendering:pixelated;
}

/* ===================== */
/* Social links overlay   */
/* ===================== */
#social-links {
  image-rendering: pixelated;
  display: none;
}

/* ===================== */
/* Help dialog overlay    */
/* ===================== */
#help-dialog {
  image-rendering: pixelated;
  display: none;
}

#help-dialog-inner {
  font-family: sans-serif;
  color: #000;
  z-index: 10;
}

#help-title {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

#help-options {
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-option-wrapper {
  transition: all 0.1s ease;
}

.help-option-wrapper.selected {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

#social-links-inner {
  font-family: sans-serif;
  color: #000;
  z-index: 10;
}

.social-icons-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  height: 100%;
}

.social-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.1s ease;
}

.social-icon-wrapper.selected {
  border: 2px solid #000;
  background-color: rgba(255, 255, 255, 0.1);
}

.social-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: block;
}

/* ===================== */
/* Video player overlay   */
/* ===================== */
#video-player {
  image-rendering: pixelated;
  display: none;
}

#video-player-inner {
  z-index: 10;
}

#video-player-element {
  border: none;
  outline: none;
  image-rendering: auto; /* Let video use smooth rendering */
}

/* Hide default video controls since we're using custom keyboard controls */
#video-player-element::-webkit-media-controls {
  display: none !important;
}

#video-player-element::-moz-media-controls {
  display: none !important;
}

#video-player-element {
  -webkit-media-controls: none;
  -moz-media-controls: none;
}

/* Video player text styling */
.video-text {
  text-align: center;
}

.video-text .dialog-char {
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

/* ===================== */
/* Inception Mode Styles */
/* ===================== */

#inception-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1800; /* Above everything except caret */
  background: #f5f5f5;
  image-rendering: pixelated;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#inception-browser {
  width: 100%;
  height: 100%;
  border: 1px solid #999;
  border-radius: 6px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#inception-browser-bar {
  height: 28px;
  background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);
  border-bottom: 1px solid #ccc;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-family: monospace;
  font-size: 9px;
  gap: 6px;
}

#inception-browser-buttons {
  display: flex;
  gap: 4px;
}

.browser-button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid #999;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  min-width: 12px; /* Ensure minimum touch target size */
  min-height: 12px;
}

.browser-button.close {
  background: #ff5555;
}

.browser-button.close:hover {
  background: #ff3333;
}

.browser-button.minimize {
  background: #ffbb33;
}

.browser-button.maximize {
  background: #33cc33;
}

#inception-url-bar {
  flex: 1;
  background: white;
  border: 1px solid #bbb;
  border-radius: 3px;
  padding: 3px 6px;
  margin: 0 4px;
  font-family: monospace;
  font-size: 8px;
  color: #666;
}

#inception-nav-buttons {
  display: flex;
  gap: 2px;
}

.nav-button {
  width: 16px;
  height: 16px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #666;
  cursor: pointer;
}

.nav-button:hover {
  background: #e8e8e8;
}

#inception-content {
  height: calc(100% - 29px);
  position: relative;
  background: white;
  padding: 4px;
}

#inception-multiplayer-status {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #000;
  border-radius: 2px;
  padding: 2px 4px;
  font-family: monospace;
  font-size: 7px;
  font-weight: bold;
  color: #000;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#inception-iframe-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  position: relative;
}

#inception-loading {
  font-family: monospace;
  font-size: 10px;
  color: #666;
  text-align: center;
  padding: 20px;
}

#inception-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 3px;
  background: white;
}

/* ===================== */
/* Game Boy Overlay       */
/* ===================== */
#game-boy-overlay {
  position: fixed;
  top: 50px; /* Space for multiplayer status + margin */
  left: 0;
  right: 0;
  bottom: 60px; /* Space for toggle button + margin */
  pointer-events: none; /* Allow clicks to pass through */
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Prevent ALL text selection and touch behaviors in Game Boy area */
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: none !important;
}

#game-boy-frame {
  width: auto;
  height: 100%; /* Fill available space */
  max-width: 100%; /* Fill available width */
  image-rendering: pixelated;
  object-fit: contain;
  
  /* Prevent text selection on the Game Boy frame itself */
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

/* D-pad container - positioned dynamically by JavaScript */
#dpad-container {
  position: fixed;
  pointer-events: none;
  z-index: 2001; /* Above the Game Boy frame */
  
  /* Extra prevention for d-pad area specifically */
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: none !important;
}

.dpad-button {
  position: absolute;
  background: rgba(0, 0, 0, 0); /* Invisible by default */
  border-radius: 2px;
  transition: all 0.08s ease-out;
  pointer-events: auto !important; /* Enable touch interaction */
  
  /* Comprehensive text selection prevention */
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: none !important;
}

/* D-pad buttons - positioned absolutely within the container */
/* Dimensions and positions will be set by JavaScript based on image measurements */
#dpad-up {
  width: 110px;  /* Base size, will be scaled by transform */
  height: 110px;
}

#dpad-down {
  width: 110px;
  height: 110px;
}

#dpad-left {
  width: 110px;
  height: 110px;
}

#dpad-right {
  width: 110px;
  height: 110px;
}

/* Press animation effects */
.dpad-button.pressed {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 0 8px rgba(255, 255, 255, 0.6),
    inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Subtle glow effect for extra visual feedback */
.dpad-button.pressed::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  z-index: -1;
}

/* Action buttons container - positioned dynamically by JavaScript */
#action-buttons-container {
  position: fixed;
  pointer-events: none;
  z-index: 2001; /* Above the Game Boy frame */
  
  /* Extra prevention for action buttons area */
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: none !important;
}

.action-button {
  position: absolute;
  background: rgba(0, 0, 0, 0); /* Invisible by default */
  transition: all 0.08s ease-out;
  pointer-events: auto !important; /* Enable touch interaction */
  
  /* Comprehensive text selection prevention */
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: none !important;
}

/* A button - circular */
#button-a {
  width: 158px;  /* diameter = radius * 2 = 79 * 2 */
  height: 158px;
  border-radius: 50%;
}

/* B button - circular */
#button-b {
  width: 152px;  /* diameter = radius * 2 = 76 * 2 */
  height: 152px;
  border-radius: 50%;
}

/* Start button - oval */
#button-start {
  width: 160px;  /* 975 - 815 = 160 */
  height: 62px;  /* 440 - 378 = 62 */
  border-radius: 31px; /* half of height for oval shape */
}

/* Press animation effects for action buttons */
.action-button.pressed {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 0 8px rgba(255, 255, 255, 0.6),
    inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Subtle glow effect for action buttons */
.action-button.pressed::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: inherit;
  z-index: -1;
}

/* ===================== */
/* Show/Hide Toggle       */
/* ===================== */
#toggle-button {
  position: fixed;
  bottom: 10px;
  left: 10px;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  z-index: 3000;
  user-select: none;
  font-family: sans-serif;
  
  /* Force underline to be visible */
  text-decoration: underline;
  text-decoration-color: #666;
  text-underline-offset: 2px;
  
  /* Subtle shimmer effect */
  background: linear-gradient(
    45deg,
    #444 40%,
    #777 50%,
    #444 60%
  );
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 4s ease-in-out infinite;
}

#toggle-button:hover {
  opacity: 1.0;
  animation-duration: 3s;
}

/* Make about link bigger on desktop */
@media (min-width: 769px) {
  #toggle-button {
    font-size: 20px;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  50% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ===================== */
/* Bottom Right Info Text */
/* ===================== */
#info-text {
  position: fixed;
  bottom: 10px;
  right: 10px;
  font-size: 18px;
  color: #333;
  opacity: 0.4;
  z-index: 3000;
  user-select: none;
  font-family: sans-serif;
}

/* ===================== */
/* Testing Text Panel    */
/* ===================== */
#side-panel {
  position: fixed;
  bottom: 60px;
  left: 10px;
  font-size: 16px;
  color: #333;
  z-index: 2500;
  display: none;
  opacity: 0.4;
  font-family: sans-serif;
  text-align: left;
}

#side-panel-breaker{
  margin-top: 10px;
}

/* ===================== */
/* Multiplayer Styles    */
/* ===================== */

/* Other players styling */
.other-player {
  pointer-events: none; /* Don't interfere with clicks */
  image-rendering: pixelated; /* Keep pixel art crisp */
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  transition: opacity 0.2s ease-in-out; /* Smooth fade in/out */
}

.other-player:hover {
  filter: drop-shadow(0 0 4px rgba(255,255,0,0.8)) !important;
}

/* Player name tags */
.player-nametag {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: #ffff00;
  text-shadow: 1px 1px 1px #000;
  font-family: monospace;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
  z-index: 11;
}

/* Multiplayer status indicator */
#multiplayer-status {
  position: fixed;
  top: 10px;
  right: 10px;
  background-color: rgba(0,0,0,0.7);
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-family: monospace;
  z-index: 3000; /* Above game boy overlay */
  user-select: none;
  transition: all 0.3s ease;
}

#multiplayer-status:hover {
  background-color: rgba(0,0,0,0.9);
  transform: scale(1.05);
}

/* Animation for players joining/leaving */
@keyframes player-join {
  0% { 
    opacity: 0; 
    transform: scale(0.5);
  }
  50% { 
    opacity: 0.4; 
    transform: scale(1.2);
  }
  100% { 
    opacity: 0.8; 
    transform: scale(1);
  }
}

@keyframes player-leave {
  0% { 
    opacity: 0.8; 
    transform: scale(1);
  }
  100% { 
    opacity: 0; 
    transform: scale(0.5);
  }
}

.other-player.joining {
  animation: player-join 0.5s ease-out;
}

.other-player.leaving {
  animation: player-leave 0.3s ease-in;
}

/* ===================== */
/* Mobile Optimizations   */
/* ===================== */

/* Enable pointer events for all devices */
.dpad-button, .action-button {
  pointer-events: auto !important; /* Enable mouse and touch interaction on all devices */
  -webkit-tap-highlight-color: transparent; /* Remove iOS tap highlight */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  /* Additional mobile-specific optimizations */
  .dpad-button, .action-button {
    /* Mobile rules already inherit from above */
  }
  
  /* Make side panel horizontal on mobile when visible */
  #side-panel {
    bottom: 12px !important; /* Same level as toggle button */
    left: 60px !important; /* Start after toggle button */
    font-size: 16px !important;
    flex-direction: row !important;
    gap: 15px !important; /* Space between links */
  }
  
  #side-panel-breaker {
    margin-top: 0 !important; /* Remove vertical spacing */
    margin-left: 0 !important; /* No extra horizontal spacing needed */
  }
}

/* Optimizations for very small screens */
@media (max-width: 480px) {
  /* Larger touch targets */
  .dpad-button {
    min-width: 44px !important;
    min-height: 44px !important;
  }
  
  .action-button {
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* Touch feedback improvements */
.dpad-button:active, .action-button:active {
  background: rgba(255, 255, 255, 0.4) !important;
  transform: scale(0.95) !important;
}

/* Prevent touch callouts, selections, and zoom during gameplay */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Comprehensive mobile interaction prevention */
* {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

/* Exception: Allow interactions for dialog links and their children */
#dialog-inner a,
#dialog-inner a *,
#dialog-inner a .dialog-char {
  -webkit-user-select: auto !important;
  -moz-user-select: auto !important;
  -ms-user-select: auto !important;
  user-select: auto !important;
  -webkit-touch-callout: default !important;
  -webkit-tap-highlight-color: rgba(0, 100, 255, 0.2) !important;
  pointer-events: auto !important;
  touch-action: auto !important;
}

/* Exception: Allow interactions for the about link (formerly toggle button) */
#toggle-button {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

/* Prevent zoom and unwanted touch behaviors */
@media (max-width: 768px) {
  html, body {
    touch-action: none !important;
    -webkit-text-size-adjust: 100% !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
    overflow: hidden !important;
  }
  
  /* Prevent zoom on all game elements */
  #game-boy-overlay, #screen, #game-boy-frame {
    touch-action: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }
}

/* Enhanced mobile press effects */
@media (max-width: 768px) {
  .dpad-button.pressed, .action-button.pressed {
    background: rgba(255, 255, 255, 0.5) !important;
    box-shadow: 
      0 0 12px rgba(255, 255, 255, 0.8),
      inset 0 3px 6px rgba(0, 0, 0, 0.4) !important;
    transform: scale(0.85) !important;
    border: 2px solid rgba(255, 255, 255, 0.6) !important;
  }
  
  /* Enhanced glow effect for mobile */
  .dpad-button.pressed::before, .action-button.pressed::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: inherit;
    z-index: -1;
  }
}

/* ======================= */
/* Game Freak Boot Animation */
/* ======================= */

#boot-animation-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  /* Ensure complete coverage to prevent any glitches */
}

#boot-animation-frame {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.boot-animation-hidden {
  display: none !important;
}

/* ===================== */
/* World Mirroring       */
/* ===================== */

/* Optional: Add subtle visual indicator when world is mirrored */
body.world-mirrored {
  /* Could add subtle effects here if desired, like a slight tint */
}

/* Ensure player sprite is also mirrored when world mirroring is enabled */
/* body.world-mirrored #player {
  transform: scaleX(-1);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
} */

/* ===================== */
/* Sign & Warp Shimmer   */
/* ===================== */

/* Only apply shimmer effects when help is enabled */
body.help-shimmer-enabled .sign {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: radial-gradient(circle at center, 
    rgba(255, 215, 0, 0.15) 0%, 
    rgba(255, 215, 0, 0.08) 50%, 
    transparent 70%
  );
  box-shadow: 
    0 0 8px rgba(255, 215, 0, 0.3),
    inset 0 0 8px rgba(255, 215, 0, 0.1);
  animation: golden-shimmer 3s ease-in-out infinite;
  z-index: 10;
  pointer-events: auto;
  image-rendering: pixelated;
  opacity: 0.7 !important; /* Override hidden barriers to show shimmer */
}

body.help-shimmer-enabled .sign:hover {
  background: radial-gradient(circle at center, 
    rgba(255, 215, 0, 0.25) 0%, 
    rgba(255, 215, 0, 0.15) 50%, 
    rgba(255, 215, 0, 0.05) 70%
  );
  box-shadow: 
    0 0 12px rgba(255, 215, 0, 0.5),
    inset 0 0 10px rgba(255, 215, 0, 0.2);
  animation-duration: 2s;
}

/* Warps - Green Shimmer */
body.help-shimmer-enabled .warp {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: radial-gradient(circle at center, 
    rgba(0, 255, 127, 0.15) 0%, 
    rgba(0, 255, 127, 0.08) 50%, 
    transparent 70%
  );
  box-shadow: 
    0 0 8px rgba(0, 255, 127, 0.3),
    inset 0 0 8px rgba(0, 255, 127, 0.1);
  animation: green-shimmer 2.5s ease-in-out infinite;
  z-index: 10;
  pointer-events: auto;
  image-rendering: pixelated;
  opacity: 0.7 !important; /* Override hidden barriers to show shimmer */
}

body.help-shimmer-enabled .warp:hover {
  background: radial-gradient(circle at center, 
    rgba(0, 255, 127, 0.25) 0%, 
    rgba(0, 255, 127, 0.15) 50%, 
    rgba(0, 255, 127, 0.05) 70%
  );
  box-shadow: 
    0 0 12px rgba(0, 255, 127, 0.5),
    inset 0 0 10px rgba(0, 255, 127, 0.2);
  animation-duration: 1.8s;
}

/* Golden Shimmer Animation */
@keyframes golden-shimmer {
  0% {
    box-shadow: 
      0 0 8px rgba(255, 215, 0, 0.3),
      inset 0 0 8px rgba(255, 215, 0, 0.1);
    transform: scale(1);
  }
  25% {
    box-shadow: 
      0 0 12px rgba(255, 215, 0, 0.4),
      inset 0 0 10px rgba(255, 215, 0, 0.15);
    transform: scale(1.02);
  }
  50% {
    box-shadow: 
      0 0 16px rgba(255, 215, 0, 0.5),
      inset 0 0 12px rgba(255, 215, 0, 0.2);
    transform: scale(1.05);
  }
  75% {
    box-shadow: 
      0 0 12px rgba(255, 215, 0, 0.4),
      inset 0 0 10px rgba(255, 215, 0, 0.15);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 
      0 0 8px rgba(255, 215, 0, 0.3),
      inset 0 0 8px rgba(255, 215, 0, 0.1);
    transform: scale(1);
  }
}

/* Green Shimmer Animation */
@keyframes green-shimmer {
  0% {
    box-shadow: 
      0 0 8px rgba(0, 255, 127, 0.3),
      inset 0 0 8px rgba(0, 255, 127, 0.1);
    transform: scale(1);
  }
  30% {
    box-shadow: 
      0 0 14px rgba(0, 255, 127, 0.45),
      inset 0 0 12px rgba(0, 255, 127, 0.18);
    transform: scale(1.03);
  }
  60% {
    box-shadow: 
      0 0 18px rgba(0, 255, 127, 0.6),
      inset 0 0 15px rgba(0, 255, 127, 0.25);
    transform: scale(1.06);
  }
  85% {
    box-shadow: 
      0 0 12px rgba(0, 255, 127, 0.4),
      inset 0 0 10px rgba(0, 255, 127, 0.15);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 
      0 0 8px rgba(0, 255, 127, 0.3),
      inset 0 0 8px rgba(0, 255, 127, 0.1);
    transform: scale(1);
  }
}

/* Mobile Optimizations for Shimmer Effects */
@media (max-width: 768px) {
  body.help-shimmer-enabled .sign, 
  body.help-shimmer-enabled .warp {
    /* Slightly stronger effects on mobile for better visibility */
    animation-duration: 2.5s;
  }
  
  body.help-shimmer-enabled .sign {
    box-shadow: 
      0 0 10px rgba(255, 215, 0, 0.4),
      inset 0 0 10px rgba(255, 215, 0, 0.15);
  }
  
  body.help-shimmer-enabled .warp {
    box-shadow: 
      0 0 10px rgba(0, 255, 127, 0.4),
      inset 0 0 10px rgba(0, 255, 127, 0.15);
  }
}

/* ======================= */
/* Customization dialog overlay    */
/* ======================= */
#customization-dialog {
  image-rendering: pixelated;
  display: none;
}

#customization-dialog-inner {
  font-family: sans-serif;
  color: #000;
  z-index: 10;
}

#customization-title {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

#customization-options {
  display: flex;
  align-items: center;
  justify-content: center;
}

.customization-option-wrapper {
  transition: all 0.1s ease;
}

.customization-option-wrapper.selected {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

/* ======================= */
/* Changelog dialog overlay    */
/* ======================= */
#changelog-dialog {
  image-rendering: pixelated;
  display: none;
}

#changelog-dialog-inner {
  font-family: sans-serif;
  color: #000;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100%;
}

#changelog-title {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}

#changelog-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#changelog-scroll-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  flex-shrink: 0;
}

/* ======================= */
/* Player Trail Effects    */
/* ======================= */

.player-trail {
  position: absolute;
  z-index: 998;
  pointer-events: none;
  image-rendering: pixelated;
  /* Smooth opacity transition for fade effect */
  transition: opacity 0.1s ease;
}
