:root {
  --bg-deep: #0a0708;
  --bg-mid: #141016;
  --bg-panel: rgba(22, 12, 14, 0.72);
  --line: rgba(255, 63, 63, 0.28);
  --text: #f4ece8;
  --muted: #b8989a;
  --accent: #ff3f3f;
  --accent-2: #d70a9a;
  --lime: #9ad70a;
  --danger: #ff3f3f;
  --fun-yellow: #ffcc06;
  --radius: 10px;
  --font-display: "Orbitron", sans-serif;
  --font-ui: "Rajdhani", sans-serif;
  --glass-blur: blur(14px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}

#ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body {
  min-height: 100vh;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.hidden {
  display: none !important;
}

button,
a,
input,
select,
canvas {
  -webkit-tap-highlight-color: transparent;
}

#screen-select {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#screen-select .select-shell {
  height: 100%;
}
.select-shell {
  width: min(920px, 94vw);
  margin: 0 auto;
  padding: 1rem 0 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
  min-height: 0;
}

.select-header {
  text-align: center;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3.6vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(100deg, #ff3f3f 10%, #ffcc06 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 63, 63, 0.35));
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.select-top {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  align-items: end;
}

.select-auth-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(18, 8, 10, 0.5);
  backdrop-filter: var(--glass-blur);
}

.auth-guest-wrap,
.auth-user-wrap {
  flex: 1;
  min-width: min(100%, 260px);
}

.auth-welcome {
  font-size: 1rem;
  color: #ffb0a8;
}

.auth-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.scenario-tabs {
  display: flex;
  gap: 0.4rem;
}

.scenario-tab {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(18, 8, 10, 0.45);
  color: var(--muted);
  font: 700 0.95rem var(--font-ui);
  letter-spacing: 0.04em;
  padding: 0.42rem 0.65rem;
  cursor: pointer;
}

.scenario-tab.active {
  color: #1a0808;
  background: linear-gradient(90deg, #ff3f3f, #ffcc06);
  border-color: #c83232;
}

.scenario-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.35rem;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e07070;
  font-weight: 700;
}

.filter-field.filter-grow {
  grid-column: span 2;
}

.filter-field input,
.filter-field select {
  border: 1px solid rgba(255, 63, 63, 0.32);
  background: rgba(22, 10, 12, 0.7);
  color: var(--text);
  border-radius: 8px;
  padding: 0.38rem 0.5rem;
  font: 600 0.92rem var(--font-ui);
}

.filter-clear-btn {
  height: 34px;
  color: #ffb0a8 !important;
  border-color: rgba(255, 63, 63, 0.4) !important;
}

.scenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-self: center;
}

.scenario-empty {
  margin: 1rem;
  text-align: center;
  color: var(--muted);
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.auth-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: rgba(18, 12, 22, 0.94);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(10, 154, 215, 0.22);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.auth-modal-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.auth-modal-tab {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 8, 12, 0.55);
  color: var(--muted);
  font: 700 0.92rem var(--font-ui);
  padding: 0.4rem;
  cursor: pointer;
}

.auth-modal-tab.active {
  color: #ffb0a8;
  border-color: rgba(255, 63, 63, 0.5);
  background: rgba(255, 63, 63, 0.12);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.auth-form input {
  border: 1px solid var(--line);
  background: rgba(10, 8, 12, 0.62);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font: 600 1rem var(--font-ui);
  text-transform: none;
}

.create-btn {
  margin-top: 0 !important;
  white-space: nowrap;
  height: 42px;
  padding: 0 1.05rem;
}

.select-actions {
  display: flex;
  gap: 0.5rem;
  align-items: end;
}

.ghost-btn,
.howto-btn {
  margin-top: 0;
  white-space: nowrap;
  height: 42px;
  padding: 0 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 63, 63, 0.4);
  background: rgba(22, 10, 12, 0.55);
  backdrop-filter: var(--glass-blur);
  color: #ffb0a8;
  font: 700 1rem var(--font-ui);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.ghost-btn:hover,
.howto-btn:hover {
  border-color: rgba(255, 63, 63, 0.7);
  background: rgba(255, 63, 63, 0.1);
}

/* —— How to Play —— */
.howto-shell {
  width: min(980px, 94vw);
  margin: 0 auto;
  padding: 1.6rem 0 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  flex: 1;
  min-height: 0;
}

.howto-header {
  text-align: center;
}

.howto-brand {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.howto-dots {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.howto-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(10, 154, 215, 0.35);
  background: rgba(12, 8, 14, 0.75);
  padding: 0;
  cursor: pointer;
}

.howto-dot.done {
  background: rgba(10, 154, 215, 0.28);
}

.howto-dot.active {
  background: var(--accent);
  border-color: #9ad7f0;
  box-shadow: 0 0 12px rgba(10, 154, 215, 0.55);
  transform: scale(1.2);
}

.howto-stage {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.1fr);
  gap: 1.1rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.howto-copy {
  background: linear-gradient(160deg, rgba(22, 14, 28, 0.82), rgba(10, 8, 12, 0.78));
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(10, 154, 215, 0.06);
}

.howto-copy h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.8vw, 1.7rem);
  letter-spacing: 0.04em;
  color: #ff6a5a;
}

.howto-copy p {
  margin: 0;
  color: #d8ccd8;
  font-size: 1.08rem;
  line-height: 1.45;
}

.howto-tip {
  color: #ffb0a8 !important;
  border-left: 3px solid rgba(255, 63, 63, 0.55);
  padding-left: 0.75rem;
  font-weight: 600;
}

.howto-demo-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
}

#howto-canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(52vh, 420px);
  margin: 0 auto;
  display: block;
  border-radius: 14px;
  border: 1px solid rgba(10, 154, 215, 0.22);
  background: #0a080c;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 0 24px rgba(10, 154, 215, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.45);
}

.howto-interact {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.howto-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.howto-nav {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.howto-nav .primary-btn {
  margin-top: 0;
  height: 44px;
  padding: 0 1.2rem;
}

.howto-footer .editor-btn {
  height: 44px;
}

.howto-footer .editor-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.select-status {
  margin: 0;
  min-height: 1em;
  color: #d08080;
  font-size: 0.88rem;
}

.select-status.error {
  color: #ff8a9a;
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: #e07070;
}

.name-field input {
  border: 1px solid rgba(255, 63, 63, 0.32);
  background: rgba(22, 10, 12, 0.7);
  backdrop-filter: var(--glass-blur);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font: 600 1rem var(--font-ui);
  outline: none;
}

.name-field input:focus {
  border-color: rgba(255, 63, 63, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 63, 63, 0.14);
}

.scenario-list-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(255, 63, 63, 0.28);
  border-radius: 12px;
  background: rgba(16, 8, 10, 0.55);
  backdrop-filter: var(--glass-blur);
  padding: 0.45rem;
  box-shadow: inset 0 1px 0 rgba(255, 63, 63, 0.06);
}

.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.scenario-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.45rem 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(28, 18, 36, 0.88), rgba(14, 10, 18, 0.88));
  color: inherit;
  padding: 0.75rem 0.9rem;
  font: inherit;
  transition: border-color 0.15s, transform 0.15s, background 0.15s, box-shadow 0.15s;
}

.scenario-play {
  min-width: 0;
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.card-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font: 700 0.95rem var(--font-ui);
  cursor: pointer;
}

.card-del {
  background: #963232;
}

.card-edit {
  background: #32964b;
}

.scenario-card:hover,
.scenario-card:focus-visible {
  border-color: rgba(255, 63, 63, 0.5);
  outline: none;
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(42, 18, 22, 0.94), rgba(18, 10, 12, 0.94));
  box-shadow: 0 0 18px rgba(255, 63, 63, 0.12);
}

.scenario-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.scenario-meta {
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.scenario-best {
  color: var(--lime);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.35;
  text-align: right;
  max-width: 11rem;
  overflow-wrap: anywhere;
  align-self: start;
}

/* —— Game screen —— */
#screen-game {
  height: 100vh;
  height: 100dvh;
  padding: 0.45rem 0.6rem 0.55rem;
  gap: 0.4rem;
  overflow: hidden;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  background: linear-gradient(180deg, rgba(14, 28, 42, 0.95), rgba(8, 14, 22, 0.95));
  border: 1px solid rgba(10, 154, 215, 0.35);
  box-shadow: inset 0 1px 0 rgba(154, 215, 10, 0.12), 0 8px 24px rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
  padding: 0 0.55rem;
}

.hud-wide {
  min-width: min(280px, 40vw);
}

.hud-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7eb8d4;
}

/* Fullscreen toggle button – HUD variant */
.fullscreen-btn {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(10, 154, 215, 0.4);
  border-radius: 6px;
  color: #7eb8d4;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  align-self: center;
}
.fullscreen-btn:hover {
  color: #9ad70a;
  border-color: rgba(154, 215, 10, 0.5);
}

/* Fullscreen toggle button – select screen variant */
.fullscreen-select-btn {
  font-size: 0.85rem;
}

.hud-item > span:last-child {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: #9ad70a;
  text-shadow: 0 0 10px rgba(154, 215, 10, 0.35);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vol-ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 7.5rem;
  padding: 0 0.45rem;
}

.vol-ctrl .hud-label {
  line-height: 1;
}

.vol-ctrl input[type="range"] {
  width: 7rem;
  height: 6px;
  accent-color: #0a9ad7;
  cursor: pointer;
  background: transparent;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
}

.canvas-wrap.is-zoomed {
  cursor: grab;
}

.canvas-wrap.is-zoomed.is-panning {
  cursor: grabbing;
}

.slot-cabinet {
  position: relative;
  overflow: hidden;
  width: max-content;
  max-width: 100%;
  padding: 5px;
  border-radius: 14px;
  border: 2px solid rgba(10, 154, 215, 0.42);
  background: rgba(8, 12, 18, 0.92);
  box-shadow:
    0 0 0 1px rgba(215, 10, 154, 0.18),
    0 10px 28px rgba(0, 0, 0, 0.4),
    inset 0 0 18px rgba(10, 154, 215, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  transform-origin: center center;
  will-change: transform;
}

.slot-cabinet::before {
  content: none;
}

.slot-cabinet.spinning {
  border-color: rgba(154, 215, 10, 0.75);
  box-shadow:
    0 0 0 1px rgba(10, 154, 215, 0.35),
    0 0 22px rgba(154, 215, 10, 0.28),
    inset 0 0 18px rgba(154, 215, 10, 0.08);
  animation: board-energy 0.55s ease-in-out infinite;
}

.slot-cabinet.payline {
  border-color: rgba(255, 63, 63, 0.7);
  box-shadow:
    0 0 0 1px rgba(255, 63, 63, 0.28),
    0 0 20px rgba(255, 63, 63, 0.22),
    inset 0 0 14px rgba(255, 63, 63, 0.08);
}

.slot-cabinet.spinning #game-canvas {
  cursor: wait;
}

@keyframes board-energy {
  0%,
  100% {
    border-color: rgba(154, 215, 10, 0.55);
  }
  50% {
    border-color: rgba(10, 154, 215, 0.85);
  }
}

#game-canvas {
  position: relative;
  z-index: 1;
  display: block;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  background: #0a080c;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.controls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
  width: min(900px, 100%);
  margin: 0 auto;
}

.ctrl-btn {
  border: 2px solid rgba(10, 154, 215, 0.35);
  border-radius: 10px;
  background: linear-gradient(180deg, #243044, #121820);
  color: #eef4fa;
  font: 700 1.15rem var(--font-ui);
  letter-spacing: 0.04em;
  padding: 0.7rem 0.4rem;
  cursor: pointer;
  transition: filter 0.12s, transform 0.12s, box-shadow 0.12s;
}

.ctrl-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 12px rgba(10, 154, 215, 0.2);
}

.ctrl-btn:active {
  transform: translateY(1px);
}

.ctrl-space {
  background: linear-gradient(180deg, #1ec0f0, #0a7aad);
  border-color: #0680b0;
  color: #041018;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: space-pulse 1.8s ease-in-out infinite;
}

.ctrl-quit {
  background: linear-gradient(180deg, #a03850, #782030);
  border-color: #5a1828;
}

@keyframes space-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(10, 154, 215, 0.45);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(10, 154, 215, 0);
  }
}

.hint {
  margin: 0 auto;
  max-width: 900px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* —— Overlay —— */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 1rem;
}

.win-card {
  width: min(420px, 100%);
  background:
    radial-gradient(circle at 18% 0%, rgba(10, 154, 215, 0.28), transparent 42%),
    radial-gradient(circle at 88% 12%, rgba(215, 10, 154, 0.18), transparent 40%),
    linear-gradient(160deg, #142436, #0a1018);
  border: 1px solid rgba(10, 154, 215, 0.4);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 36px rgba(10, 154, 215, 0.18);
}

.win-card h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  color: #9ad70a;
  text-shadow: 0 0 18px rgba(154, 215, 10, 0.45);
}

.win-sub {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7ec8e8 !important;
}

.win-card p {
  margin: 0.35rem 0;
  color: #d8ccd0;
}

.best-line {
  color: var(--lime) !important;
  font-weight: 600;
}

.win-score-line {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--fun-yellow) !important;
  letter-spacing: 0.06em;
  margin: 0.6rem 0 0.2rem !important;
}

#stat-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--fun-yellow);
  text-shadow: 0 0 10px rgba(255, 204, 6, 0.4);
}

.primary-btn {
  margin-top: 1.25rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, #ff3f3f, #d70a9a);
  color: #fff4f2;
  font: 700 1.05rem var(--font-ui);
  letter-spacing: 0.04em;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 63, 63, 0.28);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

/* —— Editor —— */
#screen-editor {
  padding: 0.7rem 0.8rem 0.8rem;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  flex: 1;
}

.editor-top h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-align: center;
}

.editor-name-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
}

.editor-name-row label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.editor-name-row input {
  border: 1px solid var(--line);
  background: rgba(10, 8, 12, 0.62);
  backdrop-filter: var(--glass-blur);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font: 600 1rem var(--font-ui);
  min-width: 180px;
}

.editor-hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.editor-body {
  display: grid;
  grid-template-columns: 150px 1fr 210px;
  gap: 0.7rem;
  flex: 1;
  min-height: 0;
}

.editor-left,
.editor-right {
  background: rgba(14, 10, 18, 0.72);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  overflow: auto;
  box-shadow: inset 0 1px 0 rgba(10, 154, 215, 0.05);
}

.editor-left h3,
.editor-right h3 {
  margin: 0.4rem 0 0.45rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c8d4ea;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: 0.35rem;
  border: 2px solid #6482b4;
  border-radius: 8px;
  background: #3c5078;
  color: #fff;
  padding: 0.4rem 0.2rem;
  cursor: pointer;
  font: inherit;
}

.tool-btn strong {
  font-size: 1.05rem;
}

.tool-btn span {
  font-size: 0.75rem;
  color: #c8d8ff;
}

.tool-btn.active {
  background: #64a064;
  border-color: #96c896;
}

.check-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.9rem;
  margin: 0.4rem 0;
}

.minsize-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.mini-btn {
  width: 26px;
  height: 26px;
  border: 1px solid #6482b4;
  border-radius: 6px;
  background: #3c5078;
  color: #fff;
  cursor: pointer;
}

#ed-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  background: rgba(8, 6, 10, 0.55);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 0 0 40px rgba(10, 154, 215, 0.03);
}

#ed-canvas {
  display: block;
  cursor: crosshair;
}

.panel-note {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-verify-link-wrap {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(154, 215, 10, 0.35);
  border-radius: 8px;
  background: rgba(154, 215, 10, 0.08);
}

.auth-verify-link {
  color: var(--lime);
  font-weight: 700;
  word-break: break-all;
}

.dist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.dist-grid label,
.pct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.dist-grid input,
.pct-row input {
  width: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1c2434;
  color: #fff;
  padding: 0.25rem 0.3rem;
}

.fill-btn {
  width: 100%;
  margin: 0.5rem 0 0.3rem;
}

.palette-btn {
  width: 100%;
  margin: 0.35rem 0 0.75rem;
  background: #3c5078;
}

.face-dist-panel {
  grid-template-columns: 1fr;
}

.dist-color-row {
  display: grid;
  grid-template-columns: 18px 1fr 54px;
  align-items: center;
  gap: 0.4rem;
}

.dist-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.dist-swatch-weapon {
  background: linear-gradient(135deg, #c83250, #78283c);
}

.dist-name {
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.72);
}

.palette-dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(85vh, 640px);
  overflow: auto;
  background: rgba(18, 12, 22, 0.94);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(10, 154, 215, 0.22);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 40px rgba(10, 154, 215, 0.06);
}

.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.palette-header h3 {
  margin: 0;
  font: 700 1.15rem var(--font-display);
}

.palette-close-btn {
  border: 0;
  background: transparent;
  color: #aab4c8;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.75rem 0;
}

.palette-row {
  display: grid;
  grid-template-columns: 1fr minmax(90px, 120px) 32px;
  gap: 0.45rem;
  align-items: center;
}

.palette-swatch-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.palette-swatch-wrap input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 0;
  border: 1px solid #5a6a8c;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.palette-rgb {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.palette-name {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1c2434;
  color: #fff;
  padding: 0.35rem 0.45rem;
  font-size: 0.9rem;
}

.palette-remove {
  border: 1px solid #6a4040;
  border-radius: 6px;
  background: #503030;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  height: 32px;
  cursor: pointer;
}

.palette-remove:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.palette-add-btn {
  width: 100%;
  background: #3c5078;
  margin-bottom: 0.75rem;
}

.palette-footer {
  display: flex;
  justify-content: flex-end;
}

.clear-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.clear-grid button {
  border: 1px solid #5a6a8c;
  border-radius: 6px;
  background: #3c4664;
  color: #fff;
  padding: 0.3rem;
  cursor: pointer;
}

.editor-btn {
  border: 0;
  border-radius: 8px;
  background: #3c6440;
  color: #fff;
  font: 700 1rem var(--font-ui);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.editor-btn.ghost {
  background: #3a445c;
}

.save-btn {
  background: linear-gradient(90deg, #c83232, #a01860);
  min-width: 110px;
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

#ed-status {
  margin: 0;
  color: var(--lime);
  font-weight: 600;
}

#ed-status.error {
  color: #ff8a9a;
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .editor-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .auth-actions {
    width: 100%;
    justify-content: stretch;
  }

  .auth-actions .ghost-btn,
  .auth-actions .create-btn {
    flex: 1;
  }

  .howto-stage {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .controls {
    grid-template-columns: repeat(3, 1fr);
  }

  .hud-wide {
    min-width: 100%;
    order: 5;
  }

  .scenario-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .scenario-play,
  .scenario-best {
    grid-column: 2;
  }

  .scenario-best {
    max-width: none;
    text-align: left;
    align-self: start;
  }

  .filter-field.filter-grow {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slot-cabinet.spinning {
    animation: none;
  }

  .ctrl-space {
    animation: none;
  }
}
