:root {
  color-scheme: dark;
  --bg: #080a08;
  --panel: #111610;
  --panel-2: #171d15;
  --paper: #d8d0b5;
  --text: #f1ead2;
  --muted: #a89f85;
  --line: rgba(216, 208, 181, 0.24);
  --accent: #d43d2f;
  --accent-2: #d6a63d;
  --good: #77bd6d;
  --warn: #d6a63d;
  --bad: #d43d2f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --mono: "Courier New", Courier, monospace;
  --sans: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(212, 61, 47, 0.16), transparent 28rem),
    radial-gradient(circle at 90% 10%, rgba(214, 166, 61, 0.12), transparent 24rem),
    var(--bg);
  background-size: 44px 44px, 44px 44px, auto, auto, auto;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.03) 0,
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.25;
}

button,
textarea,
input,
.admin-link {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.classification-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-bottom: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
  box-shadow: var(--shadow);
}

.classification-strip span {
  min-width: 0;
  padding: 10px 12px;
  color: var(--paper);
  background: rgba(17, 22, 16, 0.86);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 0.75fr);
  gap: 44px;
  align-items: center;
}

.hero-copy {
  position: relative;
  min-height: 420px;
  padding: 44px 0;
}

.hero-copy::after {
  position: absolute;
  right: 8%;
  bottom: 10%;
  width: 170px;
  height: 170px;
  border: 3px double rgba(212, 61, 47, 0.58);
  border-radius: 50%;
  content: "NO CONFIRMADO";
  display: grid;
  place-items: center;
  color: rgba(212, 61, 47, 0.8);
  font-family: var(--mono);
  font-weight: 700;
  text-align: center;
  transform: rotate(-16deg);
}

.stamp,
.result-label,
.privacy-note,
.admin-note,
.table-meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
}

h1 {
  max-width: 760px;
  margin: 16px 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.2rem, 9vw, 7.5rem);
  font-weight: 700;
  line-height: 0.9;
}

.subtitle {
  max-width: 620px;
  margin: 0;
  color: var(--paper);
  font-size: clamp(1.1rem, 2.2vw, 1.55rem);
  line-height: 1.45;
}

.dossier,
.result-panel,
.admin-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(216, 208, 181, 0.08), transparent 42%),
    rgba(17, 22, 16, 0.92);
  box-shadow: var(--shadow);
}

.dossier {
  padding: 24px;
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.86rem;
  text-transform: uppercase;
}

textarea,
input[type="password"],
input[type="text"],
input:not([type]) {
  width: 100%;
  border: 1px solid rgba(216, 208, 181, 0.32);
  border-radius: 0;
  color: var(--text);
  background: rgba(3, 5, 3, 0.58);
  outline: none;
}

textarea {
  min-height: 190px;
  resize: vertical;
  padding: 16px;
  line-height: 1.5;
}

input[type="password"],
input[type="text"],
input:not([type]) {
  padding: 13px 14px;
}

textarea:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input:not([type]):focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(214, 166, 61, 0.16);
}

.confirm-line {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.35;
  text-transform: none;
}

.confirm-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.form-actions,
.admin-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

button,
.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  padding: 0 18px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover:not(:disabled),
.admin-link:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button {
  color: #160806;
  background: var(--accent-2);
}

.secondary-button {
  color: var(--paper);
  border-color: rgba(216, 208, 181, 0.32);
  background: transparent;
}

.danger-button {
  color: var(--text);
  border-color: rgba(212, 61, 47, 0.65);
  background: rgba(212, 61, 47, 0.18);
}

.privacy-note {
  margin-top: 18px;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(200px, 0.7fr) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  margin-top: 36px;
  padding: 22px;
}

.result-panel[hidden] {
  display: none;
}

.result-panel h2 {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: clamp(1.7rem, 4vw, 3.5rem);
}

#result-message {
  margin: 0;
  color: var(--paper);
  line-height: 1.6;
}

.meter {
  grid-column: 1 / -1;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--good);
  transition: width 240ms ease, background 240ms ease;
}

.status-disponible h2 {
  color: var(--good);
}

.status-posible_duplicado h2 {
  color: var(--warn);
}

.status-ocupado h2 {
  color: var(--bad);
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.admin-header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
}

.admin-card {
  padding: 22px;
}

.admin-table-wrap {
  margin-top: 22px;
  overflow-x: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--paper);
  background: rgba(216, 208, 181, 0.06);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  color: var(--text);
  line-height: 1.45;
}

.editable-theory,
.editable-alias {
  width: min(520px, 52vw);
  min-height: 92px;
}

.editable-name {
  min-width: 160px;
}

.admin-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-transform: none;
}

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

.toast {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--accent-2);
  font-family: var(--mono);
}

@media (max-width: 820px) {
  .classification-strip,
  .hero,
  .result-panel {
    grid-template-columns: 1fr;
  }

  .classification-strip span {
    text-align: left;
  }

  .hero {
    gap: 20px;
  }

  .hero-copy {
    min-height: 300px;
    padding: 24px 0;
  }

  .hero-copy::after {
    right: 0;
    bottom: 4%;
    width: 128px;
    height: 128px;
    font-size: 0.74rem;
  }

  .admin-header {
    display: block;
  }

  .editable-theory,
  .editable-alias {
    width: 65vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* ── UFO ─────────────────────────────────────── */
#ufo {
  position: fixed;
  top: 0; left: 0;
  width: 120px;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  filter: drop-shadow(0 0 14px rgba(214,166,61,0.6));
}

/* ── Botón música ────────────────────────────── */
#music-btn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 998;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 40px;
  border: 1px solid rgba(214,166,61,0.4);
  background: rgba(8,10,8,0.92);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}
#music-btn:hover {
  border-color: rgba(214,166,61,0.7);
  color: var(--accent-2);
  box-shadow: 0 0 14px rgba(214,166,61,0.2);
}
#music-btn .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s;
}
#music-btn.playing {
  border-color: rgba(214,166,61,0.7);
  color: var(--accent-2);
}
#music-btn.playing .dot {
  background: var(--accent-2);
  animation: pulsedot 1.1s ease-in-out infinite;
}
@keyframes pulsedot {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.5); opacity: 0.6; }
}

/* ── Fix overlap textos ──────────────────────── */
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
h1 { max-width: 500px; }
.subtitle { max-width: 450px; }

@media (max-width: 820px) {
  .hero-copy::after {
    position: relative;
    right: auto;
    bottom: auto;
    align-self: flex-start;
    margin-top: 20px;
    width: 116px;
    height: 116px;
    font-size: 0.70rem;
  }
}
