/* ============================================
   Base & Page Layout
   ============================================ */

* {
  box-sizing: border-box;
  /* Eliminate 300ms tap delay on all interactive elements */
  touch-action: manipulation;
}

html,
body {
  padding: 0;
  margin: 0;
  width: 100%;
  min-height: 100%;
  font-family: 'Inter', sans-serif;
  background-color: #f0f0f0;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.game-card {
  background-color: #ffffff;
  border: 3px solid #2b2b2b;
  border-radius: 16px;
  padding: 32px 40px 24px;
  max-width: 680px;
  width: 100%;
  position: relative;
}

/* ============================================
   Game Header
   ============================================ */

.game-header {
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
  max-width: 680px;
  position: relative;
}

main {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  font-weight: 400;
  color: #2b2b2b;
  margin: 0 0 12px;
  line-height: 1.6;
  text-transform: uppercase;
  min-height: 52px;
}

.game-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #888888;
  margin: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: opacity 0.3s ease;
}

.game-description {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: #666666;
  margin: 12px auto 16px;
  line-height: 1.5;
  max-width: 480px;
  min-height: 60px;
}

/* ============================================
   Game Area (Internal - do not modify rendering)
   ============================================ */

.icon {
  -webkit-user-select: none;
  user-select: none;
  display: inline-block;
}

.icon-offline {
  content: -webkit-image-set(url(assets/default_100_percent/100-error-offline.png) 1x, url(assets/default_200_percent/200-error-offline.png) 2x);
  position: relative;
}

.hidden {
  display: none;
}

.offline .interstitial-wrapper {
  color: #2b2b2b;
  font-size: 1em;
  line-height: 1.55;
  margin: 0 auto;
  max-width: 600px;
  padding-top: 100px;
  width: 100%;
}

.offline .runner-container {
  height: 150px;
  max-width: 600px;
  overflow: hidden;
  position: absolute;
  top: 35px;
  width: 44px;
  image-rendering: pixelated;
}

.offline .runner-canvas {
  height: 150px;
  max-width: 600px;
  opacity: 1;
  overflow: hidden;
  position: absolute;
  top: 0;
  z-index: 2;
  image-rendering: pixelated;
  touch-action: none;
}

.offline .controller {
  background: rgba(247, 247, 247, .1);
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 1;
  touch-action: none;
}

#offline-resources {
  display: none;
}

/* ============================================
   Responsive / Media Queries
   ============================================ */

@media (max-width: 600px) {

  .suggested-left>#control-buttons,
  .suggested-right>#control-buttons {
    float: none;
  }

  .snackbar {
    left: 0;
    bottom: 0;
    width: 100%;
    border-radius: 0;
  }

  .game-card {
    padding: 16px 12px 12px;
    border-radius: 12px;
  }

  .game-title {
    font-size: 12px;
    min-height: 40px;
  }

  .game-subtitle {
    font-size: 12px;
  }

  .game-description {
    font-size: 11px;
    margin: 8px auto 12px;
    min-height: 66px;
  }

  /* Compact controls guide on mobile */
  .controls-container {
    gap: 2px;
    padding: 2px 0 0;
    margin-top: 2px;
  }

  .controls-text {
    font-size: 6px;
    letter-spacing: 0;
  }

  .key-group {
    flex-direction: row;
    /* Put W/A/S/D inline instead of stacked */
    gap: 1px;
  }

  .key-row {
    gap: 1px;
  }

  .key {
    width: 10px;
    height: 10px;
    font-size: 5px;
    border-radius: 2px;
    line-height: 10px;
  }

  .key-space {
    width: auto;
    padding: 0 2px;
    font-size: 5px;
  }

  .page-wrapper {
    padding: 8px 4px;
    justify-content: flex-start;
    padding-top: 10px;
  }
}

/* Very small screens: hide controls guide entirely */
@media (max-width: 380px) {
  .controls-container {
    display: none;
  }
}

@media (max-height: 350px) {
  h1 {
    margin: 0 0 15px;
  }

  .icon-offline {
    margin: 0 0 10px;
  }

  .interstitial-wrapper {
    margin-top: 5%;
  }

  .nav-wrapper {
    margin-top: 30px;
  }
}

@media (min-width: 600px) and (max-width: 736px) and (orientation: landscape) {
  .offline .interstitial-wrapper {
    margin-left: 0;
    margin-right: 0;
  }
}

@media (min-width: 420px) and (max-width: 736px) and (min-height: 240px) and (max-height: 420px) and (orientation: landscape) {
  .interstitial-wrapper {
    margin-bottom: 100px;
  }
}

@media (min-height: 240px) and (orientation: landscape) {
  .offline .interstitial-wrapper {
    margin-bottom: 90px;
  }

  .icon-offline {
    margin-bottom: 20px;
  }
}

@media (max-height: 320px) and (orientation: landscape) {
  .icon-offline {
    margin-bottom: 0;
  }

  .offline .runner-container {
    top: 10px;
  }
}

@media (max-width: 240px) {
  .interstitial-wrapper {
    overflow: inherit;
    padding: 0 8px;
  }
}

/* ============================================
   Arcade Mode (disabled but kept for reference)
   ============================================ */

.arcade-mode,
.arcade-mode .runner-container,
.arcade-mode .runner-canvas {
  image-rendering: pixelated;
  max-width: 100%;
  overflow: hidden;
}

.arcade-mode #buttons,
.arcade-mode #main-content {
  opacity: 0;
  overflow: hidden;
}

.arcade-mode .interstitial-wrapper {
  height: 100vh;
  max-width: 100%;
  overflow: hidden;
}

.arcade-mode .runner-container {
  left: 0;
  margin: auto;
  right: 0;
  transform-origin: top center;
  transition: transform 250ms cubic-bezier(0.4, 0, 1, 1) 400ms;
  z-index: 2;
}

/* ============================================
   Mute Button
   ============================================ */

.mute-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  transform: none;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  background-color: #2b2b2b;
  color: #ffffff;
  z-index: 10;
}

.mute-btn:active {
  transform: scale(0.92);
}

.mute-btn svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 16px;
  height: 16px;
}

/* Show/hide icons based on state */
.mute-btn .icon-sound,
.mute-btn .icon-mute {
  display: none;
}

.mute-btn.sound-on .icon-sound {
  display: block;
}

.mute-btn.sound-off .icon-mute {
  display: block;
}

/* Muted state: light background, dark icon */
.mute-btn.muted {
  background-color: #d0d0d0;
  color: #555555;
}

/* Night mode */
body.inverted .mute-btn {
  background-color: #f0f0f0;
  color: #2b2b2b;
}

body.inverted .mute-btn.muted {
  background-color: #555555;
  color: #999999;
}

/* ============================================
   Language Dropdown Selector
   ============================================ */
.lang-dropdown {
  position: absolute;
  top: -8px;
  right: 0;
  left: auto;
  z-index: 100;
  user-select: none;
}

.lang-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #888888;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: unset;
}

.lang-dropdown-btn:hover {
  background-color: #e0e0e0;
  color: #2b2b2b;
}

.flag-icon {
  width: 16px;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  display: block;
}

.dropdown-arrow {
  margin-left: 4px;
  font-size: 8px;
  transition: transform 0.2s ease;
}

.lang-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.lang-dropdown-content {
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  margin-top: 4px;
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  min-width: 150px;
  max-height: 250px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.lang-dropdown.open .lang-dropdown-content {
  display: flex;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #555555;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.lang-option:hover {
  background-color: #f5f5f5;
  color: #2b2b2b;
}

/* Night mode Language Dropdown */
body.inverted .lang-dropdown-btn {
  color: #777777;
}

body.inverted .lang-dropdown-btn:hover {
  background-color: #3a3a3a;
  color: #f0f0f0;
}

body.inverted .lang-dropdown-content {
  background-color: #2b2b2b;
  border-color: #444444;
}

body.inverted .lang-option {
  color: #bbbbbb;
}

body.inverted .lang-option:hover {
  background-color: #333333;
  color: #ffffff;
}

/* ============================================
   Controls Guide
   ============================================ */

.controls-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0 0;
  border-top: 2px solid #eaeaea;
  margin-top: 12px;
}

.controls-text {
  font-size: 15px;
  font-weight: 600;
  color: #aaaaaa;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.key-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.key {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  font-family: 'Inter', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.key-dark {
  background-color: #2b2b2b;
}

.key-light {
  background-color: #d0d0d0;
  color: #888888;
}

.key-space {
  width: auto;
  padding: 0 16px;
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* ============================================
   Leaderboard
   ============================================ */

.leaderboard-container {
  max-width: 680px;
  width: 100%;
  margin-top: 20px;
  background-color: #ffffff;
  border-radius: 20px;
  padding: 32px 36px;
  animation: lb-fade-in 0.4s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

@keyframes lb-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lb-header {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
}

.lb-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #929ba2;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-transform: uppercase;
}


/* Score Submission Form */
.score-submit-form {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.35s ease;
  margin-bottom: 0;
}

.score-submit-form.visible {
  max-height: 120px;
  opacity: 1;
  margin-bottom: 16px;
}

.score-submit-inner {
  background-color: #f7f7f7;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.your-score-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  font-weight: 400;
  color: #555555;
  text-transform: uppercase;
}

.your-score-label strong {
  font-weight: 400;
  color: #2b2b2b;
  font-size: 12px;
}

.score-submit-controls {
  display: flex;
  gap: 8px;
}

#player-name-input {
  flex: 1;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  font-weight: 400;
  padding: 10px 12px;
  text-transform: uppercase;
  border: 2px solid #d0d0d0;
  border-radius: 8px;
  background-color: #ffffff;
  color: #2b2b2b;
  outline: none;
  transition: border-color 0.2s ease;
}

#player-name-input:focus {
  border-color: #2b2b2b;
}

#player-name-input.error {
  border-color: #e74c3c;
  animation: lb-shake 0.4s ease;
}

@keyframes lb-shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-4px);
  }

  40% {
    transform: translateX(4px);
  }

  60% {
    transform: translateX(-3px);
  }

  80% {
    transform: translateX(3px);
  }
}

#submit-score-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background-color: #2b2b2b;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

#submit-score-btn:hover {
  opacity: 0.85;
}

#submit-score-btn:active {
  transform: scale(0.95);
}

#submit-score-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Score Lists */
.lb-scores-list {
  display: none;
}

.lb-scores-list.active {
  display: block;
}

.lb-empty,
.lb-loading {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #aaaaaa;
  text-align: center;
  padding: 24px 0;
  line-height: 1.6;
  text-transform: uppercase;
}

.lb-score-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  margin-bottom: 8px;
}

.lb-rank-icon {
  width: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.lb-diamond {
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
}

.diamond-gold {
  background-color: #fcc201;
}

.diamond-silver {
  background-color: #cfd3d8;
}

.diamond-bronze {
  background-color: #ba5e1d;
}

.diamond-other {
  background-color: #f1f2f4;
}

.lb-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #1a202c;
  flex: 1;
  margin-left: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  margin-left: 12px;
  flex-shrink: 0;
}

.lb-top-1 .lb-score-val {
  color: #fcc201;
}

.lb-top-2 .lb-score-val,
.lb-top-3 .lb-score-val,
.lb-top-other .lb-score-val {
  color: #929ba2;
}

.lb-top-1 .lb-name,
.lb-top-2 .lb-name,
.lb-top-3 .lb-name,
.lb-top-other .lb-name {
  color: #1a202c;
}

/* Leaderboard Responsive */
@media (max-width: 600px) {
  .leaderboard-container {
    padding: 24px 20px;
    border-radius: 16px;
    margin-top: 12px;
  }

  .lb-title {
    font-size: 12px;
  }

  .score-submit-controls {
    flex-direction: column;
  }

  .lb-score-row {
    padding: 10px 0;
  }

  .lb-name,
  .lb-score-val {
    font-size: 10px;
  }

  .lb-rank-icon {
    width: 28px;
  }

  .lb-diamond {
    width: 12px;
    height: 12px;
  }
}

/* ============================================
   About Section
   ============================================ */

.about-container {
  max-width: 680px;
  width: 100%;
  margin-top: 24px;
  margin-bottom: 40px;
  background-color: transparent;
  padding: 0 12px;
}

.about-header h2 {
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #2b2b2b;
  margin: 0 0 20px;
  text-align: center;
  letter-spacing: -0.3px;
}

.about-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.about-image-wrapper {
  background-color: #ffffff;
  border: 3px solid #2b2b2b;
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.about-image {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  opacity: 0.9;
}

.about-text {
  width: 100%;
}

.about-text h3 {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #2b2b2b;
  margin: 16px 0 6px;
  text-align: left;
  letter-spacing: -0.2px;
}

.about-text h3:first-child {
  margin-top: 0;
}

.about-text p {
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 400;
  color: #555555;
  line-height: 1.35;
  margin: 0 0 10px;
  text-align: left;
}

.about-text ul {
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 400;
  color: #555555;
  line-height: 1.35;
  margin: 0 0 10px 0;
  padding-left: 24px;
  text-align: left;
}

.about-text li {
  margin-bottom: 4px;
}

.about-text code {
  background-color: #e0e0e0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.about-text strong {
  color: #2b2b2b;
  font-weight: 600;
}

/* FAQ Details */
.about-text details {
  background-color: #ffffff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
  text-align: left;
}

.about-text details:hover {
  border-color: #d0d0d0;
}

.about-text summary {
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  color: #2b2b2b;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.about-text summary::-webkit-details-marker {
  display: none;
}

.about-text summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s ease;
  font-size: 12px;
}

.about-text details[open] summary::before {
  transform: rotate(90deg);
}

.about-text details p {
  padding: 0 16px 16px;
  margin: 0;
  font-size: 14px;
  text-align: center;
}

.about-image-inline {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 8px 0 24px 0;
  display: block;
}

@media (min-width: 600px) {
  .about-content {
    gap: 16px;
  }

  .about-image-wrapper {
    margin-bottom: 8px;
    padding: 20px;
    width: 120px;
    height: 120px;
  }

  .about-image {
    width: 100%;
    height: 100%;
  }

  .about-text {
    max-width: 580px;
  }
}

/* ============================================
   Night Mode (Inverted)
   ============================================ */

body.inverted {
  background-color: #1a1a1a;
}

body.inverted .game-card {
  background-color: #2b2b2b;
  border-color: #555555;
}

body.inverted .game-title {
  color: #f0f0f0;
}

body.inverted .game-subtitle {
  color: #888888;
}

body.inverted .runner-canvas {
  filter: invert(100%);
}

body.inverted .controls-container {
  border-top-color: #444444;
}

body.inverted .controls-text {
  color: #666666;
}

body.inverted .key-dark {
  background-color: #f0f0f0;
  color: #2b2b2b;
}

body.inverted .key-light {
  background-color: #555555;
  color: #999999;
}

/* Leaderboard Night Mode */
body.inverted .leaderboard-container {
  background-color: #2b2b2b;
  border-color: #555555;
}

body.inverted .lb-title {
  color: #f0f0f0;
}


body.inverted .score-submit-inner {
  background-color: #3a3a3a;
  border-color: #555555;
}

body.inverted .your-score-label {
  color: #aaaaaa;
}

body.inverted .your-score-label strong {
  color: #f0f0f0;
}

body.inverted #player-name-input {
  background-color: #2b2b2b;
  border-color: #555555;
  color: #f0f0f0;
}

body.inverted #player-name-input:focus {
  border-color: #f0f0f0;
}

body.inverted #submit-score-btn {
  background-color: #f0f0f0;
  color: #2b2b2b;
}

body.inverted .lb-score-row:nth-child(odd) {
  background-color: #333333;
}

body.inverted .lb-score-row:hover {
  background-color: #3a3a3a;
}

body.inverted .lb-name {
  color: #f0f0f0;
}

body.inverted .lb-score-val {
  color: #f0f0f0;
}

body.inverted .lb-rank {
  color: #777777;
}

body.inverted .lb-top-1 {
  background-color: #3a3520 !important;
}

body.inverted .lb-top-2 {
  background-color: #363636 !important;
}

body.inverted .lb-top-3 {
  background-color: #3a3028 !important;
}

/* About Section Night Mode */
body.inverted .about-header h2 {
  color: #f0f0f0;
}

body.inverted .about-image-wrapper {
  background-color: #2b2b2b;
  border-color: #555555;
}

body.inverted .about-image {
  filter: invert(100%);
}

body.inverted .about-text h3 {
  color: #f0f0f0;
}

body.inverted .about-text p {
  color: #aaaaaa;
}

body.inverted .about-text ul,
body.inverted .about-text li {
  color: #aaaaaa;
}

body.inverted .about-text code {
  background-color: #444444;
  color: #f0f0f0;
}

body.inverted .about-text strong {
  color: #f0f0f0;
}

body.inverted .about-text details {
  background-color: #2b2b2b;
  border-color: #555555;
}

body.inverted .about-text details:hover {
  border-color: #777777;
}

body.inverted .about-text summary {
  color: #f0f0f0;
}