@font-face {
  font-family: 'Futura Condensed';
  src: url('Futura condensed.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-game: 'Futura Condensed', 'Fira Sans Condensed', sans-serif;
  --font-ui: 'Futura Condensed', 'Outfit', sans-serif;
  --top-bar-offset: 4rem;
  --dock-offset: calc(5.5rem + env(safe-area-inset-bottom));
}

/* Keep the inline outline icons visually consistent with the lighter UI. */
#game-board-wrapper svg[fill="none"] {
  shape-rendering: geometricPrecision;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Use Arabic-capable fonts when the document direction is RTL (Arabic) */
html[dir="rtl"] {
  --font-ui: 'Futura Condensed', 'Outfit', 'Noto Sans Arabic', 'Segoe UI', 'Tahoma', sans-serif;
  --font-game: 'Futura Condensed', 'Fira Sans Condensed', 'Noto Sans Arabic', 'Segoe UI', 'Tahoma', sans-serif;

  /* Right-align text by default so Arabic reads naturally */
  body {
    text-align: right;
  }

  /* Reverse decorative icon offsets that were tuned for LTR */
  .life-fly-heart {
    margin-left: 0;
    margin-right: -0.85rem;
  }

  .life-fly-heart-buy {
    margin-left: 0;
    margin-right: -0.725rem;
  }

  /* Keep numeric score / TPS readouts left-to-right even in Arabic (RTL) so
     the digits and decimal point are never mirrored or reordered. */
  #score-display,
  #tps-display-normal,
  #tps-display-challenge,
  #best-display,
  #life-count,
  #life-timer,
  #p-points-display,
  #revive-countdown-ring-text,
  .score-digit-wrapper {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
  }

  /* Challenges screen: pin the Play button and the Best TPS readout into the
     left corner under RTL so they mirror the LTR right-hand placement.
     Force the order explicitly because automatic flex mirroring is unreliable
     here: badge on the right, content in the middle, action (Play + Best TPS)
     on the left. */
  .challenge-card.song-card {
    flex-direction: row;
  }

  .challenge-card .song-card-badge {
    order: 3;
  }

  .challenge-card .song-card-content {
    order: 2;
  }

  .challenge-card .song-card-action {
    order: 1;
    align-items: flex-start;
    margin-left: 0;
    margin-right: auto;
  }

  .challenge-card .best-score-display {
    text-align: left;
  }

  /* Results screen RTL: mirror TPS/LAPS positioning and flip back arrow */
  html[dir="rtl"] #results-tps {
    right: calc(50% - 160px);
    left: auto;
  }

  html[dir="rtl"] #results-laps {
    left: calc(50% - 160px);
    right: auto;
  }

  html[dir="rtl"] #results-home-btn svg {
    transform: scaleX(-1);
  }
}


body {
  font-family: var(--font-ui);
  background-color: #f3f4f6;
  /* Light gray background around the board */
  color: #111827;
  overflow: hidden;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0px 3px 0px rgba(128, 128, 128, 0.1);
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* Dark Mode: a slate palette that keeps the game's colorful actions prominent. */
html.dark-mode {
  color-scheme: dark;
}

html.dark-mode body {
  background-color: #000000;
  color: #e5e7eb;
}

html.dark-mode .bg-white,
html.dark-mode .bg-white\/95,
html.dark-mode .bg-white\/90,
html.dark-mode .bg-white\/80,
html.dark-mode .bg-white\/70,
html.dark-mode .bg-gray-50,
html.dark-mode .bg-gray-100 {
  background-color: #0a0a0a !important;
}

html.dark-mode .bg-gray-200,
html.dark-mode .bg-gray-200\/80 {
  background-color: #111111 !important;
}

html.dark-mode .text-gray-900,
html.dark-mode .text-gray-800,
html.dark-mode .text-gray-700 {
  color: #f3f4f6 !important;
}

html.dark-mode .text-gray-600,
html.dark-mode .text-gray-500,
html.dark-mode .text-gray-400,
html.dark-mode .text-slate-600,
html.dark-mode .text-slate-500 {
  color: #b7c2d3 !important;
}

html.dark-mode .border-gray-100,
html.dark-mode .border-gray-200,
html.dark-mode .border-gray-300,
html.dark-mode .border-white\/50,
html.dark-mode .border-white\/60 {
  border-color: #1a1a1a !important;
}

html.dark-mode .hover\:bg-gray-50:hover,
html.dark-mode .hover\:bg-gray-100:hover,
html.dark-mode .hover\:bg-gray-200:hover {
  background-color: #111111 !important;
}

html.dark-mode .glass-dark,
html.dark-mode #game-board-wrapper {
  background: #000000;
  border-color: #1a1a1a;
}

html.dark-mode .glass {
  background: rgba(0, 0, 0, 0.88);
  border-color: #1a1a1a;
}

html.dark-mode .col-element {
  border-color: rgba(255, 255, 255, 0.15);
}

html.dark-mode #gameplay-info-bar,
html.dark-mode #results-screen,
html.dark-mode .song-card,
html.dark-mode .life-modal-panel,
html.dark-mode .revive-modal-panel,
html.dark-mode .class-pass-fail-item {
  background: #0a0a0a !important;
  color: #e5e7eb;
}

html.dark-mode .gameplay-info-row,
html.dark-mode .gameplay-info-icon,
html.dark-mode .song-card-title,
html.dark-mode #results-screen {
  color: #f3f4f6;
}

html.dark-mode .song-card-artist,
html.dark-mode .class-song-list {
  color: #b7c2d3;
}

html.dark-mode .dock-button:not(.selected) > div {
  background-color: #0a0a0a;
}

html.dark-mode #shared-dock > div,
html.dark-mode #welcome-actions {
  background: rgba(0, 0, 0, 0.94) !important;
}

html.dark-mode .song-of-the-day-card {
  background: linear-gradient(135deg, #312e81 0%, #4c1d95 100%) !important;
}

html.dark-mode .song-of-the-day-card h3 {
  color: #f3f4f6 !important;
}

html.dark-mode #welcome-disc {
  background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
}

html.dark-mode .revive-modal-header {
  background: linear-gradient(180deg, #4c1d1d 0%, #3f1717 100%);
}

html.dark-mode .revive-modal-ring::before {
  background: radial-gradient(circle at top left, #111111 0%, #0a0a0a 60%);
}

html.dark-mode .revive-progress-row,
html.dark-mode .revive-status-row,
html.dark-mode .revive-cancel-btn,
html.dark-mode .language-option.selected,
html.dark-mode .class-item,
html.dark-mode .class-item.bg-kaidan,
html.dark-mode .class-item.bg-grey {
  background: #111111 !important;
  border-color: #2a2a2a;
  color: #e5e7eb;
}

html.dark-mode .revive-modal-title,
html.dark-mode .revive-status-value,
html.dark-mode .revive-modal-ring-text {
  color: #ffffff;
}

html.dark-mode .revive-modal-subtitle,
html.dark-mode .revive-progress-label,
html.dark-mode .revive-status-label {
  color: #b7c2d3;
}

html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
  background-color: #050505 !important;
  color: #e5e7eb !important;
  border-color: #1a1a1a !important;
}

html.dark-mode .tile-clicked {
  background-color: #1a1a1a !important;
  border-color: #2a2a2a !important;
}

html.dark-mode .pause-screen {
  background: rgba(0, 0, 0, 0.88);
}

html.dark-mode .pause-screen-title {
  color: #f3f4f6;
}

/* Tablet layout: stretch tilefield to full screen width */
@media (min-width: 768px) and (max-width: 1060px) {
  #game-board-wrapper {
    width: 100% !important;
    max-width: none !important;
  }

  /* Larger score on tablet */
  #score-display {
    font-size: 9rem !important;
  }

  /* Larger score on tablet; normal TPS stays smaller than score */
  #tps-display-normal {
    font-size: 3.5rem !important;
  }

  #tps-display-challenge {
    font-size: 9rem !important;
  }

  /* Softer shadow for score/TPS on tablet */
  #score-display,
  #tps-display-challenge {
    text-shadow: 0px 7px 0px rgba(0.5, 0.5, 0.5, 0.5) !important;
  }

  /* Larger start/combo tile labels on tablet */
  .tile-start-label-at-head {
    font-size: 3rem !important;
    line-height: 0.95;
  }

  .combo-badge {
    font-size: clamp(4.3rem, 15vh, 7rem) !important;
  }

  /* Increase all UI elements by 60% for tablet */
  .dock-button>div {
    width: 64px !important;
    height: 64px !important;
  }

  .dock-button>div svg {
    width: 38.4px !important;
    height: 38.4px !important;
  }

  .dock-button span {
    font-size: 17.6px !important;
  }

  .screen-top-bar {
    padding: 1.6rem !important;
  }

  .screen-top-bar-user {
    transform: scale(1.6);
    transform-origin: left center;
  }

  .screen-top-bar-stats {
    transform: scale(1.6);
    transform-origin: right center;
  }

  .song-card {
    padding: 32px !important;
    min-height: 192px !important;
  }

  .song-card-title {
    font-size: 28.8px !important;
  }

  .song-card-artist {
    font-size: 16px !important;
  }

  .btn-play {
    font-size: 17.6px !important;
    padding: 12.8px 51.2px !important;
  }

  #welcome-card {
    padding: 9.6px !important;
    min-height: 320px !important;
  }

  #welcome-disc {
    width: 102.4px !important;
    height: 102.4px !important;
  }

  #welcome-disc svg {
    width: 51.2px !important;
    height: 51.2px !important;
  }

  #welcome-song-title {
    font-size: 32px !important;
  }

  #welcome-play-btn {
    font-size: 17.6px !important;
    padding: 12.8px 51.2px !important;
  }

  .challenge-card {
    padding: 32px !important;
    min-height: 192px !important;
  }

  .challenge-card .song-card-title {
    font-size: 28.8px !important;
  }

  .heart-button svg {
    width: 38.4px !important;
    height: 38.4px !important;
  }

  .key-hint {
    font-size: 17.6px !important;
    padding: 4px 4px !important;
  }

  .pause-screen-title {
    font-size: 3.2rem !important;
  }

  .pause-screen-btn {
    font-size: 2.4rem !important;
    padding: 1.36rem 2rem !important;
  }

  #shared-dock>div {
    padding-bottom: calc(1.2rem + env(safe-area-inset-bottom)) !important;
  }

  #shared-dock>div {
    padding: 4.8rem !important;
  }

  :root {
    --dock-offset: calc(15rem + env(safe-area-inset-bottom));
  }

  /* Enlarged results screen UI elements for tablet */
  #results-song-title {
    font-size: 32px !important;
  }

  #results-medals {
    padding: 19.2px !important;
    border-radius: 19.2px !important;
  }

  #results-medals img {
    width: 129.6px !important;
    height: auto !important;
  }

  #results-tps {
    font-size: 32px !important;
    left: calc(50% - 256px) !important;
  }

  #results-score {
    font-size: 9.6rem !important;
  }

  #results-subtext {
    font-size: 32px !important;
  }

  #results-laps {
    font-size: 28.8px !important;
    right: calc(50% - 256px) !important;
  }

  /* Results screen RTL adjustments inside tablet layout */
  html[dir="rtl"] #results-tps {
    right: calc(50% - 256px) !important;
    left: auto !important;
  }

  html[dir="rtl"] #results-laps {
    left: calc(50% - 256px) !important;
    right: auto !important;
  }

  .results-dock {
    padding: 19.2px !important;
  }

  .results-dock-btn {
    width: 89.6px !important;
    height: 78.4px !important;
    border-radius: 22.4px !important;
  }

  .results-dock-btn svg {
    width: 38.4px !important;
    height: 38.4px !important;
  }

  .results-dock-center {
    border-radius: 38.4px !important;
    padding: 19.2px 38.4px !important;
    font-size: 28.8px !important;
  }

  .results-dock-center svg {
    width: 38.4px !important;
    height: 38.4px !important;
  }

  /* Full width top bar on tablet */
  .screen-top-bar {
    max-width: none !important;
  }

  /* Full width results dock on tablet */
  .results-dock {
    max-width: none !important;
  }
}

/* Smaller score on mobile and PC */
@media (max-width: 767px),
(min-width: 1061px) {
  #score-display {
    font-size: 4rem !important;
  }

  /* Smaller TPS on mobile and PC; normal TPS remains smaller than score */
  #tps-display-normal {
    font-size: 1.5rem !important;
  }

  #tps-display-challenge {
    font-size: 4rem !important;
  }

  /* Darker shadow for score and challenge TPS on mobile and PC */
  #score-display,
  #tps-display-challenge {
    text-shadow: 0px 3px 0px rgba(0, 0, 0, 0.4) !important;
  }
}

/* Screen top bar base styles */
.screen-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  background: transparent;
  box-shadow: none;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.screen-top-bar-left,
.screen-top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.screen-top-bar-left {
  flex: 1 1 auto;
  max-width: calc(100% - 220px);
  min-width: 0;
}

.screen-top-bar-right {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.screen-top-bar-box {
  background: rgba(107, 114, 128, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  min-height: 2.2rem;
  height: 100%;
  flex: 0 0 auto;
}

.screen-top-bar-entry {
  min-width: max-content;
}

.screen-top-bar-profile {
  width: auto;
  min-width: 0;
  justify-content: flex-start;
  padding: 0.35rem 0.55rem;
  height: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-display-trigger {
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: inherit;
  transition: transform 140ms ease, filter 140ms ease;
}

.profile-display-trigger:hover {
  filter: brightness(1.03);
}

.profile-display-trigger:active {
  transform: scale(0.98);
}

.screen-top-bar-profile-inner {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Loading Screen Styles */
#loading-screen {
  display: flex;
}

#loading-screen.hidden {
  display: none;
}

/* Home screen specific styles */
#home-screen {
  display: none;
  text-shadow: none;
}

/* Push main screen contents down to make space for the shared top bar */
#start-screen,
#song-list-screen,
#challenges-screen,
#home-screen,
#results-screen,
#gameover-screen {
  padding-top: var(--top-bar-offset);
}

/* Reserve space above the shared bottom dock on tab screens */
#home-screen,
#song-list-screen,
#challenges-screen {
  padding-bottom: var(--dock-offset);
  box-sizing: border-box;
}

#home-content-container,
#song-list-container,
#challenges-container {
  padding-bottom: 1rem;
}

#settings-screen .settings-scroll-panel {
  padding-top: var(--top-bar-offset);
  padding-bottom: calc(var(--dock-offset) + 1rem);
}

#song-list-container {
  padding-bottom: 4.5rem;
}

#song-search-bar {
  bottom: calc(var(--dock-offset) + 0.75rem);
}

.screen-top-bar-points {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  width: 100%;
}

.screen-top-bar-text {
  display: block;
  white-space: nowrap;
  color: #ffffff;
}

#p-points-display {
  display: block;
  width: 100%;
  text-align: right;
}

.screen-top-bar-box,
.screen-top-bar-box:has(img) {
  align-items: stretch;
}

.screen-top-bar-right .screen-top-bar-box {
  align-items: center;
  height: 100%;
}

.life-display,
.life-display-trigger:not(.screen-top-bar-box) {
  display: inline-flex;
  align-items: center;
  position: relative;
  gap: 0.35rem;
  min-width: 6.2rem;
  padding: 0.15rem 0.45rem 0.2rem 0.2rem;
  border-radius: 9999px;
  background: linear-gradient(180deg, rgba(108, 198, 236, 0.96), rgba(70, 170, 214, 0.96));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 6px rgba(21, 94, 117, 0.22);
}

.life-display-trigger {
  border: none;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.screen-top-bar-right .life-display-trigger {
  gap: 0.35rem;
  min-width: 0;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(107, 114, 128, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.life-display-trigger:hover {
  filter: brightness(1.03);
}

.life-display-trigger:active {
  transform: scale(0.98);
}

.life-fly-heart {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 120;
  width: 1.7rem;
  height: 1.7rem;
  margin-left: -0.85rem;
  margin-top: -0.85rem;
  border-radius: 9999px;
  background: #ef5350;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0.98;
  transform: translate(0, 0) scale(1);
  will-change: transform, opacity;
}

.life-fly-heart svg {
  width: 100%;
  height: 100%;
  fill: #fff;
}

.life-fly-heart.is-animating {
  transition-property: transform, opacity;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1), ease-out;
}

.life-fly-heart-buy {
  width: 1.45rem;
  height: 1.45rem;
  margin-left: -0.725rem;
  margin-top: -0.725rem;
}

.life-display-icon,
.life-pack-heart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: #ef5350;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
}

.life-display-icon svg,
.life-pack-heart svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: #fff;
}

.life-display-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}

.life-display-main {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 0;
  padding-right: 0.05rem;
}

.life-display-count,
.life-display-plus {
  font-family: var(--font-game);
  line-height: 1;
  text-shadow: none;
}

.life-display-count {
  font-size: 2rem;
}

.life-display-plus {
  font-size: 1.8rem;
  font-weight: 700;
}

.life-display-timer {
  margin-top: -0.08rem;
  padding: 0.08rem 0.5rem 0.12rem;
  border-radius: 9999px;
  background: rgba(11, 81, 116, 0.42);
  font-family: var(--font-game);
  font-size: 1.15rem;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  text-shadow: none;
}

.screen-top-bar-right .life-display-icon {
  width: 1.25rem;
  height: 1.25rem;
  background: transparent;
  box-shadow: none;
}

.screen-top-bar-right .life-display-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: #ef5350;
}

.screen-top-bar-right .life-display-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.screen-top-bar-right .life-display-main {
  justify-content: flex-start;
  padding-right: 0;
}

.screen-top-bar-right .life-display-count {
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 700;
  color: #fca5a5;
}

.screen-top-bar-right .life-display-plus {
  display: none;
}

.screen-top-bar-right .life-display-timer {
  display: block;
  margin-top: 0.05rem;
  padding: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  color: #f3f4f6;
}

.life-modal {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}

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

.life-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(1px);
}

.life-modal-panel {
  position: relative;
  width: min(100%, 24rem);
  max-height: calc(100dvh - 2.4rem);
  overflow: auto;
  border-radius: 1.4rem;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.32);
}

.life-modal-header {
  position: relative;
  padding: 1rem 1rem 0.85rem;
  border-radius: 1.4rem 1.4rem 0 0;
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.life-modal-title {
  margin: 0;
  padding-right: 2.5rem;
  font-family: var(--font-game);
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  font-weight: 500;
  line-height: 1.05;
  text-align: center;
  text-shadow: none;
}

.life-modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.6rem;
  height: 2.6rem;
  border: 0.18rem solid #fff;
  border-radius: 9999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.life-modal-close svg {
  width: 1.45rem;
  height: 1.45rem;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
}

.life-modal-status {
  display: flex;
  justify-content: center;
}

.life-modal-status-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.life-display-large {
  min-width: 0;
  padding: 0.15rem 0.55rem 0.2rem 0.18rem;
  gap: 0.4rem;
}

.life-display-large .life-display-icon {
  width: 2rem;
  height: 2rem;
}

.life-display-large .life-display-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

.life-display-large .life-display-count {
  font-size: 2rem;
  color: #fff1f2;
}

.life-display-large .life-display-timer {
  font-size: 0.9rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}

.life-display-counter-only {
  width: auto;
}

.life-display-counter-only .life-display-body {
  min-width: 0;
}

.life-display-counter-only .life-display-main {
  justify-content: flex-start;
}

.life-modal-timer-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.7rem;
  padding: 0.18rem 0.7rem 0.22rem;
  border-radius: 9999px;
  background: rgba(127, 29, 29, 0.42);
  color: #fff;
  font-family: var(--font-game);
  font-size: 0.9rem;
  line-height: 1;
  text-align: center;
  text-shadow: none;
}

.life-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 0.75rem 0.9rem;
}

.life-purchase-row {
  position: relative;
  display: block;
  width: 100%;
  min-height: 2.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.life-purchase-pack,
.life-purchase-cost {
  min-height: 2.9rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.life-purchase-pack {
  position: relative;
  z-index: 1;
  background: #d8e8f4;
  padding: 0.45rem 0.8rem;
  gap: 0.55rem;
  width: 100%;
  justify-content: flex-start;
}

.life-purchase-cost {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 9rem;
  min-width: 7.5rem;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background: #43abda;
  color: #fff;
}

.life-pack-icons {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 2.15rem;
  height: 1.55rem;
}

.life-pack-icons .life-pack-heart {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.45rem;
  height: 1.45rem;
  transform: translateY(-50%);
}

.life-pack-icons-1 .life-pack-heart:nth-child(1) {
  left: 0;
}

.life-pack-icons-3 .life-pack-heart:nth-child(1) {
  left: 0;
}

.life-pack-icons-3 .life-pack-heart:nth-child(2) {
  left: 0.72rem;
}

.life-pack-icons-3 .life-pack-heart:nth-child(3) {
  left: 1.44rem;
}

.life-pack-icons-5 .life-pack-heart:nth-child(1) {
  left: 0;
}

.life-pack-icons-5 .life-pack-heart:nth-child(2) {
  left: 0.58rem;
}

.life-pack-icons-5 .life-pack-heart:nth-child(3) {
  left: 1.16rem;
}

.life-pack-icons-5 .life-pack-heart:nth-child(4) {
  left: 1.74rem;
}

.life-pack-icons-5 .life-pack-heart:nth-child(5) {
  left: 2.32rem;
}

.life-pack-icons-3 {
  min-width: 2.95rem;
}

.life-pack-icons-5 {
  min-width: 3.5rem;
}

.life-purchase-qty,
.life-purchase-price,
.life-note-icon {
  font-family: var(--font-game);
  line-height: 1;
  text-shadow: none;
}

.life-purchase-qty {
  color: #234869;
  font-size: clamp(1.25rem, 5vw, 2rem);
}

/* Allow the browser to interpolate --revive-progress as a <percentage>
   so the conic-gradient ring animates smoothly between JS updates. */
@property --revive-progress {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 100%;
}

.revive-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  pointer-events: none;
}

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

.revive-modal>.revive-modal-backdrop,
.revive-modal>.revive-modal-panel {
  pointer-events: auto;
}

.revive-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(1.2px);
}

.revive-modal-panel {
  position: relative;
  width: min(100%, 26rem);
  border-radius: 1.6rem;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.28);
}

.revive-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 11rem;
  background: linear-gradient(180deg, #ffe4e4 0%, #ffd0d0 100%);
}

.revive-modal-ring {
  --revive-progress: 100%;
  --revive-ring-color: #ef4444;
  position: relative;
  width: 8.2rem;
  height: 8.2rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  box-sizing: border-box;
  background: conic-gradient(var(--revive-ring-color) var(--revive-progress), rgba(239, 68, 68, 0.15) 0);
  transition: --revive-progress 1s linear;
}

.revive-modal-ring::before {
  content: '';
  position: absolute;
  inset: 0.5rem;
  border-radius: 9999px;
  background: radial-gradient(circle at top left, #fff8f8 0%, #ffe4e4 60%);
}

.revive-modal-ring.revive-ring-warning {
  --revive-ring-color: #b91c1c;
}

.revive-modal-ring-text {
  position: relative;
  z-index: 1;
  font-family: var(--font-game);
  font-size: clamp(2.6rem, 7vw, 3.4rem);
  font-weight: 800;
  color: #0f172a;
}

.revive-modal-body {
  padding: 1.6rem 1.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.revive-countdown-text {
  font-family: var(--font-game);
  text-align: center;
  color: #1e3a8a;
  font-size: 1rem;
  font-weight: 700;
}

.revive-progress-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: #f8fafc;
  border-radius: 1.2rem;
}

.revive-progress-label {
  text-align: center;
  color: #475569;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.revive-progress-value {
  color: #ff6b6b;
  font-size: 1.15rem;
  font-weight: 800;
}

.revive-progress-icons {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.revive-progress-icon {
  width: 1.9rem;
  height: auto;
  opacity: 0.35;
  filter: grayscale(100%);
}

.revive-progress-icon.filled {
  opacity: 1;
  filter: none;
}

.revive-modal-title {
  margin: 0;
  font-family: var(--font-game);
  font-size: clamp(1.75rem, 5vw, 2.4rem);
  font-weight: 800;
  text-align: center;
  color: #111827;
}

.revive-modal-subtitle {
  margin: 0;
  text-align: center;
  color: #475569;
  font-size: 0.95rem;
}

.revive-status-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: #eff6ff;
  border-radius: 1.2rem;
}

.revive-status-icon {
  width: 3rem;
  height: 3rem;
}

.revive-status-label {
  color: #64748b;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.revive-status-value {
  margin-top: 0.2rem;
  font-family: var(--font-game);
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

.revive-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.revive-modal-btn {
  border: none;
  border-radius: 9999px;
  padding: 1rem 1rem;
  font-family: var(--font-game);
  font-weight: 700;
  cursor: pointer;
}

.revive-cancel-btn {
  background: #e2e8f0;
  color: #0f172a;
}

.revive-continue-btn {
  background: #ef4444;
  color: #ffffff;
}


.life-note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 9999px;
  background: #fbbf24;
  color: #fff;
  font-size: 1rem;
}

.life-purchase-price {
  font-size: clamp(1.15rem, 4.8vw, 1.9rem);
}

.life-purchase-row:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.life-purchase-row:disabled .life-purchase-cost {
  background: #fca5a5;
}

@media (max-width: 767px) {

  .life-display-trigger,
  .life-display {
    min-width: 5.45rem;
    padding-right: 0.3rem;
  }

  .life-display-icon {
    width: 1.75rem;
    height: 1.75rem;
  }

  .life-display-icon svg {
    width: 1rem;
    height: 1rem;
  }

  .life-display-count {
    font-size: 1.65rem;
  }

  .life-display-plus {
    font-size: 1.45rem;
  }

  .life-display-timer {
    font-size: 0.95rem;
  }

  .screen-top-bar-right .life-display-trigger {
    min-width: 0;
    padding: 0.3rem 0.55rem;
  }

  .screen-top-bar-right .life-display-icon,
  .screen-top-bar-right .life-display-icon svg {
    width: 1.15rem;
    height: 1.15rem;
  }

  .screen-top-bar-right .life-display-count {
    font-size: 0.875rem;
  }

  .screen-top-bar-right .life-display-timer {
    font-size: 0.56rem;
  }

  .life-modal-title {
    font-size: clamp(1.8rem, 10vw, 2.8rem);
  }

  .life-modal-close {
    width: 2.4rem;
    height: 2.4rem;
  }

  .life-purchase-row {
    min-height: 2.9rem;
  }

  .life-purchase-cost {
    width: 7.5rem;
    min-width: 7.5rem;
  }
}

.tile-start-label {
  z-index: 12;
  pointer-events: none;
}

.tile-start-label-at-head {
  align-items: flex-end;
  justify-content: center;
  font-size: 2.8rem;
  line-height: 1;
  z-index: 13;
}

/* Pause overlay sits above tiles, effects, and HUD */
.pause-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(243, 244, 246, 0.85);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

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

.pause-screen-title {
  font-family: var(--font-game);
  font-size: clamp(2rem, 6vh, 2.75rem);
  font-weight: 700;
  color: #000;
  margin: 0 0 1.75rem;
  text-align: center;
  letter-spacing: 0.02em;
}

.pause-screen-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: min(88%, 22rem);
}

.pause-screen-btn {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 9999px;
  background: #ef4444;
  color: #fff;
  font-family: var(--font-game);
  font-size: clamp(1.35rem, 4.5vh, 2rem);
  font-weight: 500;
  line-height: 1.1;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.15s;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.pause-screen-btn:hover {
  background: #dc2626;
}

.pause-screen-btn:active {
  transform: scale(0.97);
}

/* Pause button styling - hidden by default, shown during gameplay */
#pause-btn {
  display: none;
  z-index: 45;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Hide pause button on screens wider than 1060px */
@media (min-width: 1061px) {
  #pause-btn {
    display: none !important;
  }
}

/* Class to hide keyboard hints */
.key-hints-hidden {
  opacity: 0 !important;
}

#pause-btn.force-show {
  display: flex !important;
}

.font-game {
  font-family: var(--font-game);
}

/* Board columns: thin lines separating columns */
.col-element {
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.col-element:last-child {
  border-right: none;
}

/* The gameplay board must always lay out left-to-right (physical columns 0..3)
   and must never be mirrored by the RTL language setting, otherwise touch/mouse
   input would be flipped relative to what the player sees. Force LTR on the
   board and its containers regardless of the document direction. */
#game-board-wrapper,
#game-board,
#tiles-container,
.col-element {
  direction: ltr;
}

/* Song and challenge cards keep their internal content laid out left-to-right
   (title, artist, progress, action) regardless of the Arabic RTL setting. */
.song-card,
.challenge-card {
  direction: ltr;
}

/* Pre-game info bar: white one-tile-height area at the bottom, shown only before
   the game starts. It overlays the bottom of the board and is hidden on start. */
#gameplay-info-bar {
  font-family: inherit;
}

.gameplay-info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #374151;
  font-size: 1.95rem;
  font-weight: 600;
  line-height: 1.25;
}

.gameplay-info-icon {
  width: 1.875rem;
  height: 1.875rem;
  flex-shrink: 0;
  color: #374151;
}

.gameplay-info-label {
  font-weight: 600;
}

/* Glassmorphism utility for white theme */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.glass-dark {
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.game-playing {
  position: relative;
  overflow: hidden;
  background-color: #111827;
  /* Base background kept as a paint-order fallback; the two crossfade layers
     below (::before / ::after) are what actually render the level images. */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-image: url('gameImage/bgani_01.png');
}

/* Dedicated pre-rendered GPU background layers for smooth, zero-lag level crossfades */
.game-bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #111827;
  pointer-events: none;
  transition: opacity 300ms ease-out;
  transform: translateZ(0);
  will-change: opacity;
}

.low-performance-mode .game-bg-layer {
  transition: none !important;
}

.game-playing>* {
  position: relative;
  z-index: 1;
}

.game-playing>.revive-modal {
  position: fixed !important;
  z-index: 100000 !important;
}

.game-playing>.pause-screen {
  position: fixed !important;
  z-index: 9999 !important;
  isolation: isolate;
}

/* Low performance mode favors a stable frame time over decorative animation. */
.low-performance-mode .game-playing::before,
.low-performance-mode .game-playing::after {
  transition: none;
}

.low-performance-mode .tile-image-layer {
  filter: none !important;
}

.low-performance-mode .animate-pulse-slow,
.low-performance-mode .blink-three-times,
.low-performance-mode .flash-error {
  animation: none !important;
}

/* Long tile hold visual effects */
.hold-effect-container {
  position: absolute;
  pointer-events: none;
  z-index: 16;
}

.hold-circle {
  position: absolute;
  width: 60px;
  height: 60px;
  background-image: url('gameImage/circle_light.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  animation: hold-circle-expand 0.25s ease-out forwards;
}

.hold-dot {
  position: absolute;
  width: 40px;
  height: 40px;
  background-image: url('gameImage/dot_light.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: hold-dot-shrink 0.25s ease-out forwards;
}

@keyframes hold-circle-expand {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.9;
  }

  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

@keyframes hold-dot-shrink {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
}

/* Animations without hit flash */
@keyframes pulse-slow {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 0.4;
  }
}

.animate-pulse-slow {
  animation: pulse-slow 3s infinite;
}

/* Tile clicked state (turns light gray/transparent without flash animation) */
.tile-clicked {
  background-color: #f3f4f6 !important;
  border-top: 1px solid #e5e7eb !important;
  border-bottom: 1px solid #e5e7eb !important;
}

/* Error animation for game over */
@keyframes flash-error {
  0% {
    background-color: rgba(239, 68, 68, 0.9);
  }

  100% {
    background-color: rgba(239, 68, 68, 0.4);
  }
}

.flash-error {
  animation: flash-error 0.5s ease-out forwards;
}

/* Blink animation for missed tile - blinks 3 times */
@keyframes blink-three-times {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.15;
  }
}

.blink-three-times {
  animation: blink-three-times 0.5s ease-in-out 3 !important;
}

/* Column flash animation for wrong press - bright red at tile height */
@keyframes column-flash-red {

  0%,
  100% {
    background-color: transparent;
  }

  50% {
    background-color: rgba(255, 0, 0, 0.7);
  }
}

.column-flash-red {
  animation: column-flash-red 0.5s ease-in-out 3;
}

/* Settings pill styling */
.settings-pill {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.settings-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.keyboard-nav-selected {
  position: relative;
  border-radius: 1.5rem;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.95), 0 14px 28px -18px rgba(37, 99, 235, 0.7);
  transform: translateY(-1px);
  transition: box-shadow 140ms ease, transform 140ms ease;
}

.keyboard-nav-selected.song-card,
.keyboard-nav-selected.class-item {
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.96), rgba(219, 234, 254, 0.96));
}

.keyboard-nav-selected.settings-pill,
.keyboard-nav-selected#welcome-play-btn,
.keyboard-nav-selected.results-dock-center {
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.98), rgba(219, 234, 254, 0.98));
}

html.dark-mode .keyboard-nav-selected {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.95), 0 14px 28px -18px rgba(30, 64, 175, 0.72);
}

html.dark-mode .keyboard-nav-selected.song-card,
html.dark-mode .keyboard-nav-selected.class-item,
html.dark-mode .keyboard-nav-selected.settings-pill,
html.dark-mode .keyboard-nav-selected#welcome-play-btn,
html.dark-mode .keyboard-nav-selected.results-dock-center {
  background: rgba(30, 41, 59, 0.96) !important;
}

/* Modal backdrop */
#keybinds-modal-backdrop,
#speed-modal-backdrop,
#language-modal-backdrop {
  cursor: pointer;
}

/* Language option styling */
.language-option {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.language-option:hover {
  border-color: #6366f1;
}

.language-option.selected {
  border-color: #6366f1;
  background-color: #eef2ff;
}

.language-option.selected .language-check {
  display: block;
}

/* Soundfont option styling */
.soundfont-option {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.soundfont-option:hover {
  border-color: #6366f1;
}

.soundfont-option.selected {
  border-color: #6366f1;
  background-color: #eef2ff;
}

.soundfont-option.selected .soundfont-check {
  display: block;
}

/* Long/Hold note styling */
.tile-long {
  border-bottom: none !important;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
  position: absolute;
  width: 25%;
  z-index: 5;
  overflow: visible;
  /* Allow the dome/cue to be visible if outside */
}

/* Thin vertical red line down the middle of the long note */
.tile-long-line {
  position: absolute;
  left: calc(50% - 0.75px);
  width: 1.5px;
  background-color: #ff3b30;
  box-shadow: 0 0 5px rgba(255, 59, 48, 0.8);
  opacity: 0.85;
  z-index: 6;
}

/* Active holding state - red glowing gradient overlay */
.tile-holding {
  box-shadow: inset 0 0 25px rgba(239, 68, 68, 0.8), 0 0 15px rgba(239, 68, 68, 0.5) !important;
  opacity: 0.9;
}

.tile-holding::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(239, 68, 68, 0.4), rgba(239, 68, 68, 0.1));
  pointer-events: none;
  animation: hold-pulse 1s infinite alternate;
  z-index: 7;
}

@keyframes hold-pulse {
  from {
    opacity: 0.6;
  }

  to {
    opacity: 1.0;
  }
}

/* Curved-top dome area for hold note */
.tile-hold-dome {
  position: absolute;
  left: 0;
  width: 100%;
  height: 12%;
  /* percentage of screen/board height */
  background: #ff1a1a;
  /* Solid red matching the curve color */
  border-radius: 50% 50% 0 0 / 25% 25% 0 0;
  /* Significantly flattened curved top */
  box-shadow: 0 -4px 15px rgba(255, 26, 26, 0.9);
  pointer-events: none;
  z-index: 8;
}

/* Red ring cue for Piano Tiles 2 hold start - just a red circle with nothing inside it */
.red-ring-cue {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 32px;
  height: 32px;
  border: 3.5px solid #ff3b30;
  border-radius: 50%;
  background-color: transparent;
  /* transparent inside */
  box-shadow: 0 0 8px rgba(255, 59, 48, 0.6);
  pointer-events: none;
  z-index: 10;
}

/* Combo/multi-tap note */
.tile-combo {
  height: 50%;
  box-sizing: content-box;
}

.combo-badge {
  font-family: var(--font-game);
  font-weight: 500;
  font-size: clamp(3.25rem, 13vh, 5.5rem);
  line-height: 1;
  color: #ffffff;
  background-color: transparent;
  border: none;
  border-radius: 0;
  min-width: 80px;
  min-height: 80px;
  padding: 0.15em 0.25em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
}

.combo-badge-pop {
  animation: combo-badge-pop 0.08s ease-out;
}

@keyframes combo-badge-pop {
  0% {
    transform: translateX(-50%) scale(0.9);
  }

  50% {
    transform: translateX(-50%) scale(1.1);
  }

  100% {
    transform: translateX(-50%) scale(1);
  }
}

.tile-combo.combo-hit-pulse {
  animation: combo-tile-pulse 0.15s ease-out;
}

@keyframes combo-tile-pulse {

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

  50% {
    filter: brightness(1.3);
    transform: scale(1.1);
  }
}

/* Hit ripple on successful tap */
.hit-ripple {
  position: absolute;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  margin-top: -36px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  pointer-events: none;
  animation: hit-ripple-spread 0.45s ease-out forwards;
}

/* Bigger ripple for combo tile taps */
.hit-ripple-combo {
  width: 130px;
  height: 130px;
  margin-left: -65px;
  margin-top: -65px;
  border: 3.5px solid rgba(255, 200, 80, 0.95);
  animation: hit-ripple-combo-spread 0.5s ease-out forwards;
}

@keyframes hit-ripple-combo-spread {
  0% {
    transform: scale(0.25);
    opacity: 1;
  }

  100% {
    transform: scale(2.6);
    opacity: 0;
  }
}

.combo-plus-one {
  position: absolute;
  font-family: var(--font-game);
  font-weight: 400;
  font-size: clamp(2.5rem, 9vw, 3.5rem);
  line-height: 1;
  color: #ffffff;
  text-shadow: none;
  pointer-events: none;
  z-index: 12;
  transform: translate(-50%, -50%);
  animation: combo-plus-one-float 0.6s ease-out forwards;
}

.long-tile-score-popup {
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translate(-50%, -100%);
  font-family: var(--font-game);
  font-weight: 400;
  font-size: clamp(3rem, 10vw, 4rem);
  line-height: 1;
  color: #ef4444;
  text-shadow: none;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  animation: long-tile-score-popup-fade 0.5s ease-out forwards;
}

@keyframes long-tile-score-popup-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, -100%) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1.05);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -100%) scale(0.95);
  }
}



@keyframes combo-plus-one-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.75);
  }

  30% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -110%) scale(1.05);
  }
}

@keyframes hit-ripple-spread {
  0% {
    transform: scale(0.35);
    opacity: 0.95;
  }

  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

@keyframes pop-bounce {
  0% {
    transform: scale(0.8);
  }

  70% {
    transform: scale(1.15);
  }

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

/* Grade dynamic background & text styling */
.grade-E {
  background-color: #2318cf !important;
  color: #ffffff !important;
}

.grade-D {
  background-color: #0073ff !important;
  color: #ffffff !important;
}

.grade-D-plus {
  background-color: #48cbfb !important;
  color: #1e293b !important;
}

.grade-C {
  background-color: #9aeab7 !important;
  color: #1e293b !important;
}

.grade-C-plus {
  background-color: #cfe9bd !important;
  color: #1e293b !important;
}

.grade-B {
  background-color: #fff094 !important;
  color: #1e293b !important;
}

.grade-B-plus {
  background-color: #ffd83b !important;
  color: #1e293b !important;
}

.grade-A {
  background-color: #ffcb91 !important;
  color: #1e293b !important;
}

.grade-A-plus {
  background-color: #ff92b4 !important;
  color: #1e293b !important;
}

.grade-AA {
  background-color: #b39ee6 !important;
  color: #ffffff !important;
}

.grade-AA-plus {
  background-color: #bd6ae6 !important;
  color: #ffffff !important;
}

.grade-AAA {
  background-color: #a200e6 !important;
  color: #ffffff !important;
}

/* Results screen adjustments */
#results-medals {
  padding: 12px;
  /* add breathing room around stars/crowns */
  border-radius: 12px;
}

/* Center the main results score using absolute coordinates */
#results-main-score {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 60;
}

/* Keep TPS and Laps readable when score is centered */
#results-tps {
  position: absolute;
  left: calc(50% - 160px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
}

#results-laps {
  position: absolute;
  right: calc(50% - 160px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
}

/* Score increment pop animation (0.3s) */
@keyframes score-pop {
  0% {
    transform: scale(0.88);
    opacity: 0;
  }

  60% {
    transform: scale(1.08);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.score-increment {
  animation: score-pop 0.3s cubic-bezier(.2, .9, .3, 1) both;
  transform-origin: center;
}

/* Medal pop (staggered delays applied via inline style) */
@keyframes result-pop {
  0% {
    transform: scale(0.25);
    opacity: 0;
  }

  70% {
    transform: scale(1.06);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.result-medal {
  width: 3rem;
  height: auto;
  transform-origin: center;
  animation-name: result-pop;
  animation-duration: 0.45s;
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(.2, .9, .3, 1);
}

/* removed combined rule so silhouette styling is consistent and non-animated */

/* Results screen styles (white background, top-bar inherits .screen-top-bar) */
#results-screen {
  background: #ffffff;
  color: #111827;
  /* dark text */
}

#results-screen .results-content {
  transform: translateY(-10px);
}

#results-screen .results-rank {
  letter-spacing: 0.12em;
}

#results-screen #results-score {
  font-size: clamp(3rem, 12vw, 6rem);
  line-height: 0.9;
}

#results-screen #results-subtext {
  font-weight: 700;
}

#results-screen #results-medals img {
  width: 81px;
  /* 50% bigger */
  height: auto;
}

/* silhouette for unearned medals */
.medal-silhouette {
  width: 3rem;
  height: auto;
  /* fully desaturated, flat grey silhouette with no shadows */
  filter: grayscale(100%) brightness(0.75) saturate(0%);
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
  opacity: 1 !important;
}

/* push song title down slightly from top bar */
#results-song-title {
  margin-top: 60px;
  text-align: center;
}

#results-screen .screen-top-bar-text {
  color: #111827 !important;
}

#results-screen button {
  cursor: pointer;
}

/* Results dock (bottom) */
.results-dock {
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.results-dock-btn {
  border-radius: 14px;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.results-dock-center {
  border-radius: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Dock fixed to bottom of results screen */
#results-screen .results-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(6px + env(safe-area-inset-bottom));
  margin-left: auto;
  margin-right: auto;
  width: min(100%, 520px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  /* restore inner padding to match reference */
}

#results-screen .results-dock-btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.grade-AAA-plus {
  background-color: #4d4d73 !important;
  color: #ffffff !important;
}

.grade-S {
  background-color: #252554 !important;
  color: #ffffff !important;
}

.grade-SS {
  background-color: #161c47 !important;
  color: #ffffff !important;
}

.grade-SSS {
  background-color: #0f266c !important;
  color: #ffffff !important;
}

.grade-P {
  background-color: #0c154a !important;
  color: #ffffff !important;
}

.grade-M {
  background-color: #2d2d2d !important;
  color: #ffffff !important;
}

.grade-GM {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
}

.grade-PM {
  background-color: #000000 !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6) !important;
  outline: 1px solid #ffffff !important;
}

/* Star animation styles */
@keyframes star-pop-in {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.star-pop-animation {
  animation: star-pop-in 0.4s ease-out forwards;
}

@keyframes star-slide-left {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-30%);
  }
}

@keyframes star-slide-right {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(30%);
  }
}

.star-slide-left {
  animation: star-slide-left 0.3s ease-out forwards;
}

.star-slide-right {
  animation: star-slide-right 0.3s ease-out forwards;
}

@keyframes fade-out {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

.fade-out {
  animation: fade-out 0.2s ease-out forwards;
}

.fade-in {
  animation: fade-in 0.2s ease-out forwards;
}

/* Floating score popup above tiles */
@keyframes score-float-up {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translateY(-30px) scale(1.1);
    opacity: 0;
  }
}

.score-popup {
  position: absolute;
  font-family: var(--font-game);
  font-weight: 500;
  font-size: 1.5rem;
  color: #ff6b6b;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 25;
  animation: score-float-up 0.8s ease-out forwards;
  white-space: nowrap;
}

/* Long-tile completion popup: bigger pop-out then fade up */
@keyframes score-long-pop {
  0% {
    transform: translateX(-50%) translateY(0) scale(0.6);
    opacity: 0;
  }

  25% {
    transform: translateX(-50%) translateY(-10px) scale(1.35);
    opacity: 1;
  }

  60% {
    transform: translateX(-50%) translateY(-18px) scale(1.1);
    opacity: 1;
  }

  100% {
    transform: translateX(-50%) translateY(-48px) scale(0.9);
    opacity: 0;
  }
}

.score-popup-long {
  position: absolute;
  font-family: var(--font-game);
  font-weight: 500;
  font-size: 2rem;
  color: #ffd700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 26;
  animation: score-long-pop 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}


/* Star and Crown animation display styling */
#star-animation-display {
  color: #ffd700 !important;
  /* Yellow color for stars */
  transform: translateY(10px);
}

#crown-animation-display {
  color: #ffd700 !important;
  /* Yellow color for crowns */
  transform: translateY(10px);
}

/* Score digit wrapper for consistent positioning */
.score-digit-wrapper {
  display: inline-block;
  text-align: center;
  font-variant-numeric: tabular-nums;
  /* Ensures consistent width for all digits */
  min-width: 0.2em;
  /* Minimal width to prevent layout shifts when digits change */
  vertical-align: baseline;
  /* Maintains proper alignment with text */
  margin: 0;
  padding: 0;
  /* No extra spacing that could interfere with animations */
  line-height: 1;
  /* Tight line height to prevent vertical shifts */
}

/* Song card styling */
.song-card {
  background: white;
  border-radius: 16px;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.1s, box-shadow 0.1s;
  cursor: pointer;
  padding: 12px 16px;
  gap: 16px;
  min-height: 120px;
  user-select: none;
  position: relative;
}

.song-card:active {
  transform: scale(0.98);
}

.song-card-icon {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateY(-33px);
  margin-left: -4px;
}

/* For ranked songs (medal) */
.song-card-icon.ranked .rank-icon-image {
  width: 36px;
  height: 32px;
}


.song-card-icon.ranked.purple .rank-icon-image {
  width: 36px;
  height: 32px;
}

.song-card-icon.ranked .rank-number {
  position: absolute;
  color: white;
  font-weight: normal;
  font-size: 0.9rem;
  text-shadow: none;
}

/* For regular numbered songs */
.song-card-icon.numbered {
  background-color: #ef4444;
  border-radius: 50%;
  color: white;
  font-weight: normal;
  font-size: 1.1rem;
}

.song-card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.song-card-title {
  font-family: var(--font-game);
  font-weight: 500;
  font-size: 1.5rem;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  text-shadow: none;
}

.song-card-artist {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: #9ca3af;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: none;
}

.song-card-progress {
  display: flex;
  align-items: center;
  gap: 0px;
  margin-top: 6px;
}

.song-card-progress img {
  width: 32px;
  height: auto;
  box-shadow: none;
}

.song-card-progress .earned {
  color: #fbbf24;
}

.song-card-progress .unearned {
  color: #e5e7eb;
  filter: grayscale(100%);
  opacity: 0.3;
}

.song-card-action {
  position: absolute;
  bottom: 12px;
  right: 12px;
}

.btn-play {
  background: #ef4444;
  /* red */
  color: white;
  font-weight: bold;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  padding: 8px 32px;
  border-radius: 9999px;
  /* pill shape */
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(56, 189, 248, 0.3);
  transition: transform 0.1s;
}

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

.btn-load {
  background: #6366f1;
  /* indigo */
  color: white;
  font-weight: bold;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  padding: 8px 32px;
  border-radius: 9999px;
  /* pill shape */
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
  transition: transform 0.1s;
}

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

.btn-load:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Header bar styling for song list screen */
#song-list-screen>div:first-child {
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

#player-name-display {
  min-width: 100px;
  transition: all 0.2s ease;
}

#player-name-text {
  font-size: 1.25rem;
}

#player-name-display:hover {
  transform: scale(1.05);
}

#player-name-display:active {
  transform: scale(0.95);
}

#p-points-display {
  min-width: 100px;
}

#total-crowns,
#total-stars {
  min-width: 30px;
  text-align: center;
}

/* Dock button selected state styling */
.dock-button.selected>div {
  background-color: var(--selected-color, #ec4899);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px -8px rgba(15, 23, 42, 0.22);
}

.dock-button.keyboard-tab-selected>div {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.9), 0 10px 18px -8px rgba(15, 23, 42, 0.24);
}

html.dark-mode .dock-button.keyboard-tab-selected>div {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.92), 0 10px 18px -8px rgba(15, 23, 42, 0.32);
}

.dock-button.selected>div svg {
  color: white !important;
}

.dock-button:not(.selected)>div {
  background-color: #ffffff;
}

.dock-button>div {
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.dock-button:hover>div {
  transform: translateY(-1px);
}

.dock-button[data-color="blue"]:not(.selected)>div svg {
  color: #3b82f6 !important;
}

.dock-button[data-color="pink"]:not(.selected)>div svg {
  color: #ec4899 !important;
}

.dock-button[data-color="purple"]:not(.selected)>div svg {
  color: #a855f7 !important;
}

.dock-button[data-color="green"]:not(.selected)>div svg {
  color: #22c55e !important;
}

.dock-button[data-color="red"]:not(.selected)>div svg {
  color: #ef4444 !important;
}

/* Color mapping for dock buttons */
.dock-button[data-color="blue"] {
  --selected-color: #3b82f6;
}

.dock-button[data-color="pink"] {
  --selected-color: #ec4899;
}

.dock-button[data-color="purple"] {
  --selected-color: #a855f7;
}

.dock-button[data-color="green"] {
  --selected-color: #22c55e;
}

.dock-button[data-color="red"] {
  --selected-color: #ef4444;
}

/* Home screen specific styles */
#home-screen {
  display: none;
  text-shadow: none;
}

#home-screen:not(.hidden) {
  display: flex;
}

/* Home screen layout */
#home-content-container {
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  scrollbar-gutter: stable both-edges;
}

#home-content-container>* {
  width: 100%;
  box-sizing: border-box;
}

/* Welcome card styling */
#welcome-disc {
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
  border: none;
  transition: transform 0.1s ease-out, width 0.2s ease, height 0.2s ease;
  width: var(--welcome-disc-size) !important;
  height: var(--welcome-disc-size) !important;
  max-width: 100%;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#welcome-card {
  --welcome-card-padding: 1.5rem;
  --welcome-card-min-height: 25rem;
  --welcome-disc-size: clamp(8rem, 46vw, 14rem);
  position: relative;
  z-index: 1;
  text-shadow: none;
  overflow: visible;
  box-sizing: border-box;
  padding: var(--welcome-card-padding) var(--welcome-card-padding) 0;
  min-height: var(--welcome-card-min-height);
  margin-bottom: -1rem;
  transition: padding 0.2s ease, min-height 0.2s ease, box-shadow 0.2s ease;
}

#welcome-actions {
  --welcome-title-size: 2rem;
  --welcome-button-padding: 0.75rem 2rem;
  --welcome-button-font-size: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
  position: sticky;
  top: 0;
  z-index: 5;
  margin-top: 1rem;
  padding: 0.5rem 0 1rem;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: padding 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

#welcome-actions.is-stuck {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

@media (max-width: 640px) {
  #welcome-card {
    --welcome-card-padding: 1rem;
    min-height: auto;
    margin-bottom: -0.75rem;
  }

  #welcome-actions {
    margin-top: 0.75rem;
  }

  #welcome-disc {
    width: clamp(7rem, 60vw, 12rem) !important;
    height: clamp(7rem, 60vw, 12rem) !important;
  }
}

#welcome-card h3:not(#welcome-song-title) {
  text-shadow: none;
}

#welcome-song-title {
  font-size: var(--welcome-title-size);
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: font-size 0.2s ease;
}

#welcome-play-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.3);
  padding: var(--welcome-button-padding);
  font-size: var(--welcome-button-font-size);
  transition: padding 0.2s ease, font-size 0.2s ease, transform 0.2s ease;
}

#welcome-play-btn:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

/* Heart button styling */
.heart-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: transform 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: none;
}

.heart-button:hover {
  background-color: rgba(239, 68, 68, 0.1);
  transform: scale(1.1);
}

.heart-button:active {
  transform: scale(0.95);
}

.heart-button svg {
  width: 24px;
  height: 24px;
  transition: fill 0.2s, stroke 0.2s;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.heart-button.favourite svg {
  fill: #ef4444;
  color: #ef4444;
  stroke: #ef4444;
}

.heart-button:not(.favourite) svg {
  fill: none;
  color: #9ca3af;
  stroke: currentColor;
}

/* Home screen dock button selected state override */
#home-dock-btn.selected>div {
  background-color: #3b82f6;
}

#home-dock-btn.selected>div svg {
  color: white !important;
}

#music-dock-btn.selected>div {
  background-color: #ec4899;
}

#music-dock-btn.selected>div svg {
  color: white !important;
}

/* Music tab dock button selected state override */
#music-dock-home-btn.selected>div {
  background-color: #3b82f6;
}

#music-dock-home-btn.selected>div svg {
  color: white !important;
}

#music-dock-music-btn.selected>div {
  background-color: #ec4899;
}

#music-dock-music-btn.selected>div svg {
  color: white !important;
}

/* Remove text shadow from all dock buttons */
.dock-button {
  text-shadow: none;
}

.dock-button span {
  text-shadow: none;
}

#shared-dock {
  pointer-events: auto;
}

#shared-dock>div {
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
}

@media (max-width: 767px) {
  #shared-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
  }

  #shared-dock>div {
    border-radius: 1.25rem 1.25rem 0 0;
    margin: 0 auto;
    max-width: none;
  }
}

/* Challenge card specific styles */
.challenge-card {
  min-height: 180px;
  padding: 20px;
  align-items: center;
  gap: 16px;
}

.song-card-badge {
  flex-shrink: 0;
  width: 144px;
  height: 144px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: -30px;
}

.challenge-badge-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.challenge-card .song-card-artist {
  color: #a855f7;
  font-weight: 600;
}

.challenge-card .song-card-title {
  font-size: 1.8rem;
}

.challenge-card .song-card-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.challenge-card .best-score-display {
  font-size: 0.9rem;
  font-weight: 600;
  color: #a855f7;
  text-align: right;
}

/* Class Mode Styles */
.class-item {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border-radius: 0.75rem;
  background-color: #f3f4f6;
  /* default bg */
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #e5e7eb;
}

.class-item:active {
  transform: scale(0.98);
}

.class-item.bg-kaidan {
  background-color: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.class-item.bg-grey {
  background-color: #e5e7eb;
  border-color: #d1d5db;
}

.class-item-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.class-song-list {
  font-size: 0.9rem;
  color: #4b5563;
  padding-left: 1rem;
  border-left: 2px solid rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.class-pass-fail-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  background: white;
  border-radius: 0.5rem;
  font-weight: 600;
}

.class-pass {
  color: #16a34a;
}

.class-fail {
  color: #dc2626;
}

/* Responsive top bar on small devices */
@media (max-width: 420px) {
  .screen-top-bar {
    gap: 0.25rem;
    padding: 0.4rem 0.2rem;
  }

  .screen-top-bar-left,
  .screen-top-bar-right {
    gap: 0.25rem;
  }

  .screen-top-bar-box {
    padding: 0.2rem 0.3rem;
  }

  .screen-top-bar-right .life-display-trigger {
    padding: 0.2rem 0.3rem;
  }

  .screen-top-bar-profile-inner {
    gap: 0.25rem;
  }

  .screen-top-bar-left {
    max-width: calc(100% - 150px);
  }

  #player-name-text {
    font-size: 0.75rem;
  }

  #class-highest-cleared {
    font-size: 0.55rem;
  }

  #p-points-display {
    font-size: 0.9rem;
  }

  #total-crowns,
  #total-stars,
  #life-count,
  .life-display-timer {
    font-size: 0.75rem;
  }

  .screen-top-bar-right .life-display-icon svg {
    width: 1rem;
    height: 1rem;
  }

  .screen-top-bar-box img {
    width: 1rem;
    height: auto;
  }
}

/* ─── Performance: compositor-layer isolation for gameplay ─────────────────
   These are updated every RAF tick; promoting them avoids re-painting the
   rest of the page on every frame.                                          */
#tiles-container {
  /* Containment: nothing inside affects outside layout/paint, which lets
     the browser skip expensive cross-tree checks on every style mutation. */
  contain: layout style;
  /* Promote to a composited layer so tile position changes don't trigger
     main-thread layout or paint for the rest of the page. */
  will-change: transform;
}

#hit-effects {
  contain: layout style;
  will-change: transform;
}

/* ─── Static styles for tile child layers set once at creation ─────────────
   Replaces per-frame JS style writes for properties that never change.      */
.tile-image-layer {
  position: absolute;
  left: 0;
  right: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
  display: none;
}

/* Tile start label base styles — dynamic parts (display, height, bottom,
   inset) are still applied via JS only when the state actually changes.    */
.tile-start-label {
  justify-content: center;
  font-family: var(--font-game);
  font-weight: 500;
  font-size: 2.8rem;
  color: #ffffff;
  letter-spacing: 0.1em;
  display: none;
  position: absolute;
  inset: 0;
  height: auto;
  align-items: center;
}

/* When the label is anchored to the long-tile head, only dynamic overrides
   (left/right/top/bottom/height/fontSize) are set via JS.                 */
.tile-start-label-at-head {
  inset: auto;
}

/* ─── Background Animation System Styles ─────────────────────────────────── */
#game-bg-anim-container {
  contain: layout style;
  pointer-events: none;
  overflow: hidden;
}

.bg-anim-item {
  position: absolute;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform, opacity;
  backface-visibility: hidden;
  object-fit: contain;
}

/* ─── Background Intensity Filter Style ──────────────────────────────────── */
#game-bg-intensity-overlay {
  contain: layout style;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(236, 72, 153, 0.8) 0%, rgba(219, 39, 119, 0.9) 65%, rgba(157, 23, 77, 0.95) 100%);
  opacity: 0;
  transition: opacity 0.2s ease-out;
  will-change: opacity;
}


