:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d7ded8;
  --green: #18885b;
  --teal: #0f766e;
  --blue: #245cc7;
  --amber: #c98215;
  --red: #c33f38;
  --shadow: 0 18px 40px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
  width: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid #bfc9c1;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  border-color: var(--teal);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}

#randomizeInteractive,
.tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 18px 0;
}

.view {
  display: none;
  padding: 14px 18px 18px;
}

.view.active {
  display: block;
}

.interactive-shell {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 340px;
  grid-template-areas:
    "board controls";
  gap: 16px;
  max-width: 1320px;
  margin: 0 auto;
  align-items: start;
}

.gallery-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

.layer-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.layer-panel h2 {
  margin-bottom: 2px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-weight: 760;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.toggle-row span {
  display: flex;
  align-items: center;
  min-width: 0;
}

.swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(23, 32, 51, 0.18);
}

.swatch.amber { background: #f59e0b; }
.swatch.red { background: #d94343; }
.swatch.sand { background: #c69c58; }
.swatch.blue { background: #2563eb; }
.swatch.gold { background: #d39a1e; }
.swatch.cyan { background: #1f9bb4; }

.focus-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.focus-choice.active {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.gallery-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.scene-frame-wrap {
  position: relative;
  width: 100%;
  height: 560px;
  overflow: hidden;
  background: white;
}

.scene-frame-wrap iframe {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.board,
.controls {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.board {
  grid-area: board;
  position: relative;
  overflow: hidden;
}

.view-reset-button {
  position: absolute;
  z-index: 6;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.12);
  font-size: 0.82rem;
}

.gallery-view-reset {
  top: 14px;
  right: 14px;
}

.hud {
  display: grid;
  grid-template-columns: 1fr;
  border-bottom: 1px solid var(--line);
}

.hud div {
  padding: 12px 16px;
  border-right: 1px solid var(--line);
}

.hud div:last-child {
  border-right: 0;
}

.hud span,
.controls label > span,
.meters span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #eef4f0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.controls {
  grid-area: controls;
  padding: 16px;
}

.controls label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5ce;
  border-radius: 8px;
  padding: 0 10px;
  background: white;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.meters {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.meters div {
  display: grid;
  grid-template-columns: 88px 1fr 34px;
  align-items: center;
  gap: 8px;
}

meter {
  width: 100%;
  height: 16px;
}

.feedback {
  min-height: 56px;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 6px;
  background: #eaf6f3;
  line-height: 1.45;
}

@media (max-width: 940px) {
  .interactive-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "board"
      "controls";
  }
}

@media (max-width: 720px) {
  .gallery-shell {
    grid-template-columns: 1fr;
  }

  .layer-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layer-panel h2,
  .focus-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .mode-tabs,
  .view {
    padding: 10px;
  }

  .mode-tabs {
    justify-content: stretch;
    padding-bottom: 0;
  }

  .mode-tabs .tab {
    flex: 1 1 0;
  }

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

  .hud {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .hud div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

}
