/* File: src/css/style.css */
/* ------------------------------------------------------------
   UNIDROP – Magical Puzzle Game  (Theme V3.3 • 2025-06-22)
   ------------------------------------------------------------ */

/* 1. SETUP & DEFAULTS
   ------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

:root {
  /* --- CORE PALETTE --------------------------------------------------- */
  --panel-bg: #ffffff;
  --board-bg: rgba(71, 35, 122, .2);
  --board-border: rgba(255, 255, 255, .5);

  --primary-text: #6a3a9a;
  --theme-primary-text: #6a3a9a;
  --value-text: #ffffff;

  --header-text: #d96bb2;
  --theme-header-text: #d96bb2;

  --score-popup-color: #ff69b4;

  /* --- BACKGROUND IMAGES --- */
  --theme-bg-image: url('../../assets/images/background.webp');
  --sky-bg-image: url('../../assets/images/main_screen_background.webp');
  --hill-bg-image: url('../../assets/images/green_hills.webp');
  --logo-image: url('../../assets/images/unidrop_logo.webp');
  --cloud-edge: url('../../assets/images/cloud_edge.webp');

  /* --- EFFECT GRADIENTS --- */
  --rainbow-gradient: linear-gradient(45deg, #ffadad, #ffd6a5, #fdffb6, #caffbf, #9bf6ff, #a0c4ff, #bdb2ff);

  /* --- SAFE AREA INSETS (Mobile) --- */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed
}

body {
  background: var(--theme-bg-image) center/cover no-repeat;
  font-family: 'Nunito', sans-serif;
  color: var(--theme-primary-text);
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: background-image .5s;
}

/* 2. LAYOUT MANAGEMENT
   ------------------------------------------------------------ */
.mobile-view {
  display: none
}

.desktop-view {
  display: flex
}

.game-container.desktop-view {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 90vw;
  height: 95vh;
  max-width: 1600px;
  background: rgba(45, 25, 80, .6);
  border: 3px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(10px);
  padding: 20px;
  border-radius: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .1);
  animation: float-in .8s ease-out;
}

@keyframes float-in {
  from {
    transform: translateY(30px);
    opacity: 0
  }

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

.main-content-area {
  display: flex;
  gap: 25px;
  align-items: stretch;
  height: 100%
}

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 280px
}

.sidebar-scroll {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding-right: 10px
}

.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  position: relative
}

.board-and-rows-container {
  display: flex;
  align-items: flex-start;
  gap: 8px
}

.game-board-wrapper {
  position: relative;
  background: var(--board-bg);
  padding: 10px;
  border-radius: 20px;
  border: 2px solid var(--board-border);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, .2);
}

#game-board-desktop,
#game-board-mobile {
  display: block;
  background: transparent;
  border-radius: 15px;
  position: relative
}

.ghost-container,
.effects-layer {
  position: absolute;
  top: 10px;
  left: 10px;
  pointer-events: none
}

.effects-layer {
  z-index: 5
}

/* 3. DESKTOP UI PANELS
   ------------------------------------------------------------ */
.desktop-view .ui-box {
  background: rgba(255, 255, 255, .5);
  backdrop-filter: blur(5px);
  padding: 15px;
  border-radius: 20px;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, .8);
  flex-shrink: 0;
  position: relative;
}

.desktop-view .ui-box .sidebar-h2 {
  font-weight: 900;
  font-size: 1.1em;
  color: var(--theme-header-text);
  text-transform: uppercase;
  margin-bottom: 8px;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, .5);
}

.desktop-view .ui-box .value {
  font-size: 2.5em;
  font-weight: 900;
  color: var(--theme-primary-text);
  text-shadow: 0 0 10px rgba(255, 255, 255, .8);
}

/* Grouping Container for Hold/Next */
.hold-next-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.desktop-view .hold-box,
.desktop-view .next-box {
  flex: 1;
  background: url('../../assets/images/hold_next_bg.webp') center/contain no-repeat;
  border: none;
  height: 90px;
  /* Reduced from 130px */
  background-color: transparent;
  backdrop-filter: none;
  display: flex;
  /* flex for alignment */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 5px;
}

.desktop-view .hold-box .sidebar-h2,
.desktop-view .next-box .sidebar-h2 {
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .2);
  margin-top: -5px;
  font-size: 0.8em;
}

#next-piece-canvas-desktop,
#hold-piece-canvas-desktop {
  max-height: 55px;
  /* Fits within 90px box */
  width: auto;
  display: block;
  margin: 0 auto;
  transform: none;
}

/* Stats Dashboard */
.stats-dashboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px !important;
  /* Force compact padding */
}

.primary-stat {
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 5px;
}

.primary-stat .value {
  font-size: 2.5em;
  /* Keep score big */
  line-height: 1;
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat-mini {
  background: rgba(255, 255, 255, .3);
  padding: 5px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .4);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-mini .label {
  font-size: 0.65em;
  font-weight: 700;
  color: var(--theme-header-text);
  text-transform: uppercase;
  margin-bottom: 0;
}

.stat-mini .value-mini {
  font-size: 1.1em;
  font-weight: 900;
  color: var(--theme-primary-text);
}

/* Obsolete verbose styles removed/overwritten by above */

/* 4. PLAYER PROFILE & SCOREBOARD
   ------------------------------------------------------------ */
.player-profile-box {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px
}

#current-player-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
  flex-shrink: 0;
}

.player-info {
  text-align: left
}

#current-player-name {
  font-size: 1.2em;
  font-weight: 900;
  color: var(--theme-primary-text)
}

.player-progression {
  font-size: .9em;
  font-weight: 700;
  color: var(--primary-text);
  opacity: .8;
  margin: 2px 0 6px
}

#current-player-level {
  font-weight: 900;
  color: var(--theme-header-text)
}

#switch-player-button {
  font-family: 'Nunito', sans-serif;
  font-size: .8em;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 10px;
  border: none;
  background: var(--theme-header-text);
  color: #fff;
  cursor: pointer;
  transition: background .2s;
  margin-top: 4px;
}

@media (hover: hover) {
  #switch-player-button:hover {
    background: #c75a9f
  }
}

.scoreboard-box {
  padding: 10px 15px
}

#scoreboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.scoreboard-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9em;
  padding: 5px;
  border-radius: 8px;
  transition: background-color .2s;
}

.scoreboard-item.current {
  background: rgba(106, 58, 154, .2);
  font-weight: 900
}

.scoreboard-rank {
  font-weight: 900;
  color: var(--theme-header-text);
  width: 20px;
  text-align: right
}

.scoreboard-avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%
}

.scoreboard-name {
  flex-grow: 1;
  color: var(--theme-primary-text);
  text-align: left
}

.scoreboard-score {
  font-weight: 700;
  color: var(--theme-primary-text)
}

/* 5. SWITCH-PROFILE OVERLAY (polished)
   ------------------------------------------------------------ */
#player-profile-overlay .overlay-content,
#scoreboard-overlay .overlay-content {
  width: 95%;
  max-width: 600px;
  padding: 35px 30px 30px;
  border-radius: 30px;
}

.profile-title {
  font-size: 2.2em;
  color: var(--theme-header-text);
  margin-bottom: 10px
}

.profile-subtitle {
  font-size: 1.1em;
  color: var(--theme-primary-text);
  margin-bottom: 20px
}

.player-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.player-list::-webkit-scrollbar {
  width: 6px
}

.player-list::-webkit-scrollbar-thumb {
  background: rgba(106, 58, 154, .4);
  border-radius: 3px
}

.player-item {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(255, 255, 255, .55);
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border .2s, transform .2s, background .2s;
}

@media (hover: hover) {
  .player-item:hover {
    border-color: var(--theme-header-text);
    transform: translateY(-2px)
  }
}

.player-item.active {
  border-color: #ffd700;
  background: rgba(255, 215, 0, .15);
  box-shadow: 0 0 12px rgba(255, 215, 0, .6)
}

.player-item img {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.player-item span {
  font-size: 1.35em;
  font-weight: 900;
  color: var(--theme-primary-text);
  flex-grow: 1;
  text-align: left;
  line-height: 1.1
}

.add-player-section {
  width: 100%;
  display: flex;
  gap: 12px;
  margin-top: 10px
}

#new-player-name-input {
  flex-grow: 1;
  padding: 12px 14px;
  border: 2px solid rgba(0, 0, 0, .15);
  border-radius: 14px;
  font-size: 1em;
}

#add-player-button {
  padding: 12px 20px;
  border-radius: 14px;
  background: linear-gradient(45deg, #8d80e8, #a0c4ff);
  color: #fff;
  border: none;
  font-weight: 900;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}

@media (hover: hover) {
  #add-player-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, .25)
  }
}

.avatar-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 18px 0
}

.avatar-choice {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .2s, border .2s;
}

@media (hover: hover) {
  .avatar-choice:hover {
    transform: scale(1.15)
  }
}

.avatar-choice.selected {
  border-color: #ffd700;
  box-shadow: 0 0 10px #ffd700
}

/* 6. GENERIC OVERLAY FRAME
   ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  overflow: hidden;
  font-weight: 900;
  text-align: center;
  color: var(--theme-primary-text);
}

/* THEMED OVERLAYS (Main Menu, Difficulty, Pause) */
#message-overlay,
#difficulty-overlay,
#pause-overlay {
  background: var(--sky-bg-image) repeat center/240px, rgba(135, 206, 235, 0.4);
  background-blend-mode: normal;
  backdrop-filter: blur(5px);
}

/* FUNCTIONAL OVERLAYS (Profile, Scoreboard) */
#player-profile-overlay,
#scoreboard-overlay {
  background: rgba(255, 203, 237, .55);
  backdrop-filter: blur(10px);
}

/* CLOUD EDGE (top) for themed overlays */
#message-overlay::before,
#difficulty-overlay::before,
#pause-overlay::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 96px;
  background: var(--cloud-edge) repeat-x top center;
  background-size: auto 96px;
  pointer-events: none;
  z-index: 1;
}

/* HILL (bottom) for themed overlays */
#message-overlay::after,
#difficulty-overlay::after,
#pause-overlay::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 120px;
  background: var(--hill-bg-image) repeat-x bottom center;
  background-size: auto 120px;
  pointer-events: none;
  z-index: 1;
}

/* OVERLAY CARD */
.overlay-content {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, .92);
  padding: 40px 40px 50px;
  /* Adjusted padding */
  border-radius: 24px;
  border: 2px solid #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
  max-height: 80vh;
  overflow-y: auto;
}

/* LOGO */
#message-overlay .game-title,
#difficulty-overlay .game-title {
  display: block;
  margin: -20px auto 24px auto;
  /* Pull logo up */
  width: 320px;
  max-width: 80vw;
  height: 168px;
  background: var(--logo-image) center/contain no-repeat;
  text-indent: -9999px;
  /* Hide text */
}

/* SUBTITLE & BUTTONS */
.subtitle {
  font-size: 1.25em;
  font-weight: 900;
  color: #6234c7;
  margin-bottom: 30px
}

.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 460px
}

.difficulty-options button {
  padding: 20px 40px;
  /* Adjusted padding */
  border-radius: 50px;
  border: 3px solid #fff;
  font-size: 1.35em;
  font-weight: 900;
  text-transform: uppercase;
  color: #fff;
  box-shadow: 0 8px 0px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, .18);
  /* Added bottom edge for 3D effect */
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}

@media (hover: hover) {
  .difficulty-options button:hover {
    transform: translateY(-3px);
    box-shadow: 0 11px 0px rgba(0, 0, 0, 0.15), 0 12px 28px rgba(0, 0, 0, .25)
  }
}

.difficulty-options button:active {
  transform: translateY(2px);
  box-shadow: 0 6px 0px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, .20)
}

button[data-difficulty="easy"] {
  background: linear-gradient(180deg, #4ed6ff 0%, #2ca8ff 100%)
}

button[data-difficulty="normal"] {
  background: linear-gradient(180deg, #73a4ff 0%, #426aff 100%)
}

button[data-difficulty="hard"] {
  background: linear-gradient(180deg, #c095ff 0%, #8e5cff 100%)
}

.difficulty-options button p {
  font-size: .55em;
  font-weight: 600;
  opacity: .9;
  margin-top: 6px;
  text-transform: none;
  /* Keep description sentence case */
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  width: 100%
}

.button-row button {
  flex: 1;
  padding: 16px;
  border-radius: 50px;
  border: none;
  background: linear-gradient(45deg, #ff80c0, #ffa6e0);
  color: #fff;
  font-weight: 900;
  font-size: .85em;
  text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(255, 128, 192, .35);
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}

@media (hover: hover) {
  .button-row button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(255, 128, 192, .5)
  }
}

/* 7. PAUSE-SPECIFIC OVERLAY
   ------------------------------------------------------------ */
#resume-game-button,
#quit-game-button,
#close-player-profile-button,
#close-scoreboard-button {
  font-family: 'Nunito', sans-serif;
  font-size: 1.1em;
  font-weight: 900;
  text-transform: uppercase;
  padding: 18px 40px;
  border-radius: 50px;
  border: 2px solid white;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  width: 80%;
  max-width: 400px;
  margin: 8px 0;
}

#resume-game-button:active,
#quit-game-button:active,
#close-player-profile-button:active,
#close-scoreboard-button:active {
  transform: translateY(2px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

@media (hover: hover) {

  #resume-game-button:hover,
  #quit-game-button:hover,
  #close-player-profile-button:hover,
  #close-scoreboard-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.25);
  }
}

#resume-game-button {
  background: linear-gradient(180deg, #6bff81 0%, #34c759 100%);
}

#quit-game-button {
  background: linear-gradient(180deg, #ff8a8a 0%, #ff5252 100%);
}

#close-player-profile-button,
#close-scoreboard-button {
  background: linear-gradient(180deg, #a0c4ff 0%, #8d80e8 100%);
  width: auto;
  max-width: none;
  margin-top: 20px;
  padding-left: 50px;
  padding-right: 50px;
}

#pause-overlay .overlay-content {
  width: 90%;
  max-width: 500px;
  padding-bottom: 30px;
}

#pause-overlay .profile-title {
  font-size: 2.5em;
  color: var(--theme-header-text);
  margin-bottom: 25px;
  margin-top: 20px;
}

#pause-overlay .separator {
  height: 2px;
  background-color: rgba(106, 58, 154, 0.15);
  width: 80%;
  margin: 25px 0;
}

#pause-overlay .profile-subtitle {
  margin: 0 0 15px 0;
}

#pause-overlay .difficulty-options {
  flex-direction: row;
  gap: 15px;
  width: 100%;
  margin-bottom: 20px;
}

#pause-overlay .difficulty-options button {
  flex: 1;
  padding: 18px 10px;
  font-size: 1em;
}

#pause-overlay .difficulty-options button p {
  display: none;
}

#pause-overlay .button-row {
  margin-bottom: 25px;
}

/* 8. NOTIFICATIONS / PARTICLES / MISC
   ------------------------------------------------------------ */
#notification-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none
}

.feedback-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
  border-radius: 20px
}

.line-clear-effect,
.column-clear-effect {
  background: var(--rainbow-gradient);
  box-shadow: 0 0 20px 10px #fff;
  animation: sparkle-out .6s ease-out forwards
}

.line-clear-effect {
  position: absolute;
  left: 0;
  width: 100%
}

.column-clear-effect {
  position: absolute;
  top: 0;
  height: 100%
}

@keyframes sparkle-out {
  from {
    transform: scale(0);
    opacity: 1
  }

  to {
    transform: scale(1.5);
    opacity: 0
  }
}

.perfect-sum-notification,
.level-up-notification,
.challenge-notification {
  text-align: center;
  min-width: 300px;
  pointer-events: all
}

.perfect-sum-notification {
  background: var(--rainbow-gradient);
  color: #fff;
  padding: 20px 35px;
  border-radius: 50px;
  font-size: 1.4em;
  font-weight: 900;
  animation: magicPop 2.5s ease-out forwards;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .1);
  text-transform: uppercase;
  letter-spacing: 2px
}

.level-up-notification {
  background: linear-gradient(45deg, #ffd700, #ff9ff3);
  color: #fff;
  padding: 20px 40px;
  border-radius: 50px;
  font-size: 1.8em;
  font-weight: 900;
  animation: magicPop 3s ease-out forwards;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  text-transform: uppercase;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, .3);
  letter-spacing: 2px;
  border: 3px solid #fff
}

@keyframes magicPop {
  0% {
    transform: scale(0);
    opacity: 0
  }

  15%,
  85% {
    transform: scale(1.1);
    opacity: 1
  }

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

.score-popup {
  position: absolute;
  color: var(--score-popup-color);
  font-size: 1.5em;
  font-weight: 900;
  pointer-events: none;
  animation: scoreFloat 1.5s ease-out forwards;
  text-shadow: 0 0 10px #fff
}

@keyframes scoreFloat {
  0% {
    transform: translateY(0) scale(.5);
    opacity: 0
  }

  20% {
    transform: translateY(-20px) scale(1.2);
    opacity: 1
  }

  100% {
    transform: translateY(-100px) scale(.8);
    opacity: 0
  }
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--rainbow-gradient);
  background-size: 300%;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFly 1s ease-out forwards;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%)
}

@keyframes particleFly {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(0) rotate(360deg);
    opacity: 0
  }
}

.sound-toggle {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, .5);
  border: 2px solid #fff;
  color: var(--theme-primary-text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  transition: all .3s ease;
  z-index: 10
}

.sound-toggle:hover {
  transform: scale(1.1);
  background: #fff
}

.sound-toggle.muted {
  opacity: .6
}

.high-score-indicator {
  position: absolute;
  top: -15px;
  right: 10px;
  background: linear-gradient(45deg, #ffd93d, #ff6b6b);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .8em;
  font-weight: 900;
  animation: highScoreBounce 2s ease-in-out infinite;
  box-shadow: 0 4px 15px rgba(255, 107, 107, .5)
}

@keyframes highScoreBounce {

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

  50% {
    transform: translateY(-4px) scale(1.05)
  }
}

/* 9. RESPONSIVE & MOBILE
   ------------------------------------------------------------ */
@media (max-width:820px),
(max-height:600px) {
  .desktop-view {
    display: none
  }

  .mobile-view {
    display: block;
    position: fixed;
    inset: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--theme-bg-image)
  }

  .mobile-top-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 11;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 50px;
    padding: 0 5px
  }

  .mobile-ui-element {
    background: rgba(0, 0, 0, .3);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 6px;
    color: #fff;
    transition: opacity .3s, transform .3s;
    opacity: .9;
    display: flex;
    align-items: center;
    justify-content: center
  }

  .mobile-board-fullscreen {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 70px
  }

  .mobile-board-wrapper {
    position: relative;
    background: var(--board-bg);
    padding: 10px;
    border-radius: 20px;
    border: 2px solid var(--board-border);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, .2);
    display: inline-block;
    line-height: 0
  }

  #mobile-score-level {
    text-align: center;
    font-weight: 900;
    font-size: .9em;
    min-width: 60px
  }

  #mobile-score {
    font-size: 1em;
    line-height: 1.1
  }

  #mobile-level {
    font-size: .8em;
    color: #ffd93d;
    line-height: 1.1
  }

  #mobile-next-overlay,
  #mobile-hold-overlay {
    width: 44px;
    height: 44px;
    padding: 4px
  }

  #next-piece-canvas-mobile,
  #hold-piece-canvas-mobile {
    width: 100%;
    height: 100%
  }

  .mobile-menu-btn {
    width: 44px;
    height: 44px;
    background: var(--theme-header-text);
    /* Use theme color instead of gray */
    background-image: linear-gradient(135deg, var(--theme-header-text), #ff69b4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: none;
    color: #fff;
    border-radius: 12px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
  }

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

  .overlay {
    border-radius: 0
  }

  .overlay-content {
    width: 90%;
    padding: 20px
  }

  #pause-overlay .difficulty-options {
    flex-direction: column
  }

  .game-title {
    font-size: 2.5em
  }

  .subtitle {
    font-size: 1em
  }

  .difficulty-options button {
    font-size: 1em;
    padding: 15px 30px
  }

  .mobile-controls-bottom,
  .mobile-layout {
    display: none
  }
}

/* 10. CHALLENGE NOTIFICATION
   ------------------------------------------------------------ */
#challenge-notification-desktop,
#challenge-notification-mobile {
  display: none
}

.challenge-notification {
  background: linear-gradient(45deg, #ff6b6b, #feca57);
  color: #fff;
  padding: 10px 25px;
  border-radius: 50px;
  font-size: 1.2em;
  font-weight: 900;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, .2);
  box-shadow: 0 5px 20px rgba(255, 107, 107, .4);
  animation: fadeInThenOut 4s ease-in-out forwards
}

@keyframes fadeInThenOut {
  0% {
    opacity: 0;
    transform: translateY(-20px)
  }

  15% {
    opacity: 1;
    transform: translateY(0)
  }

  85% {
    opacity: 1;
    transform: translateY(0)
  }

  100% {
    opacity: 0;
    transform: translateY(20px)
  }
}

/* 11. LANDSCAPE MOBILE
   ------------------------------------------------------------ */
.landscape-mode .mobile-view {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 10px
}

.landscape-mode .mobile-top-bar {
  display: none
}

.landscape-mode .mobile-board-fullscreen {
  padding-top: 0;
  flex-grow: 1;
  height: 100%
}

.mobile-landscape-sidebar {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100px;
  align-items: center;
  justify-content: center;
  height: 100%
}

.landscape-mode #mobile-score-level {
  flex-direction: column;
  width: 80px;
  height: 80px;
  font-size: 1.1em
}

.landscape-mode #mobile-hold-overlay,
.landscape-mode #mobile-next-overlay,
.landscape-mode .mobile-menu-btn {
  width: 80px;
  height: 80px;
  margin: 0
}

.landscape-mode .mobile-menu-btn {
  border-radius: 12px
}

/* 12. CANVAS RENDERING
   ------------------------------------------------------------ */
canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges
}


/* Fix Mobile Gestures */
canvas {
  touch-action: none;
}

/* 13. CONTROLS OVERLAY
   ------------------------------------------------------------ */
.controls-content {
  overflow-y: auto;
  max-height: 80vh;
  justify-content: flex-start;
  padding-bottom: 20px;
}

.controls-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 20px;
}

.control-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.4);
  padding: 10px 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.control-label {
  font-weight: 900;
  color: var(--theme-primary-text);
  font-size: 1.1em;
}

.control-key-btn {
  background: linear-gradient(135deg, #a0c4ff, #8d80e8);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 900;
  cursor: pointer;
  min-width: 80px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
  transition: transform 0.1s, box-shadow 0.1s;
}

.control-key-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.control-key-btn.remapping {
  background: linear-gradient(135deg, #ff6b6b, #ff4757);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

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

.secondary-button {
  background: transparent;
  border: 2px solid var(--theme-primary-text);
  color: var(--theme-primary-text);
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  font-size: 0.9em;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.profile-close-button {
  display: block;
  margin: 20px auto 0;
  padding: 10px 40px;
  background: #ff6b6b;
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 1.1em;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.profile-close-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(255, 107, 107, 0.5);
}

.profile-close-button:active {
  transform: translateY(1px);
}