/* ═══════════════════════════════════════════════════════════════════════════
   Cabinet — Premium UI Stylesheet
   Dark atmospheric aesthetic inspired by VerFall quality standards.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg-deep: #08080c;
  --bg-surface: #0c0c12;
  --bg-elevated: rgba(18, 18, 26, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.04);
  --text-primary: #f0ece4;
  --text-secondary: #9e9a92;
  --text-muted: #6a665e;
  --accent: #d4af37;
  --accent-dim: #8a6a18;
  --accent-glow: rgba(212, 175, 55, 0.35);
  --danger: #cc4422;
  --success: #5a9e6e;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition-fast: 0.14s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-base: 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  --font-serif: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ─── Reset & Base ──────────────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body,
#background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  overflow: hidden;
}

/* ─── Atmospheric Orbs ──────────────────────────────────────────────────── */
.orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(60px);
  z-index: 0;
  opacity: 0.55;
}

.orb-a {
  top: 10%;
  left: 15%;
  width: 55vw;
  height: 55vh;
  background: radial-gradient(closest-side, rgba(212, 175, 55, 0.22), rgba(138, 106, 24, 0.06) 50%, transparent 80%);
  animation: orb-drift-a 18s ease-in-out infinite;
}

.orb-b {
  top: 45%;
  left: 55%;
  width: 45vw;
  height: 45vh;
  background: radial-gradient(closest-side, rgba(180, 140, 60, 0.16), rgba(100, 80, 30, 0.04) 50%, transparent 80%);
  animation: orb-drift-b 22s ease-in-out infinite;
}

.orb-c {
  top: 60%;
  left: 10%;
  width: 50vw;
  height: 40vh;
  background: radial-gradient(closest-side, rgba(100, 90, 160, 0.12), rgba(50, 45, 90, 0.04) 50%, transparent 80%);
  animation: orb-drift-c 26s ease-in-out infinite;
}

.orb-d {
  top: 20%;
  left: 60%;
  width: 40vw;
  height: 50vh;
  background: radial-gradient(closest-side, rgba(200, 160, 80, 0.14), rgba(120, 90, 40, 0.04) 50%, transparent 80%);
  animation: orb-drift-d 20s ease-in-out infinite;
}

@keyframes orb-drift-a {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
  33% { transform: translate(8vw, -5vh) scale(1.15); opacity: 0.7; }
  66% { transform: translate(-4vw, 6vh) scale(0.9); opacity: 0.45; }
}

@keyframes orb-drift-b {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
  40% { transform: translate(-6vw, 4vh) scale(1.2); opacity: 0.6; }
  80% { transform: translate(3vw, -6vh) scale(0.95); opacity: 0.5; }
}

@keyframes orb-drift-c {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.35; }
  50% { transform: translate(5vw, -4vh) scale(1.1); opacity: 0.5; }
}

@keyframes orb-drift-d {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
  30% { transform: translate(-5vw, 3vh) scale(1.12); opacity: 0.55; }
  70% { transform: translate(4vw, -5vh) scale(0.92); opacity: 0.45; }
}

/* ─── Vignette & Film Grain ─────────────────────────────────────────────── */
.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.25) 50%, rgba(0,0,0,0.7) 100%);
}

.film-grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.025;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* ─── Canvas Frame ──────────────────────────────────────────────────────── */
.canvas-frame {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 8px;
}

.canvas-frame canvas {
  margin: 0;
}

canvas {
  position: relative;
  z-index: 2;
  max-width: calc(100% - 6px);
  margin: auto;
  border-radius: var(--radius-md);
  box-shadow:
    0 0 0 1px var(--glass-border),
    0 0 0 1px rgba(212, 175, 55, 0.06),
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(212, 175, 55, 0.04);
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: -webkit-crisp-edges;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}

#sand-canvas {
  z-index: 2;
}

#fluid-canvas {
  position: absolute;
  bottom: 8px;
  z-index: 1;
  opacity: 0.85;
}

/* ─── UI Container ──────────────────────────────────────────────────────── */
#ui {
  position: relative;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
button {
  position: relative;
  height: 34px;
  min-width: 34px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(0) scale(0.97);
  background: rgba(255, 255, 255, 0.04);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.25);
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

button.active,
button.selected {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.45);
  color: #fff5dc;
  text-shadow: 0 0 8px var(--accent-glow);
  box-shadow:
    inset 0 1px 0 rgba(212, 175, 55, 0.15),
    0 0 14px rgba(212, 175, 55, 0.12);
}

button.selected:hover {
  background: rgba(212, 175, 55, 0.24);
  border-color: rgba(212, 175, 55, 0.55);
}

/* ─── Icon Buttons ──────────────────────────────────────────────────────── */
.btn-icon {
  width: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ─── Element Buttons ───────────────────────────────────────────────────── */
.element-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 10px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.element-btn::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.element-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.element-btn:hover::before {
  opacity: 1;
  box-shadow: 0 0 6px currentColor;
}

.element-btn.selected {
  background: rgba(212, 175, 55, 0.15);
  border-color: rgba(212, 175, 55, 0.4);
  color: #fff5dc;
  text-shadow: 0 0 10px var(--accent-glow);
  box-shadow:
    inset 0 1px 0 rgba(212, 175, 55, 0.1),
    0 0 16px rgba(212, 175, 55, 0.1);
}

.element-btn.selected::before {
  opacity: 1;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ─── Size Buttons ──────────────────────────────────────────────────────── */
.size-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.size-btn svg {
  width: 16px;
  height: 16px;
}

.size-btn.selected {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.4);
}

/* ─── Control Groups ────────────────────────────────────────────────────── */
.control-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.control-divider {
  width: 1px;
  height: 20px;
  background: var(--glass-border);
  margin: 0 2px;
}

/* ─── Element Palette ───────────────────────────────────────────────────── */
.element-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

/* ─── FPS Counter ───────────────────────────────────────────────────────── */
#fps {
  pointer-events: none;
  z-index: 10;
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  display: inline-block;
  white-space: pre;
  user-select: none;
  line-height: 1.4;
}

/* ─── Submission Title ──────────────────────────────────────────────────── */
.submission-title {
  z-index: 10;
  position: relative;
  overflow-wrap: break-word;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
}

.submission-title button {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  background: rgba(212, 175, 55, 0.1);
  border-color: rgba(212, 175, 55, 0.25);
  color: var(--accent);
}

.submission-title button:hover {
  background: rgba(212, 175, 55, 0.18);
}

/* ─── Menus & Modals ────────────────────────────────────────────────────── */
.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 4, 8, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: scrim-in 0.25s ease-out;
}

@keyframes scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.menu {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 51;
  background: var(--bg-elevated);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(0,0,0,0.3);
  padding: 20px;
  max-width: 720px;
  margin: auto;
  animation: menu-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.menu h1,
.menu h2,
.menu h3,
.menu h4 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  margin-bottom: 0.5em;
  letter-spacing: 0.04em;
}

.menu h1 { font-size: 1.6rem; font-weight: 600; }
.menu h2 { font-size: 1.3rem; font-weight: 500; }
.menu h3 { font-size: 1.1rem; font-weight: 500; }
.menu h4 { font-size: 0.95rem; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); }

.menu p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1em;
  font-size: 14px;
}

.menu a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast);
}

.menu a:hover {
  border-bottom-color: var(--accent-dim);
}

.menu .x {
  position: absolute;
  right: 12px;
  top: 12px;
}

.menu .x button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.menu .x button:hover {
  background: rgba(204, 68, 34, 0.2);
  color: var(--danger);
}

/* ─── Inputs ────────────────────────────────────────────────────────────── */
input {
  position: relative;
  height: 34px;
  min-width: 80px;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

input::placeholder {
  color: var(--text-muted);
}

input:focus {
  outline: none;
  border-color: rgba(212, 175, 55, 0.4);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
  background: rgba(0, 0, 0, 0.4);
}

/* ─── Submissions / Browse ──────────────────────────────────────────────── */
.submissions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media only screen and (min-width: 700px) {
  .submissions {
    grid-template-columns: repeat(2, 1fr);
  }
}

.submission {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.submission:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.12);
}

.submission img,
.submissionImg {
  width: 100%;
  max-height: 50vw;
  object-fit: cover;
  display: block;
  background: var(--bg-surface);
}

.submission div {
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.submission div h3 {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  width: 100%;
}

.submission div h2 {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-block;
  max-width: 50vw;
}

.img-link {
  width: 50%;
  line-height: 0;
}

.submission button.parent {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  font-size: 12px;
}

.thread {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.bottom-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--glass-border);
}

.bottom-row > * {
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.heart {
  background: transparent;
  border-color: transparent;
  border-width: 0;
  flex-grow: 0;
  text-align: left;
  padding: 0;
  margin: 0;
  min-width: 0 !important;
  transition: transform 0.1s;
  flex-grow: 0;
  margin-right: -2px;
  color: var(--text-muted);
  font-size: 16px;
}

.heart:hover {
  color: #e05252;
  transform: scale(1.2);
  background: transparent;
}

.heart:active {
  color: #ff4444;
  filter: none;
  transform: scale(1.4);
}

.submission .adminButtons {
  display: flex;
  flex-direction: row;
  margin: 0;
  gap: 4px;
  padding: 8px 12px;
}

.admin * {
  font-size: 12px !important;
}

.admin .submission h3.title {
  overflow: hidden;
}

.delete {
  background: rgba(204, 68, 34, 0.15) !important;
  border-color: rgba(204, 68, 34, 0.3) !important;
  color: #ff8888 !important;
}

.delete:hover {
  background: rgba(204, 68, 34, 0.25) !important;
}

.ban {
  background: rgba(204, 68, 34, 0.25) !important;
  border-color: rgba(204, 68, 34, 0.4) !important;
  color: #ffaaaa !important;
}

.pardon {
  background: rgba(90, 158, 110, 0.15) !important;
  border-color: rgba(90, 158, 110, 0.3) !important;
  color: #88cc99 !important;
}

.adminButtons button:active {
  transform: scale(1.15);
  z-index: 5;
}

/* ─── Firebase UI overrides ─────────────────────────────────────────────── */
.firebaseui-container.mdl-card {
  background-color: transparent;
  box-shadow: none !important;
}

/* ─── Benchmark ─────────────────────────────────────────────────────────── */
.benchmark {
  position: absolute;
  bottom: 32px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-secondary);
  z-index: 9999;
  padding: 6px 10px;
}

/* ─── Info Page ─────────────────────────────────────────────────────────── */
.Info {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 4px;
}

.Info h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3em;
  letter-spacing: 0.06em;
}

.Info h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--accent);
  margin: 1.2em 0 0.6em;
}

.Info h4 {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin: 1em 0 0.3em;
}

.Info p {
  color: var(--text-secondary);
  line-height: 1.65;
  font-size: 14px;
}

.Info a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast);
}

.Info a:hover {
  border-bottom-color: var(--accent-dim);
}

.Info hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 1.2em 0;
}

/* ─── Pull Tab ──────────────────────────────────────────────────────────── */
#PullTabContent {
  position: fixed;
  z-index: 20;
  top: 56px;
  right: 0px;
  font-size: 14px;
  width: 320px;
  max-width: 80vw;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-right: none;
  transform: translate(calc(100%), 0px);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 10px 5px rgba(0, 0, 0, 0.25));
  padding: 16px;
  color: var(--text-secondary);
}

#PullTabContent.open {
  transform: translate(0px, 0px);
}

#PullTabContent.dismissed {
  transform: translate(calc(100% + 20px), 0px);
}

#PullTabContent p {
  line-height: 1.6;
  margin-bottom: 12px;
}

#PullTabContent a {
  color: var(--accent);
  text-decoration: none;
}

#PullTab {
  box-sizing: border-box;
  position: absolute;
  margin: auto;
  left: -40px;
  top: 12px;
  z-index: 21;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 18px;
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  cursor: pointer;
  color: var(--accent);
  transition: background var(--transition-fast);
}

#PullTab:hover {
  background: rgba(212, 175, 55, 0.1);
}

#PullTab img {
  display: none;
}

#logo {
  margin: auto;
  display: block;
}

.CTA {
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: rgba(212, 175, 55, 0.1);
  color: var(--accent);
  border-radius: var(--radius-sm);
  display: block;
  margin: auto;
  width: fit-content;
  padding: 0.5em 1em;
  margin-top: 0.5em;
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.CTA:hover {
  background: rgba(212, 175, 55, 0.18);
  transform: rotate(1deg) scale(1.02);
  filter: drop-shadow(1px 3px 6px rgba(0, 0, 0, 0.15));
}

.discord {
  margin: auto;
  display: block;
  position: relative;
  width: 200px;
  background: rgba(88, 101, 242, 0.15);
  border: 1px solid rgba(88, 101, 242, 0.3);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  color: #aab2f5;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.discord:hover {
  background: rgba(88, 101, 242, 0.22);
  transform: translateY(-1px);
}

.link-icon {
  width: 1em;
  height: 1em;
  vertical-align: bottom;
  margin-left: 0.5em;
}

.app-store-badge {
  height: 40px;
  width: auto;
  display: block;
  margin: 0.5em auto;
}

.arrow-icon {
  position: absolute;
  left: -100px;
  top: 50%;
  width: 100px;
  transform: translateY(-50%);
}

.price-icon {
  position: absolute;
  bottom: -20px;
  right: -120px;
  height: 100px;
}

.reversed {
  transform: rotate(180deg);
}

/* ─── App Container ─────────────────────────────────────────────────────── */
.App {
  font-family: var(--font-sans);
  text-align: center;
  margin-top: 40px;
}

/* ─── Responsive: Mobile ────────────────────────────────────────────────── */
@media only screen and (max-width: 699px) {
  #ui {
    padding: 8px;
    gap: 4px;
  }

  button {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .btn-icon {
    width: 32px;
    padding: 0;
  }

  .element-btn {
    font-size: 10px;
    padding: 0 8px;
    height: 26px;
  }

  .element-btn::before {
    width: 5px;
    height: 5px;
    left: 5px;
  }

  .control-group {
    padding: 2px 4px;
    gap: 2px;
  }

  .menu {
    left: 8px;
    right: 8px;
    top: 8px;
    padding: 16px;
    border-radius: var(--radius-md);
  }

  canvas {
    border-radius: var(--radius-sm);
  }

  .canvas-frame {
    padding: 4px;
  }

  #fps {
    font-size: 10px;
    padding: 3px 6px;
    right: 6px;
    bottom: 6px;
  }

  .submission-title {
    font-size: 11px;
    padding: 2px 6px;
  }
}

/* ─── Landscape Sidebar Layout ──────────────────────────────────────────── */
#background.layout-landscape {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}

#background.layout-landscape #ui {
  width: 210px;
  height: 100vh;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  border-bottom: none;
  border-right: 1px solid var(--glass-border);
  flex-shrink: 0;
}

#background.layout-landscape .canvas-frame {
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
  flex: 1;
  height: 100vh;
  align-items: flex-end;
  justify-content: center;
  padding: 8px;
}

/* ─── Responsive: Tablet ────────────────────────────────────────────────── */
@media only screen and (min-width: 700px) and (max-width: 1023px) {
  .menu {
    max-width: 600px;
  }
}

/* ─── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .orb,
  .orb-a,
  .orb-b,
  .orb-c,
  .orb-d {
    animation: none;
  }

  button,
  .element-btn,
  .submission {
    transition: none;
  }
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ─── Selection ─────────────────────────────────────────────────────────── */
::selection {
  background: rgba(212, 175, 55, 0.25);
  color: #fff5dc;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Cabinet Side Panels — Radio, Chat, Presence
   ═══════════════════════════════════════════════════════════════════════════ */

.side-panel {
  position: fixed;
  top: 56px;
  right: 0;
  width: 280px;
  max-width: 80vw;
  max-height: calc(100vh - 64px);
  z-index: 30;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-right: none;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(0,0,0,0.3);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: panel-slide-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow-y: auto;
}

@keyframes panel-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.side-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
}

.side-panel-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  font-size: 16px;
  color: var(--text-muted);
}

/* ─── Radio Panel ───────────────────────────────────────────────────────── */
.radio-panel .radio-track {
  text-align: center;
  padding: 8px 0;
}

.radio-track-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.radio-track-num {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.radio-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.radio-play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.15);
  border-color: rgba(212, 175, 55, 0.4);
}

.radio-play-btn:hover {
  background: rgba(212, 175, 55, 0.25);
}

.radio-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.radio-volume input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  outline: none;
}

.radio-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.radio-viz-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding-top: 4px;
}

/* ─── Chat Panel ────────────────────────────────────────────────────────── */
.chat-panel .chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  max-height: 320px;
  padding-right: 4px;
}

.chat-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px 0;
  font-style: italic;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.chat-user {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.chat-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--glass-border);
}

.chat-input-row input {
  flex: 1;
  height: 32px;
  font-size: 13px;
}

.chat-input-row button {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
}

/* ─── Presence ──────────────────────────────────────────────────────────── */
.presence-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.presence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5a9e6e;
  box-shadow: 0 0 6px rgba(90, 158, 110, 0.5);
  animation: presence-pulse 2s ease-in-out infinite;
}

@keyframes presence-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.presence-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.presence-cursor {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: left 0.15s ease-out, top 0.15s ease-out;
  pointer-events: none;
}

.presence-cursor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 8px currentColor;
}

.presence-cursor-name {
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}


/* ─── Hide dat.gui panel ───────────────────────────────────────────────── */
.dg.ac {
  display: none !important;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Cabinet UI Overhaul — Mobile Drawer, Categories, Tooltips, Fullscreen
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Toolbar Wrapper ───────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

/* ─── Hide Mobile Utility ───────────────────────────────────────────────── */
.hide-mobile {
  display: inherit;
}

/* ─── Mobile Toolbar Row ────────────────────────────────────────────────── */
.mobile-toolbar-row {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--glass-border);
}

/* ─── Mobile Drawer ─────────────────────────────────────────────────────── */
.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 4, 8, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: scrim-in 0.2s ease-out;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mobile-drawer {
  width: 100%;
  max-height: 70vh;
  background: var(--bg-elevated);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  animation: drawer-up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes drawer-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-drawer-content {
  overflow-y: auto;
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-category {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-left: 2px;
}

.mobile-category-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── Compact Element Buttons (mobile drawer) ───────────────────────────── */
.element-btn.compact {
  font-size: 11px;
  padding: 0 8px;
  height: 28px;
}

.element-btn.compact::before {
  width: 5px;
  height: 5px;
  left: 5px;
}

/* ─── Chat Meta / Timestamps ────────────────────────────────────────────── */
.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-time {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: auto;
}

/* ─── Tooltip Enhancement ───────────────────────────────────────────────── */
.element-btn[title]::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.element-btn[title]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ─── Fullscreen Adjustments ────────────────────────────────────────────── */
:fullscreen #background {
  background: var(--bg-deep);
}

:fullscreen #ui {
  background: rgba(8, 8, 12, 0.85);
}

:fullscreen .canvas-frame {
  padding: 4px;
}

/* ─── Responsive: Mobile Overrides ──────────────────────────────────────── */
@media only screen and (max-width: 699px) {
  .hide-mobile {
    display: none !important;
  }

  .mobile-toolbar-row {
    display: flex;
  }

  .toolbar {
    gap: 4px;
  }

  .element-palette {
    display: none;
  }

  .side-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 55vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--glass-border);
    border-bottom: none;
    animation: drawer-up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  @keyframes panel-slide-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .presence-indicator {
    font-size: 11px;
    padding: 2px 6px;
  }

  .submission-title {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ─── Landscape Sidebar: maintain palette visibility ────────────────────── */
#background.layout-landscape .mobile-toolbar-row {
  display: none;
}

#background.layout-landscape .element-palette {
  display: flex;
}

#background.layout-landscape .hide-mobile {
  display: inherit;
}
