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

* {
  box-sizing: border-box;
}

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

body {
  background: #111413;
}

[hidden] {
  display: none !important;
}

.app {
  position: relative;
}

#viewerFrame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #8fc0df;
  touch-action: none;
  user-select: none;
}

.panel {
  position: absolute;
  top: 16px;
  left: 16px;
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(18, 22, 21, 0.86);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.panel :is(a, button, input, select, textarea, label) {
  pointer-events: auto;
}

:focus-visible {
  outline: 2px solid #8fd7ff;
  outline-offset: 3px;
}

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

.brand-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: #a9b4ad;
  font-size: 12px;
}

a,
button,
input,
select {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #202623;
  color: #f7f2ea;
  font: inherit;
}

a,
button {
  display: grid;
  place-items: center;
  text-decoration: none;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: #a9b4ad;
}

select {
  width: 100%;
  padding: 0 10px;
}

input {
  width: 100%;
  padding: 0 10px;
}

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

.stats > div {
  min-width: 0;
  padding: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.stats span {
  display: block;
  color: #a9b4ad;
  font-size: 11px;
}

.stats strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  padding: 0 12px;
}

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

.toolbar button,
.chat-form button,
.admin-login button {
  background: #d9f07f;
  color: #172014;
  font-weight: 700;
}

.chat-form {
  display: grid;
  gap: 8px;
}

.admin-panel {
  left: auto;
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: auto;
}

.admin-gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 14, 13, 0.58);
  backdrop-filter: blur(10px);
}

.admin-login {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(18, 22, 21, 0.94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

@media (max-width: 680px) {
  .panel {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    padding: 10px;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stats > div {
    padding: 8px;
  }

  .admin-panel {
    right: 10px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }
}

body[data-hud="hidden"] .panel {
  display: none;
}

body[data-hud="compact"] .panel {
  width: min(260px, calc(100vw - 20px));
}

body[data-hud="compact"] .stats {
  display: none;
}
