/* styles.css — layout, control panel, fallback/error messages. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #12131a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f2efe9;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#app canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#ui-root > * {
  pointer-events: auto;
}

/* ---- Control panel ---- */

.panel {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 232px;
  max-width: calc(100vw - 28px);
  padding: 14px 14px 12px;
  background: rgba(18, 19, 26, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  line-height: 1.4;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel__title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  margin: 0;
}

.panel__toggle {
  display: none;
}

.panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.panel__row:last-child {
  margin-bottom: 0;
}

.panel__label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.panel__label[for] {
  cursor: pointer;
}

.panel__value {
  font-variant-numeric: tabular-nums;
  color: #b9c4d6;
  min-width: 34px;
  text-align: right;
}

.panel__button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2efe9;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.panel__button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
}

.panel__button:active {
  transform: translateY(1px);
}

.panel__button[aria-pressed="true"] {
  background: #c9784a;
  border-color: #e08a58;
  color: #1a1210;
}

.panel__button:focus-visible,
.panel__input:focus-visible,
.panel__checkbox:focus-visible,
.panel__button:focus-visible {
  outline: 2px solid #7fb0e8;
  outline-offset: 2px;
}

.panel__buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 9px;
}

.panel__sub-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b93a6;
  margin: 2px 0 6px;
}

.panel__input[type="range"] {
  flex: 1;
  accent-color: #c9784a;
  width: 100%;
}

.panel__checkbox {
  accent-color: #c9784a;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.panel__hint {
  margin: 10px 0 0;
  font-size: 10.5px;
  color: #8b93a6;
  line-height: 1.5;
}

.panel--collapsed {
  width: auto;
  padding: 6px 10px;
}

.panel--collapsed .panel__content {
  display: none;
}

.panel--collapsed .panel__toggle {
  display: inline-block;
}

.panel__collapse-btn {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2efe9;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.panel__collapse-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ---- Fallback / error card ---- */

.fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  background: rgba(12, 13, 18, 0.85);
}

/* Author display rules must not shadow the UA [hidden] rule used by the guard. */
.fallback[hidden] {
  display: none !important;
}

.fallback-card {
  max-width: 460px;
  padding: 26px 28px;
  background: rgba(24, 25, 33, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.fallback-card h1 {
  font-size: 18px;
  margin: 0 0 10px;
  font-weight: 650;
}

.fallback-card p {
  margin: 6px 0;
  font-size: 13px;
  color: #d7dce6;
  line-height: 1.55;
}

.fallback-card .fallback-hint {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #f0d58a;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 12px;
  word-break: break-word;
}

.noscript .fallback {
  position: relative;
  margin: 12px auto;
  background: transparent;
}

/* ---- Debug panel ---- */

.debug {
  position: absolute;
  bottom: 12px;
  left: 14px;
  width: 260px;
  max-width: calc(100vw - 28px);
  padding: 10px 12px;
  background: rgba(18, 19, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-size: 11px;
  z-index: 20;
}

.debug h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b93a6;
}

.debug__row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.debug__row label {
  flex: 0 0 66px;
  color: #cdd3df;
}

.debug__row input[type="range"] {
  flex: 1;
  accent-color: #c9784a;
}

.debug__row .debug__val {
  flex: 0 0 42px;
  text-align: right;
  color: #b9c4d6;
  font-variant-numeric: tabular-nums;
}

.debug__readout {
  margin-top: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: #9fb0c9;
  line-height: 1.5;
  white-space: pre;
}

.debug__close {
  margin-top: 8px;
}

/* ---- Small screens: collapse the panel ---- */

@media (max-width: 520px) {
  .panel .panel__content {
    display: none;
  }
  .panel .panel__collapse-btn {
    display: inline-block;
  }
  .panel {
    width: auto;
    padding: 6px 10px;
  }
}
