/* I changed the color-scheme because of the notch on ios ) : */
:root {
  color-scheme: dark;
  --bg: #0b0b10;
  --fg: #f3f3f3;
  --muted: #b7b7c2;
  --accent: #ff9f1c;
  --panel: rgba(12, 12, 18, 0.85);
  --pause-text-dim: #8a861d;
  --pause-text-hot: #ffe84d;
  --pause-text-shadow: #242100;
}

* {
  box-sizing: border-box;
}

/* iOS standalone: black background prevents white flash on load and sets notch/safe-area color */
html {
  height: 100%;
  background-color: #000;
}

body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 20% 10%, #1b1b28, #09090d 60%, #050508 100%);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--fg);
}

body.gameplay-active {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#hud-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 6;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  --joystick-scale: 1;
}

.touch-controls.active {
  pointer-events: auto;
}

.touch-controls.preview {
  inset: auto;
  left: 16px;
  bottom: 16px;
  width: min(46vw, 240px);
  height: min(46vw, 240px);
  pointer-events: auto;
  z-index: 11;
}

.touch-controls.hidden {
  display: none;
}

.touch-controls .joystick {
  position: absolute;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%) scale(var(--joystick-scale));
  pointer-events: none;
}

.touch-controls .joystick.hidden {
  display: none;
}

.touch-controls.preview .joystick {
  left: 50%;
  top: 50%;
  pointer-events: auto;
}

.touch-controls .joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
}

.touch-controls .joystick-handle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(255, 159, 28, 0.65);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.stage-fade {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 333ms linear;
  z-index: 8;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  z-index: 10;
  padding: 16px;
}

.overlay.hidden {
  display: none;
}

.overlay.pause-menu-active {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
}

.overlay.pause-menu-active .menu-actions {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 20;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(460px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

#gamepad-calibration-map {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 12, 0.6);
  display: block;
  margin: 0 auto 12px;
}

.hidden {
  display: none !important;
}

.panel {
  width: min(560px, 94vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#main-menu {
  position: relative;
  padding-bottom: 48px;
}

.menu-version {
  position: absolute;
  right: 18px;
  bottom: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1;
  color: rgba(183, 183, 194, 0.92);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: text;
}

#replay-library-menu {
  width: min(1024px, 96vw);
}

#settings-menu {
  width: min(760px, 96vw);
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0.3px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.panel p {
  margin: 0 0 16px;
  color: var(--muted);
}

.pause-menu-panel {
  width: min(440px, 92vw);
  max-height: calc(100vh - 32px);
  padding: 12px;
  border-radius: 0;
  border: 2px solid rgba(255, 233, 120, 0.68);
  background:
    linear-gradient(180deg, rgba(24, 22, 12, 0.94), rgba(14, 12, 5, 0.96)),
    radial-gradient(240px 120px at 20% 0%, rgba(255, 224, 96, 0.2), rgba(255, 224, 96, 0));
  box-shadow:
    0 0 0 2px rgba(84, 70, 20, 0.75) inset,
    0 16px 42px rgba(0, 0, 0, 0.62);
  animation: smb1-pause-enter 180ms ease-out;
}

.pause-menu-frame {
  border: 1px solid rgba(255, 236, 142, 0.45);
  padding: 16px 18px 18px;
  background: rgba(6, 6, 4, 0.34);
}

.pause-menu-title {
  margin: 0 0 12px;
  text-align: center;
  letter-spacing: 3px;
  font-family: "Trebuchet MS", "Segoe UI", "Arial Black", sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--pause-text-hot);
  text-shadow:
    0 2px 0 #443900,
    0 0 12px rgba(255, 234, 124, 0.45);
}

.pause-menu-list {
  display: grid;
  gap: 6px;
}

.pause-menu-item {
  flex: none;
  width: 100%;
  justify-content: flex-start;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 0;
  color: var(--pause-text-dim);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-align: left;
  text-shadow: 2px 2px 0 var(--pause-text-shadow);
  transition: color 100ms linear;
}

.pause-menu-item:hover,
.pause-menu-item:focus-visible,
.pause-menu-item.is-selected {
  color: var(--pause-text-hot);
  outline: none;
  animation: smb1-pause-blink 420ms steps(2, end) infinite;
}

@keyframes smb1-pause-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.95);
  }

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

@keyframes smb1-pause-blink {
  0% {
    filter: brightness(1.35);
  }

  49% {
    filter: brightness(1.35);
  }

  50% {
    filter: brightness(0.96);
  }

  100% {
    filter: brightness(0.96);
  }
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

.control-mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.control-mode-row select {
  flex: 1 1 200px;
}

.control-mode-row .compact {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 12px;
}

.gyro-helper {
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gyro-helper-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 12, 0.6);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45);
  perspective: 220px;
  --gyro-x: 0deg;
  --gyro-y: 0deg;
}

.gyro-helper-ghost,
.gyro-helper-device {
  position: absolute;
  inset: 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transform-style: preserve-3d;
}

.gyro-helper-ghost {
  background: rgba(255, 255, 255, 0.06);
  transform: rotateX(60deg);
}

.gyro-helper-device {
  background: rgba(255, 159, 28, 0.2);
  border-color: rgba(255, 159, 28, 0.65);
  transform: rotateX(calc(60deg + var(--gyro-x))) rotateY(var(--gyro-y));
  transition: transform 80ms linear;
}

.gyro-helper-device.at-limit {
  background: rgba(255, 77, 61, 0.35);
  border-color: rgba(255, 77, 61, 0.85);
}

.checkbox-field {
  margin-top: 4px;
}

.slider-group {
  margin-bottom: 16px;
}

.control-mode-settings {
  margin: 0 0 16px;
}

.panel-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 8px;
  flex-wrap: wrap;
}

.settings-tab-button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(12, 12, 18, 0.5);
  color: var(--fg);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.settings-tab-button.active {
  border-color: var(--accent);
  background: rgba(255, 159, 28, 0.12);
}

.settings-tab-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-tab-panel.hidden {
  display: none;
}

.profile-avatar-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.profile-avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(12, 12, 18, 0.45);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar-controls {
  display: grid;
  gap: 6px;
}

.profile-avatar-controls .text-input {
  width: 100%;
}

.profile-ball-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-ball-texture-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-ball-texture-row .field {
  display: grid;
  gap: 6px;
}

.profile-ball-preview-row {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.profile-ball-preview-label {
  font-size: 13px;
  color: var(--muted);
}

.profile-ball-preview-window {
  width: min(360px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: #111419;
  overflow: hidden;
}

.profile-ball-preview-window canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 11;
}

.color-input {
  width: 100%;
  height: 40px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 12, 18, 0.6);
}

@media (max-width: 740px) {

  .profile-ball-row,
  .profile-ball-texture-row {
    grid-template-columns: 1fr;
  }
}

.menu-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.menu-header h1 {
  margin: 0;
}

.menu-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.menu-button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(16, 16, 24, 0.7);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.menu-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 159, 28, 0.6);
  background: rgba(20, 20, 30, 0.85);
}

.menu-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(16, 16, 24, 0.5);
}

.menu-button-title {
  font-size: 16px;
  font-weight: 600;
}

.menu-button-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.multiplayer-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.multiplayer-view.hidden {
  display: none;
}

.multiplayer-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.multiplayer-layout.hidden {
  display: none;
}

.lobby-chat-panel {
  width: min(320px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.4;
}

.chat-list-ingame {
  max-height: 140px;
  overflow: hidden;
}

.chat-line {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chat-line.chat-fade {
  animation-name: ingame-chat-fade;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.chat-name {
  font-weight: 700;
  color: #ffdd77;
}

.chat-text {
  color: #ffffff;
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
}

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

  83.333% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-input-row .text-input {
  flex: 1;
}

.ingame-chat {
  position: fixed;
  left: 16px;
  bottom: 150px;
  z-index: 9;
  width: min(340px, 70vw);
  color: #ffffff;
  font: 13px/1.45 system-ui, sans-serif;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ingame-chat.open {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  pointer-events: auto;
}

.ingame-chat .chat-list {
  max-height: 200px;
  overflow-y: hidden;
}

.ingame-chat.open .chat-list {
  overflow-y: auto;
}

.ingame-chat .chat-input-row {
  min-height: 36px;
  transition: opacity 0.15s ease;
}

.ingame-chat .chat-input-row.collapsed {
  pointer-events: none;
}

.ingame-chat .text-input {
  background: rgba(10, 10, 15, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--fg);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ingame-chat .text-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.ingame-chat .chat-input-row.collapsed .text-input {
  background: transparent;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.85);
}

.ingame-chat .chat-input-row.collapsed .text-input::placeholder {
  color: rgba(255, 255, 255, 0.9);
}

.text-input {
  flex: 1 1 auto;
  padding: 10px 12px;
  background: rgba(12, 12, 18, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
}

input[type='password']::-ms-reveal,
input[type='password']::-ms-clear {
  display: none;
}

.lobby-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.lobby-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 18, 0.55);
  font-size: 13px;
}

.lobby-item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lobby-item-title {
  font-weight: 600;
}

.lobby-item-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.lobby-item-meta {
  color: var(--muted);
  font-size: 12px;
}

.lobby-room-info {
  font-size: 14px;
  font-weight: 600;
}

.lobby-room-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.lobby-player-list {
  display: grid;
  gap: 8px;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 18, 0.4);
}

.lobby-player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lobby-player-name {
  font-size: 13px;
  font-weight: 600;
}

.lobby-player-tags {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.lobby-player-sub {
  font-size: 11px;
  color: var(--muted);
}

.kick-button {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 11px;
  border-color: rgba(255, 99, 99, 0.45);
  color: #ffb3b3;
}

.kick-button:hover {
  border-color: rgba(255, 99, 99, 0.75);
  background: rgba(255, 99, 99, 0.15);
}

.lobby-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 18, 0.35);
  margin-bottom: 10px;
  font-size: 13px;
}

.lobby-setting-value {
  color: var(--muted);
  font-size: 12px;
}

.lobby-setting-button {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(12, 12, 18, 0.4);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.lobby-setting-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.lobby-gamemode-options {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 55%),
    rgba(255, 255, 255, 0.2);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#nameplate-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  font: 12px/1.2 system-ui, sans-serif;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.nameplate {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.nameplate.visible {
  opacity: 1;
}

.nameplate .avatar {
  width: 24px;
  height: 24px;
}

.nameplate-name {
  font-weight: 600;
  font-size: 12px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(36px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.avatar-option {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 12, 18, 0.6);
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease, border-color 120ms ease;
}

.avatar-option.selected {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(255, 159, 28, 0.2);
}

.avatar-amber {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #ffb347, #ff7b00);
}

.avatar-mint {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #7fe8c8, #28a88b);
}

.avatar-sky {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #7fb2ff, #3f6fd9);
}

.avatar-rose {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #ff9aa2, #d46a7e);
}

.avatar-slate {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #a0a7b8, #5d6676);
}

.avatar-lime {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #b6ff6b, #5ccf2a);
}

.lobby-players {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 18, 0.35);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.control-mode-block {
  margin-bottom: 12px;
}

.control-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 6px;
}

.control-hint.error {
  color: #ffb3b3;
}

.lobby-max-players-warning {
  color: #ffd36c;
}

.response-curve {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 12, 0.6);
  display: grid;
  place-items: center;
}

.response-curve svg {
  width: 100%;
  height: 100%;
}

.response-curve path {
  fill: none;
  stroke: rgba(255, 159, 28, 0.85);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.input-falloff-visuals {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.input-preview {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 12, 0.6);
  overflow: hidden;
}

.input-preview-grid {
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.input-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.input-dot.raw {
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

.input-dot.processed {
  background: rgba(255, 77, 61, 0.95);
  box-shadow: 0 0 6px rgba(255, 77, 61, 0.75);
}

.slider-field span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

output {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #f3f3f3;
  color: #1b1200;
  color-scheme: light;
  -webkit-text-fill-color: #1b1200;
}

select option {
  color: #1b1200;
  background: #f3f3f3;
}

.row {
  display: flex;
  gap: 12px;
}

.pack-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pack-controls .ghost {
  flex: 0 0 auto;
}

.pack-picker {
  display: flex;
  gap: 8px;
}

.pack-status {
  font-size: 12px;
  color: var(--muted);
}

button {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #1b1200;
}

button.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--fg);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.hint code {
  color: #ffd38a;
}

@media (max-width: 720px) {
  .panel {
    padding: 18px;
  }

  .panel h1 {
    font-size: 22px;
  }
}

.menu-actions {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--fg);
}

.menu-actions-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.credits-menu {
  position: relative;
  font-size: 13px;
  color: var(--fg);
}

.settings-button {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 10px;
}

.menu-action-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: var(--fg);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.menu-action-link:focus-visible {
  outline: 2px solid rgba(255, 159, 28, 0.8);
  outline-offset: 2px;
}

.discord-server-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex: 0 0 auto;
}

/* Hover "bridge" so the menu doesn't vanish while moving into the panel */
.credits-menu::after {
  content: "";
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  height: 10px;
}

.credits-label {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.credits-label:focus-visible {
  outline: 2px solid rgba(255, 159, 28, 0.8);
  outline-offset: 2px;
}

.credits-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  min-width: 320px;
  width: max-content;
  max-width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;

  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

/* OPEN on hover (desktop) OR when toggled open (mobile) */
.credits-menu:hover .credits-panel,
.credits-menu.open .credits-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.credits-panel a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.credits-panel a:hover {
  text-decoration: underline;
}

.credits-panel span {
  color: var(--muted);
  margin-left: 4px;
}

.credits-panel .credits-multiline {
  display: grid;
  gap: 4px;
}

.credits-panel .credits-title {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2px;
}

.credits-panel .credits-sublist {
  display: grid;
  gap: 2px;
  margin-left: 12px;
}

.mobile-menu-button {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(220px, 48vw);
  height: 40px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 8, 12, 0.78);
  color: var(--fg);
  font-weight: 600;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
  backdrop-filter: blur(6px);
}

.fullscreen-button {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 12;
  padding: 6px 10px;
  font-size: 11px;
}

.leaderboard-list {
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 6, 10, 0.55);
  padding: 10px 12px;
  max-height: 320px;
  overflow: auto;
  font-size: 13px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 32px 1fr 120px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-row.admin-row {
  grid-template-columns: 32px 1fr 120px auto;
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  font-weight: 700;
  opacity: 0.8;
}

.leaderboard-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.replay-library-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.replay-library-row:last-child {
  border-bottom: none;
}

.replay-library-info {
  min-width: 0;
  flex: 1 1 auto;
}

.replay-library-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.replay-library-subtitle {
  margin-top: 2px;
  opacity: 0.75;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.replay-library-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}