:root {
  --bg: #f6f2e8;
  --ink: #241d16;
  --muted: #766b5f;
  --line: rgba(36, 29, 22, 0.18);
  --panel: rgba(255, 252, 245, 0.9);
  --accent: #b26a28;
  --accent-dark: #7a431b;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#viewport {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

#app {
  position: relative;
}

#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.github-corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: 230px;
  height: 230px;
  color: #fff8ed;
  text-decoration: none;
  overflow: hidden;
}

.github-corner::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 84px;
  height: 84px;
  content: "";
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(122, 67, 27, 0.34));
  border-bottom: 1px solid rgba(122, 67, 27, 0.24);
  border-left: 1px solid rgba(122, 67, 27, 0.18);
  box-shadow: -10px 10px 22px rgba(50, 38, 22, 0.18);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.github-corner::after {
  position: absolute;
  top: 54px;
  right: -53px;
  width: 238px;
  height: 1px;
  content: "";
  background: rgba(255, 255, 255, 0.36);
  transform: rotate(45deg);
}

.github-corner__content {
  position: absolute;
  top: 38px;
  right: -61px;
  width: 246px;
  min-height: 46px;
  display: grid;
  gap: 2px;
  place-content: center;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  border-top: 1px solid rgba(255, 255, 255, 0.26);
  border-bottom: 1px solid rgba(36, 29, 22, 0.28);
  box-shadow: 0 14px 34px rgba(50, 38, 22, 0.28);
  text-align: center;
  text-transform: uppercase;
  transform: rotate(45deg);
}

.github-corner__title {
  font-size: 16px;
  font-weight: 900;
}

.github-corner__subtitle {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.84;
}

.github-corner:hover::before,
.github-corner:focus-visible::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.76), rgba(178, 106, 40, 0.42));
}

.github-corner:hover .github-corner__content,
.github-corner:focus-visible .github-corner__content {
  background: linear-gradient(135deg, #8c4f22, #c57930);
}

.github-corner:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: -12px;
}

.panel {
  position: absolute;
  left: 18px;
  top: 18px;
  width: min(390px, calc(100vw - 36px));
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(50, 38, 22, 0.18);
  backdrop-filter: blur(14px);
}

.panel-heading,
.panel-copy,
.timeline-control,
.display-controls__body,
.opacity-controls {
  display: grid;
}

.panel-heading {
  gap: 12px;
}

.panel-copy {
  min-width: 0;
}

.panel-kicker {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 5px;
}

.label {
  margin: 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: 0;
}

.note {
  min-height: 44px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.transport {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
}

.timeline-control,
.opacity-controls {
  gap: 6px;
}

.display-controls {
  min-width: 0;
}

.display-controls > summary {
  display: none;
}

.display-controls__body {
  gap: 12px;
  padding-top: 2px;
}

button {
  height: 38px;
  border: 1px solid rgba(122, 67, 27, 0.28);
  border-radius: 7px;
  background: #fff8ed;
  color: var(--accent-dark);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #fff0d9;
}

.range-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.value-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

output {
  min-width: 42px;
  color: var(--accent-dark);
  text-align: right;
}

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

.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.toggles label {
  display: flex;
  gap: 7px;
  align-items: center;
}

.toggles input {
  accent-color: var(--accent);
}

#loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

html.is-embedded .github-corner {
  top: auto;
  right: 10px;
  bottom: 10px;
  width: auto;
  height: auto;
  padding: 8px 11px;
  background: var(--accent-dark);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  box-shadow: 0 10px 24px rgba(50, 38, 22, 0.2);
}

html.is-embedded .github-corner::before,
html.is-embedded .github-corner::after {
  display: none;
}

html.is-embedded .github-corner__content {
  position: static;
  width: auto;
  min-height: 0;
  display: flex;
  gap: 6px;
  align-items: baseline;
  background: transparent;
  border: 0;
  box-shadow: none;
  transform: none;
}

html.is-embedded .github-corner__title {
  font-size: 11px;
}

html.is-embedded .github-corner__subtitle {
  font-size: 9px;
}

html.is-embedded .panel {
  left: 10px;
  right: 10px;
  top: 10px;
  width: auto;
  max-height: calc(100% - 20px);
  gap: 8px;
  padding: 11px;
  overflow: auto;
}

html.is-embedded .panel-heading {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

html.is-embedded .panel-kicker,
html.is-embedded .note {
  display: none;
}

html.is-embedded h1 {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

html.is-embedded .transport {
  display: flex;
  gap: 6px;
}

html.is-embedded button {
  width: 58px;
  height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

html.is-embedded .timeline-control {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

html.is-embedded .timeline-control .range-label {
  margin: 0;
  font-size: 11px;
}

html.is-embedded .display-controls {
  border-top: 1px solid var(--line);
}

html.is-embedded .display-controls > summary {
  display: block;
  padding: 8px 2px 0;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

html.is-embedded .display-controls__body {
  gap: 10px;
  padding-top: 8px;
}

html.is-embedded .display-controls:not([open]) .display-controls__body {
  display: none;
}

html.is-embedded .toggles {
  font-size: 12px;
}

@media (max-width: 720px) {
  .github-corner {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: auto;
    height: auto;
    padding: 10px 13px;
    background: var(--accent-dark);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    box-shadow: 0 12px 28px rgba(50, 38, 22, 0.22);
    filter: none;
  }

  .github-corner::before,
  .github-corner::after {
    display: none;
  }

  .github-corner__content {
    position: static;
    width: auto;
    display: flex;
    gap: 7px;
    align-items: baseline;
    transform: none;
  }

  .github-corner__title {
    font-size: 12px;
  }

  .github-corner__subtitle {
    font-size: 10px;
  }

  .panel {
    left: 10px;
    right: 10px;
    top: 10px;
    width: auto;
    padding: 12px;
  }

  h1 {
    font-size: 19px;
  }

  .note {
    min-height: 38px;
    font-size: 13px;
  }
}
