﻿:root {
  --bg: #0a0a1a;
  --accent: #00f5ff;
  --danger: #ff3366;
  --text: #e0e0e0;
  --panel-bg: rgba(10, 10, 30, 0.85);
  --line: rgba(0, 245, 255, 0.2);
  --muted: rgba(224, 224, 224, 0.5);
}

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

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

body {
  position: relative;
  color: var(--text);
  background: var(--bg);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #0a0a2e 0%, #000000 70%);
  animation: hueShift 60s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(0, 245, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 245, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, transparent, black 25%, black 75%, transparent);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#app,
#webgl {
  position: fixed;
  inset: 0;
}

#webgl {
  display: block;
  z-index: 0;
  width: 100%;
  height: 100%;
}

.panel {
  position: fixed;
  z-index: 10;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-bg);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.title-block {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 12;
  width: max-content;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.title-block h1 {
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(0, 245, 255, 0.5);
}

.title-block p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

#hud {
  top: 20px;
  left: 20px;
  min-width: 235px;
  padding: 15px;
  opacity: 0.9;
}

.hud-brand {
  color: var(--accent);
  font-size: 11px;
  line-height: 1.5;
}

.hud-line {
  height: 1px;
  margin: 10px 0;
  background: rgba(0, 245, 255, 0.2);
}

.hud-stat {
  margin: 6px 0;
  color: var(--text);
  font-size: 11px;
  opacity: 0.8;
}

.hud-stat strong {
  color: var(--accent);
  font-weight: 400;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hud-button {
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid rgba(0, 245, 255, 0.35);
  border-radius: 5px;
  color: var(--accent);
  background: rgba(0, 245, 255, 0.05);
  cursor: pointer;
  transition: 0.2s ease;
}

.hud-button:hover {
  border-color: var(--accent);
  background: rgba(0, 245, 255, 0.16);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.25);
}

.reset-button {
  font-size: 10px;
  letter-spacing: 0.5px;
}

#shape-switcher {
  top: 20px;
  left: 50%;
  display: flex;
  gap: 4px;
  padding: 5px;
  transform: translateX(-50%);
}

.shape-button {
  padding: 8px 11px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  background: transparent;
  font-size: 10px;
  cursor: pointer;
  transition: 0.2s ease;
}

.shape-button:hover,
.shape-button.active {
  color: #001416;
  background: var(--accent);
  box-shadow: 0 0 15px rgba(0, 245, 255, 0.35);
}

#materials-panel {
  top: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  width: 260px;
  max-height: calc(100vh - 160px);
  padding: 14px;
}

#materials-panel h2 {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 3px;
}

#materials-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

#materials-list::-webkit-scrollbar {
  width: 4px;
}

#materials-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

#materials-list::-webkit-scrollbar-thumb {
  border-radius: 5px;
  background: var(--accent);
}

.material-card {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  text-align: left;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: all 0.2s ease;
}

.material-card:hover {
  border-color: var(--accent);
  transform: translateX(-4px);
}

.material-card.selected {
  border-color: var(--accent);
  background: rgba(0, 245, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 245, 255, 0.2);
}

.material-icon {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  font-size: 18px;
}

.material-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.material-name {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-density {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mass-control {
  margin-top: 12px;
}

.mass-control label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
}

.mass-control label strong {
  color: var(--accent);
  font-weight: 400;
}

#mass-slider {
  width: 100%;
  height: 4px;
  appearance: none;
  border-radius: 3px;
  outline: none;
  background: linear-gradient(90deg, var(--accent), #175066);
  cursor: pointer;
}

#mass-slider::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  appearance: none;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

#mass-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

#throw-button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  background: linear-gradient(135deg, #00f5ff22, #00f5ff44);
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#throw-button:hover {
  box-shadow: 0 0 20px rgba(0, 245, 255, 0.4);
  transform: scale(1.02);
}

#throw-button:active {
  transform: scale(0.95);
}

#author {
  position: fixed;
  right: 20px;
  bottom: 15px;
  z-index: 10;
  color: #666;
  font-size: 9px;
  opacity: 0.25;
  transition: opacity 0.3s ease;
}

#author:hover {
  opacity: 0.6;
}

#toast-container {
  position: fixed;
  top: 82px;
  left: 50%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 30px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  background: rgba(5, 20, 35, 0.92);
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.2);
  animation: slideIn 0.25s ease, fadeOut 0.5s ease 1.7s forwards;
}

.toast.danger {
  border-color: var(--danger);
  color: var(--danger);
  animation: slideIn 0.25s ease, shake 0.35s ease 0.25s, fadeOut 0.5s ease 1.7s forwards;
}

#overflow-warning,
#performance-warning {
  position: fixed;
  left: 50%;
  z-index: 20;
  display: none;
  color: var(--danger);
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 51, 102, 0.7);
  transform: translateX(-50%);
}

#overflow-warning {
  top: 145px;
  animation: pulse 0.8s infinite;
}

#performance-warning {
  bottom: 15px;
  font-size: 10px;
}

#overflow-warning.visible,
#performance-warning.visible {
  display: block;
}

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #050510;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
  visibility: hidden;
  opacity: 0;
}

.loading-content {
  text-align: center;
}

.loading-title {
  color: var(--accent);
  font-size: 18px;
  letter-spacing: 3px;
  text-shadow: 0 0 18px rgba(0, 245, 255, 0.6);
}

.loading-subtitle {
  margin-top: 18px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1px;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 22px auto 0;
  border: 3px solid rgba(0, 245, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes hueShift {
  0%,
  100% {
    filter: hue-rotate(0deg);
  }

  50% {
    filter: hue-rotate(20deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

@keyframes glow {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.5);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }

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

@media (max-width: 768px) {
  .title-block {
    top: 15px;
  }

  .title-block h1 {
    font-size: 14px;
    letter-spacing: 2px;
  }

  .title-block p {
    font-size: 9px;
  }

  #hud {
    top: 15px;
    left: 12px;
    min-width: 175px;
    padding: 10px;
  }

  .hud-brand {
    font-size: 9px;
  }

  .hud-stat {
    font-size: 10px;
  }

  #shape-switcher {
    top: 61px;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
  }

  .shape-button {
    padding: 7px 8px;
    font-size: 9px;
    white-space: nowrap;
  }

  #materials-panel {
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: none;
    height: 180px;
    padding: 9px 12px;
    border-right: 0;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
  }

  #materials-panel h2 {
    margin-bottom: 7px;
    font-size: 11px;
  }

  #materials-list {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .material-card {
    width: 150px;
    min-width: 150px;
    margin-bottom: 0;
    padding: 7px;
  }

  .mass-control {
    margin-top: 8px;
  }

  #throw-button {
    position: absolute;
    right: 12px;
    bottom: 13px;
    width: 38%;
    margin: 0;
    padding: 10px 5px;
    font-size: 11px;
  }

  .mass-control {
    width: 55%;
  }

  #author {
    right: 10px;
    bottom: 188px;
  }

  #overflow-warning {
    top: 145px;
    font-size: 10px;
  }

  .material-card:hover,
  #throw-button:hover,
  .hud-button:hover,
  .shape-button:hover {
    transform: none;
    box-shadow: none;
  }
}

@media (max-width: 480px) {
  .title-block h1 {
    font-size: 14px;
    letter-spacing: 1px;
  }

  .title-block p {
    display: none;
  }

  #hud {
    min-width: 120px;
  }

  .hud-brand,
  .hud-stat:nth-of-type(1),
  .hud-stat:nth-of-type(4),
  .hud-line:first-of-type {
    display: none;
  }

  .hud-stat {
    margin: 3px 0;
    font-size: 9px;
  }

  .hud-actions {
    margin-top: 4px;
  }

  .reset-button {
    display: none;
  }

  #shape-switcher {
    top: 57px;
    left: auto;
    right: 10px;
    transform: none;
  }

  .shape-button {
    padding: 6px;
    font-size: 0;
  }

  .shape-button::first-letter {
    font-size: 14px;
  }

  #materials-panel {
    height: 150px;
  }

  .material-card {
    width: 125px;
    min-width: 125px;
  }

  .material-name {
    font-size: 10px;
  }

  .material-density {
    font-size: 8px;
  }

  #throw-button {
    width: 42%;
    font-size: 10px;
  }

  .mass-control {
    width: 52%;
  }

  #author {
    display: none;
  }
}

@media (pointer: coarse) {
  .material-card:hover,
  #throw-button:hover,
  .hud-button:hover,
  .shape-button:hover {
    border-color: initial;
    transform: none;
    box-shadow: none;
  }
}
