:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0c0d10;
  color: #f4f5f7;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  background:
    linear-gradient(180deg, rgba(13, 16, 20, 0.2), rgba(13, 16, 20, 0.88)),
    #0c0d10;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#viewport:active {
  cursor: grabbing;
}

.control-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(380px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(17, 19, 24, 0.86);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 720;
  letter-spacing: 0;
}

.panel-header p {
  margin: 5px 0 0;
  color: #a9b0bd;
  font-size: 13px;
}

button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 0 12px;
  color: #f7f8fb;
  background: #262b32;
  cursor: pointer;
}

button:hover {
  border-color: rgba(109, 213, 186, 0.8);
  background: #303741;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.stats-grid div {
  min-height: 58px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.stats-grid span,
.panel-footer span {
  display: block;
  color: #96a0ad;
  font-size: 12px;
}

.stats-grid strong {
  display: block;
  margin-top: 6px;
  color: #ffffff;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.control-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d9dde4;
  font-size: 13px;
}

output {
  color: #75d8bb;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: #75d8bb;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.error-box {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(620px, calc(100vw - 40px));
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 1px solid rgba(255, 124, 124, 0.65);
  border-radius: 8px;
  background: rgba(34, 18, 18, 0.94);
  color: #ffd9d9;
  line-height: 1.5;
}

@media (max-width: 780px) {
  .control-panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-height: 48vh;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(80px, 1fr));
  }
}
