:root {
  color-scheme: dark;
  --bg: #0c0b0e;
  --panel: #17151c;
  --border: #3a3244;
  --accent: #c89b4f;
  --ink: #ece6d8;
  --muted: #a89f8d;
  --error: #ffd5cf;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-width: 280px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse at 50% 42%, #1d1826 0%, #100e14 55%, #09080b 100%);
}

.player {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100dvh;
  padding: 0 clamp(8px, 2.4vw, 28px);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.account-link {
  align-self: center;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 4px;
  text-decoration: none;
}

.account-link:hover,
.account-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.account-link[hidden] { display: none; }

.utility-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  background: var(--panel);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.utility-button:hover:not(:disabled),
.utility-button:focus-visible {
  border-color: var(--accent);
  color: #fff3d6;
  outline: none;
}

.utility-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.utility-button[hidden] { display: none; }

.feedback-anchor {
  display: inline-flex;
  align-items: center;
}

.toolbar .px-feedback-button,
.toolbar .px-feedback-entry {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  background: var(--panel);
}

.toolbar .px-feedback-button:hover:not(:disabled),
.toolbar .px-feedback-button:focus-visible,
.toolbar .px-feedback-entry:hover:not(:disabled),
.toolbar .px-feedback-entry:focus-visible {
  border-color: var(--accent);
  color: #fff3d6;
}

.recovery-status {
  margin: 0;
  padding: 3px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.recovery-status:empty { padding: 0; }

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px 0;
}

.screen-frame {
  position: relative;
  width: var(--screen-width, min(100%, 96vh));
  height: var(--screen-height, auto);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  box-shadow: 0 18px 64px #000a, 0 0 0 1px var(--border);
  overflow: hidden;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}

.status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--ink);
  background: #0c0b0ee8;
  text-align: center;
  font-size: clamp(13px, 2vw, 16px);
  line-height: 1.55;
}

.status[hidden] { display: none; }

.error {
  color: var(--error);
  background: #1a0f12f2;
  white-space: pre-wrap;
}

.setup-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #0c0b0ef0;
  overflow-y: auto;
}

.setup-overlay[hidden] { display: none; }

.setup-card {
  width: min(100%, 540px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 22px;
  box-shadow: 0 16px 40px #0009;
}

.setup-card h1 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.setup-card p {
  margin: 8px 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.setup-muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.setup-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #25202e;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.setup-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #14100a;
  font-weight: 600;
}

.setup-button[hidden] { display: none; }
.setup-overlay input[type="file"] { display: none; }

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.touch-hint { display: none; }

@media (pointer: coarse) {
  .desktop-hint { display: none; }
  .touch-hint { display: inline; }
  .account-link { min-height: 44px; display: inline-flex; align-items: center; }
}

@media (max-width: 520px) {
  .player { padding: 0 8px; }
  .brand { font-size: 12px; letter-spacing: 0.12em; }
  .toolbar { min-height: 48px; }
  .toolbar-actions { gap: 4px; }
  .utility-button { padding: 0 8px; font-size: 11px; }
  .account-link { font-size: 11px; }
  .stage { padding: 6px 0; }
}

@media (max-height: 440px) {
  .toolbar { min-height: 44px; padding: 2px 0; }
  .stage { padding: 4px 0; }
  .footer { min-height: 22px; padding: 2px 0; font-size: 10px; }
}
