:root {
  --panel: rgba(12, 18, 34, 0.88);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef2ff;
  --muted: rgba(238, 242, 255, 0.65);
  --accent: #ff8a3d;
  --accent-2: #7df9c2;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
  --radius: 28px;
  --font-ui: "Avenir Next", "Montserrat", "Segoe UI", sans-serif;
  --font-display: "Helvetica Neue", "Arial Narrow", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(125, 249, 194, 0.12), transparent 36%),
    radial-gradient(circle at bottom right, rgba(255, 138, 61, 0.18), transparent 32%),
    linear-gradient(180deg, #09101f 0%, #050811 100%);
  color: var(--text);
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.home-view {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  gap: 24px;
}

.home-hero,
.panel,
.preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.home-hero,
.panel,
.preview {
  padding: 24px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 24px;
}

.list-panel {
  min-height: 420px;
}

.tournament-list {
  display: grid;
  gap: 14px;
}

.tournament-list.empty::before,
.team-library.empty::before,
.story-sets.empty::before {
  content: "Todavia no hay elementos guardados.";
  color: var(--muted);
  font-size: 0.92rem;
}

.tournament-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tournament-card h3,
.match-title,
.section-head h2,
.preview-header h2,
.collapse-head h2,
h1,
h2,
h3,
p {
  margin: 0;
}

.tournament-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.shell {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  min-height: 100vh;
  height: 100vh;
}

.controls,
.preview {
  min-height: 0;
  height: calc(100vh - 48px);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  padding-bottom: 24px;
}

.controls::-webkit-scrollbar {
  width: 10px;
}

.controls::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.controls::-webkit-scrollbar-thumb {
  background: rgba(125, 249, 194, 0.28);
  border-radius: 999px;
}

.controls::-webkit-scrollbar-thumb:hover {
  background: rgba(125, 249, 194, 0.42);
}

.hero-panel {
  background:
    linear-gradient(135deg, rgba(255, 138, 61, 0.16), transparent 52%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.04)),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.lede {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.back-btn {
  margin-bottom: 16px;
}

.collapsible {
  padding: 0;
  overflow: visible;
}

.collapsible[open] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.03)),
    var(--panel);
}

.collapse-head {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  cursor: pointer;
}

.collapse-head::-webkit-details-marker {
  display: none;
}

.collapse-head::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-2);
  font-size: 1.15rem;
  flex: 0 0 auto;
}

.collapsible[open] .collapse-head::after {
  content: "−";
}

.collapse-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.collapse-body {
  padding: 0 22px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.stack-form,
.field,
.compact-select {
  display: grid;
  gap: 8px;
}

.field {
  margin-bottom: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}

.field span,
.compact-select span,
.meta-text,
.range-output {
  font-size: 0.82rem;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.compact-select select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.compact-select select:focus {
  border-color: rgba(125, 249, 194, 0.65);
  background: rgba(255, 255, 255, 0.08);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
  font: inherit;
}

.color-input {
  min-height: 48px;
  padding: 6px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.92rem;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.header-block {
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-block:last-child {
  margin-bottom: 0;
}

.header-block-body {
  margin-top: 12px;
}

.header-block-body.is-hidden {
  display: none;
}

.upload-field {
  position: relative;
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  overflow: hidden;
  cursor: pointer;
}

.upload-field input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-field span {
  color: var(--muted);
}

.inline-actions {
  display: flex;
  gap: 10px;
}

.solid-btn,
.ghost-btn {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  cursor: pointer;
}

.solid-btn {
  background: linear-gradient(135deg, var(--accent), #ffb03d);
  color: #0e1424;
  font-weight: 700;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.danger-btn {
  background: rgba(255, 95, 114, 0.14);
  color: #ffd2d8;
}

.big {
  min-height: 58px;
  font-size: 1rem;
}

.summary-select {
  min-width: 110px;
}

.matches,
.team-library,
.story-sets {
  display: grid;
  gap: 14px;
}

.import-results {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.import-group-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.import-group-top p,
.import-group-list {
  color: var(--muted);
}

.import-group-list {
  margin: 12px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 0.86rem;
}

.import-hint,
.import-name-hint {
  color: var(--accent-2);
  font-size: 0.76rem;
}

.import-hint {
  margin-left: 8px;
}

.match-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.match-top {
  margin-bottom: 14px;
}

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

.field.mini input {
  text-align: center;
}

.import-name-hint {
  min-height: 1em;
}

.team-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.team-logo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.team-logo-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

.team-name {
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-actions {
  display: flex;
  gap: 8px;
}

.team-actions button {
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.team-actions button.danger {
  background: rgba(255, 95, 114, 0.14);
  color: #ffd2d8;
}

.preview {
  display: grid;
  gap: 22px;
  align-content: start;
}

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

.preview-tools {
  display: flex;
  align-items: center;
  gap: 14px;
}

.preview-check {
  font-size: 0.82rem;
}

.status-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(125, 249, 194, 0.12);
  color: var(--accent-2);
  font-size: 0.84rem;
}

.canvas-frame {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 18px;
  border-radius: calc(var(--radius) - 8px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(0, 0, 0, 0.16);
}

.canvas-stage {
  position: relative;
  width: min(100%, 445px);
  aspect-ratio: 9 / 16;
}

canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 34px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  background: #111827;
}

.instagram-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 16px 22px;
  pointer-events: none;
  border-radius: 34px;
}

.instagram-preview-overlay.hidden {
  display: none;
}

.ig-top,
.ig-bottom,
.ig-user,
.ig-actions,
.ig-dots {
  display: flex;
  align-items: center;
}

.ig-top,
.ig-bottom {
  justify-content: space-between;
  gap: 12px;
}

.ig-user {
  gap: 10px;
}

.ig-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.24);
}

.ig-meta {
  display: grid;
  gap: 1px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.ig-meta strong,
.ig-meta span {
  line-height: 1;
}

.ig-meta strong {
  font-size: 0.78rem;
}

.ig-meta span {
  font-size: 0.68rem;
  opacity: 0.86;
}

.ig-dots,
.ig-actions {
  gap: 5px;
}

.ig-dots span,
.ig-actions span {
  display: block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.ig-dots span {
  width: 4px;
  height: 4px;
}

.ig-actions span {
  width: 18px;
  height: 18px;
}

.ig-input-pill {
  min-width: 150px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.74rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.12);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
}

@media (max-width: 1160px) {
  .home-grid,
  .shell {
    grid-template-columns: 1fr;
  }

  .shell {
    min-height: auto;
    height: auto;
  }

  .controls,
  .preview {
    height: auto;
  }

  .controls {
    overflow: visible;
    padding-right: 0;
    padding-bottom: 0;
  }
}

@media (max-width: 720px) {
  .home-view,
  .shell {
    padding: 14px;
    gap: 16px;
  }

  .home-hero,
  .panel,
  .preview {
    padding: 18px;
    border-radius: 22px;
  }

  .field-row,
  .match-grid {
    grid-template-columns: 1fr;
  }

  .inline-actions,
  .team-actions {
    flex-wrap: wrap;
  }
}
