:root {
  --bg: #FFEDD5;
  --bg-2: #fed7aa;
  --panel: rgba(0, 0, 0, 0.9);
  --panel-strong: rgba(0, 0, 0, 0.96);
  --panel-soft: rgba(23, 23, 23, 0.74);
  --border: rgba(127, 29, 29, 0.56);
  --border-soft: rgba(127, 29, 29, 0.36);
  --red: #ef4444;
  --red-deep: #7f1d1d;
  --red-soft: rgba(127, 29, 29, 0.34);
  --amber: #f59e0b;
  --green: #10b981;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --muted-2: #737373;
  --scene-light: #FDFDFC;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, color-mix(in srgb, var(--scene-light) 28%, transparent), transparent 28%),
    radial-gradient(circle at 84% 12%, color-mix(in srgb, var(--scene-light) 24%, transparent), transparent 30%),
    var(--bg);
}

.viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.interface {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 320px);
  gap: 16px;
}

.stats-panel,
.sidebar,
.info-panel,
.mobile-hint {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.stats-panel {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 22px;
  align-items: center;
  padding: 12px 26px;
  border-radius: 22px;
  text-align: center;
}

.stat {
  min-width: 78px;
}

.stat-title {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  color: #ffffff;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 22px;
  line-height: 1;
}

.stat-value.red {
  color: var(--red);
}

.divider {
  width: 1px;
  height: 34px;
  background: var(--border);
}

.sidebar,
.info-panel {
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 24px;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--red-deep) transparent;
}

.sidebar {
  grid-column: 1;
}

.info-panel {
  grid-column: 3;
}

.panel-title {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.panel-copy {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.control-group {
  margin-bottom: 24px;
}

.control-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.option-list,
.mode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-btn,
.mode-btn,
.reset-btn {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  color: #d4d4d4;
  background: rgba(23, 23, 23, 0.58);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.control-btn:hover,
.mode-btn:hover,
.reset-btn:hover {
  transform: translateY(-1px);
  background: rgba(38, 38, 38, 0.78);
}

.control-btn.active,
.mode-btn.active {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(127, 29, 29, 0.32);
}

.mode-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  color: var(--muted-2);
  font-weight: 800;
}

.mode-btn.active .mode-icon {
  color: #f87171;
}

.range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scale-value {
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  margin-top: 12px;
  accent-color: var(--red);
  appearance: none;
  border-radius: 999px;
  background: #262626;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.16);
}

.color-control-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.color-control {
  min-height: 46px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  padding: 10px 12px;
  color: #d4d4d4;
  background: rgba(23, 23, 23, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.color-label {
  font-size: 13px;
  font-weight: 700;
}

.color-value {
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  text-transform: uppercase;
}

input[type="color"] {
  width: 36px;
  height: 30px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 8px;
}

.mini-reset-btn {
  width: 100%;
  min-height: 34px;
  border-radius: 12px;
  color: var(--red);
  background: rgba(127, 29, 29, 0.18);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 160ms ease, background 160ms ease;
}

.mini-reset-btn:hover {
  transform: translateY(-1px);
  background: rgba(127, 29, 29, 0.3);
}

.reset-wrap {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
}

.reset-btn {
  justify-content: center;
  color: var(--red);
  border-color: var(--border-soft);
  background: rgba(23, 23, 23, 0.72);
}

.info-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.info-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  color: var(--red);
  background: rgba(127, 29, 29, 0.28);
  border: 1px solid rgba(239, 68, 68, 0.22);
  font-weight: 800;
}

.info-title {
  margin: 0;
  color: var(--red);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.info-block {
  margin: 0 0 20px;
}

.info-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.info-text {
  margin: 0;
  color: #d4d4d4;
  font-size: 14px;
  line-height: 1.68;
}

.callout,
.action-box,
.energy-box {
  border-radius: 18px;
  padding: 16px;
}

.callout {
  background: rgba(23, 23, 23, 0.54);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 16px rgba(0, 0, 0, 0.2);
}

.action-box {
  background: rgba(127, 29, 29, 0.23);
  border: 1px solid rgba(153, 27, 27, 0.52);
}

.energy-box {
  margin-top: 20px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(38, 38, 38, 0.92);
}

.energy-bar {
  width: 100%;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #171717;
  border: 1px solid #262626;
}

.energy-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #10b981, #f59e0b, #dc2626);
  transition: width 500ms ease;
}

.energy-scale {
  display: flex;
  justify-content: space-between;
  margin: 8px 0 12px;
  color: #737373;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mobile-hint {
  display: none;
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  color: #d4d4d4;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .viewer {
    position: fixed;
    height: 100vh;
  }

  .interface {
    position: relative;
    min-height: 100vh;
    grid-template-columns: 1fr;
    align-content: end;
    padding-top: 96px;
  }

  .sidebar,
  .info-panel {
    grid-column: 1;
    max-height: none;
  }

  .stats-panel {
    width: calc(100% - 32px);
    grid-template-columns: 1fr 1px 1fr 1px 1fr;
    gap: 10px;
    padding-inline: 12px;
  }

  .stat {
    min-width: 0;
  }

  .stat-title {
    font-size: 8px;
  }

  .stat-value {
    font-size: 18px;
  }

  .mobile-hint {
    display: block;
  }
}
