:root {
  --ink: #000000;
  --muted: #6b625b;
  --paper: #fbf8f3;
  --paper-deep: #eee5db;
  --line: #d4c7b9;
  --coral: #5b5248;
  --coral-dark: #40382f;
  --lime: #e2d2c0;
  --blue: #5b5248;
  --shadow: 0 24px 70px rgba(91, 82, 72, .16);
  font-family: 'Montserrat', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-width: 320px;
  background: #d8cec1;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(226, 210, 192, .72), transparent 24rem),
    radial-gradient(circle at 92% 18%, rgba(91, 82, 72, .18), transparent 23rem),
    #d8cec1;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(91, 82, 72, .45);
  outline-offset: 3px;
}

.app-shell,
.container {
  width: min(1240px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 22px;
}

.site-header,
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 0 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: .84rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 4px 4px 0 var(--ink);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.brand-slash {
  color: var(--coral);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-nav-link,
.site-nav a {
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-decoration: none;
}

.site-nav-link:hover,
.site-nav-link.is-active,
.site-nav a:hover {
  border-color: var(--line);
  background: rgba(251, 248, 243, .72);
  color: var(--ink);
}

main {
  min-height: calc(100vh - 130px);
}

.section {
  width: 100%;
}

.workspace-section {
  padding: clamp(28px, 5vw, 70px) 0 56px;
}

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 38px;
  margin-bottom: 42px;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow,
.panel-index {
  color: var(--coral-dark);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.eyebrow span {
  display: inline-block;
  width: 28px;
  height: 1px;
  margin: 0 9px 3px;
  background: var(--coral);
}

.hero-copy h1 {
  max-width: 620px;
  margin-top: 14px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(3rem, 6vw, 5.5rem);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .9;
}

.hero-copy h1 em {
  color: var(--coral);
  font-style: normal;
}

.hero-lede {
  max-width: 490px;
  margin-top: 25px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.hero-stamp {
  display: grid;
  flex: 0 0 174px;
  grid-template-columns: 1fr 1fr;
  gap: 7px 10px;
  padding: 17px;
  border: 1px solid var(--ink);
  background: var(--lime);
  transform: rotate(3deg);
  box-shadow: 7px 7px 0 var(--ink);
}

.hero-stamp span {
  color: var(--ink);
  font-size: .68rem;
  font-weight: 800;
}

.hero-stamp strong {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, .65fr);
  gap: 18px;
  align-items: stretch;
}

.form-panel,
.extension-card,
.sorteo-card,
.resultado-card,
.loading-card {
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.form-panel {
  padding: clamp(25px, 4vw, 40px);
}

.panel-heading,
.rules-topline,
.field-label-row,
.file-row,
.user-info,
.user-details {
  display: flex;
  align-items: center;
}

.panel-heading,
.rules-topline,
.field-label-row {
  justify-content: space-between;
  gap: 18px;
}

.panel-heading h2,
.rules-panel h2,
.extension-card h2,
.sorteo-card h2,
.loading-card h2,
.resultado-card h2 {
  margin-top: 7px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.8rem, 3vw, 2.65rem);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1;
}

.panel-status {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(226, 210, 192, .72);
  color: var(--coral-dark);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .1em;
}

.panel-description {
  max-width: 520px;
  margin: 17px 0 28px;
  color: var(--muted);
  font-size: .9rem;
}

.field-label-row {
  margin-bottom: 9px;
}

.field-label-row label,
.input-group label {
  color: var(--ink);
  font-size: .8rem;
  font-weight: 800;
}

.field-label-row span {
  color: var(--muted);
  font-size: .7rem;
}

textarea,
.input-group input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f5eee6;
  color: var(--ink);
}

textarea {
  min-height: 230px;
  padding: 16px;
  resize: vertical;
  font-family: Consolas, 'Courier New', monospace;
  font-size: .82rem;
  line-height: 1.7;
}

textarea::placeholder,
input::placeholder {
  color: #968a7e;
}

textarea:focus,
.input-group input:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 4px rgba(91, 82, 72, .15);
}

.field-help {
  margin-top: 9px;
  color: var(--muted);
  font-size: .72rem;
}

.file-row {
  gap: 10px;
  margin: 20px 0 24px;
  color: var(--muted);
  font-size: .72rem;
}

.file-row input[type="file"] {
  width: 1px;
  height: 1px;
  overflow: hidden;
  position: absolute;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.file-button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-deep);
  color: var(--ink);
  cursor: pointer;
  font-size: .73rem;
  font-weight: 800;
}

.file-button:hover {
  border-color: var(--ink);
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.primary-action {
  width: 100%;
  padding: 15px 18px;
  background: var(--ink);
  color: var(--paper);
  font-size: .86rem;
}

.primary-action:hover {
  background: var(--coral-dark);
  box-shadow: 0 10px 20px rgba(91, 82, 72, .2);
  transform: translateY(-2px);
}

.action-arrow {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--lime);
  color: var(--ink);
  font-size: 1rem;
}

.secondary-action {
  padding: 11px 18px;
  background: var(--paper-deep);
  color: var(--ink);
}

.rules-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(25px, 4vw, 38px);
  border-radius: 24px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}

.rules-panel::after {
  width: 190px;
  height: 190px;
  border: 1px solid rgba(226, 210, 192, .7);
  border-radius: 50%;
  content: '';
  position: absolute;
  right: -88px;
  bottom: -94px;
}

.rules-panel .panel-index {
  color: var(--lime);
}

.rule-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 7px rgba(91, 82, 72, .15);
}

.rules-panel h2 {
  max-width: 290px;
  margin-top: 34px;
  color: var(--paper);
  font-size: clamp(2rem, 3vw, 3rem);
}

.rules-panel > p {
  margin-top: 18px;
  color: #cfc2b4;
  font-size: .86rem;
  line-height: 1.7;
}

.rule-list {
  margin: 28px 0;
  list-style: none;
}

.rule-list li {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid rgba(251, 248, 243, .15);
}

.rule-list li > span {
  color: var(--lime);
  font-size: .7rem;
  font-weight: 800;
}

.rule-list strong,
.rule-list small {
  display: block;
}

.rule-list strong {
  font-size: .8rem;
}

.rule-list small {
  margin-top: 4px;
  color: #8f8377;
  font-size: .72rem;
}

.text-link {
  color: var(--coral-dark);
  font-size: .78rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rules-panel .text-link {
  position: relative;
  z-index: 1;
  color: var(--lime);
}

.state-section {
  display: flex;
  min-height: 600px;
  align-items: center;
  justify-content: center;
  padding: 50px 0;
}

.state-card,
.result-card,
.authenticated-card {
  width: min(100%, 620px);
  padding: clamp(28px, 5vw, 52px);
  text-align: center;
}

.user-info {
  gap: 13px;
  margin-bottom: 28px;
  text-align: left;
}

.user-info img {
  width: 48px;
  height: 48px;
  border: 2px solid var(--lime);
  border-radius: 50%;
}

.user-details {
  flex: 1;
  justify-content: space-between;
  gap: 16px;
}

.user-details span {
  font-size: .86rem;
  font-weight: 800;
}

.input-group {
  margin: 28px 0;
  text-align: left;
}

.input-group input {
  margin-top: 8px;
  padding: 14px;
}

.input-group small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: .72rem;
}

.requirements {
  margin: 20px 0 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-deep);
  text-align: left;
}

.requirements h3 {
  margin-bottom: 10px;
  font-size: .8rem;
}

.requirements ul {
  display: grid;
  gap: 8px;
  list-style: none;
}

.requirements li {
  color: var(--muted);
  font-size: .78rem;
}

.requirements strong {
  color: var(--ink);
}

.loading-orbit {
  width: 62px;
  height: 62px;
  margin: 0 auto 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  position: relative;
  animation: orbit 1.5s linear infinite;
}

.loading-orbit::before,
.loading-orbit span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: absolute;
  content: '';
}

.loading-orbit::before {
  top: -6px;
  left: 25px;
  background: var(--coral);
}

.loading-orbit span {
  right: -5px;
  bottom: 8px;
  background: var(--lime);
}

.loading-card h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.loading-card > p:last-child {
  margin-top: 15px;
  color: var(--muted);
  font-size: .86rem;
}

.loading-candidate {
  min-height: 72px;
  margin: 25px 0 20px;
  color: var(--coral-dark);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: -.035em;
  line-height: 1;
}

.loading-candidate.is-flipping {
  animation: candidateFlip .105s ease-out;
}

.draw-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-deep);
}

.draw-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--lime));
  transition: width .1s linear;
}

.loading-dots {
  color: var(--coral);
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

@keyframes candidateFlip {
  from { opacity: .2; transform: translateY(8px) rotateX(-18deg); }
  to { opacity: 1; transform: translateY(0) rotateX(0); }
}

.winner-badge,
.empty-badge {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 22px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 6px 6px 0 var(--ink);
  font-size: 2rem;
}

.empty-badge {
  background: var(--paper-deep);
  color: var(--muted);
}

.winner-badge {
  animation: winnerPop .65s cubic-bezier(.16, 1, .3, 1) .12s both;
}

.resultado-card h2 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.result-card {
  animation: resultReveal .7s cubic-bezier(.2, .8, .2, 1) both;
}

.ganador-nombre {
  margin-top: 25px;
  color: var(--coral-dark);
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  font-weight: 800;
}

.ganador-comentario {
  max-width: 430px;
  margin: 9px auto 0;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 1rem;
  font-style: italic;
}

.verificacion-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  margin: 25px auto 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-deep);
  text-align: left;
}

.verificacion-links strong {
  font-size: .76rem;
}

.verificacion-links a {
  color: var(--blue);
  font-size: .8rem;
  font-weight: 800;
  text-decoration: underline;
}

.verification-instructions {
  display: grid;
  gap: 5px;
  max-width: 390px;
  margin: 22px auto 0;
  padding: 13px 16px;
  border-left: 4px solid var(--coral);
  background: #f0e6dc;
  color: #40382f;
  font-size: .76rem;
  line-height: 1.45;
  text-align: left;
}

.verification-instructions strong {
  font-size: .82rem;
}

.verification-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  max-width: 440px;
  margin: 24px auto 0;
}

.verification-actions .primary-action,
.verification-actions .secondary-action {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: .72rem;
}

.verification-actions .secondary-action {
  border: 1px solid var(--line);
  color: var(--muted);
}

.verification-actions .primary-action:disabled {
  cursor: not-allowed;
  opacity: .4;
  transform: none;
}

.share-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 440px);
  min-height: 52px;
  margin: 24px auto 0;
  padding: 13px 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 800;
}

.share-action:hover {
  background: #e2d2c0;
  box-shadow: 4px 4px 0 var(--ink);
  transform: translateY(-2px);
}

.share-status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: .72rem;
}

.winner-badge.is-official {
  background: var(--coral);
  color: white;
  animation: officialPop .8s cubic-bezier(.16, 1, .3, 1) both;
}

.confetti-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.resultado-card {
  position: relative;
  overflow: hidden;
}

.confetti-layer i {
  width: 9px;
  height: 17px;
  display: block;
  position: absolute;
  top: 18%;
  left: var(--x);
  opacity: 0;
  transform: translateY(-20px) rotate(0);
  animation: confettiFall 1.5s ease-out var(--delay) forwards;
}

.verification-note {
  max-width: 390px;
  margin: 13px auto 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.5;
}

@keyframes resultReveal {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes winnerPop {
  from { opacity: 0; transform: scale(.5) rotate(-12deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes officialPop {
  0% { transform: scale(.8) rotate(-8deg); }
  70% { transform: scale(1.12) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(-20px) rotate(0); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translateY(470px) rotate(var(--spin)); }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 36px 0 28px;
}

.stat {
  padding: 14px 8px;
  border-top: 2px solid var(--ink);
  text-align: left;
}

.stat-number,
.stat-label {
  display: block;
}

.stat-number {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  margin-top: 7px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.error-message {
  display: flex;
  gap: 10px;
  width: min(100%, 620px);
  margin: 0 auto 30px;
  padding: 15px 18px;
  border-left: 4px solid var(--coral);
  background: #f0e6dc;
  color: #40382f;
  font-size: .8rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 22px;
  border-top: 1px solid rgba(0, 0, 0, .12);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.footer-links {
  display: inline-flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--coral);
  font-weight: 700;
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.extension-card {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 50px);
  text-align: left;
}

.extension-card h2 {
  margin-bottom: 10px;
}

.extension-card h3 {
  margin: 26px 0 10px;
  font-size: 1.05rem;
}

.section-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--coral-dark);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.extension-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  margin: 22px 0 4px;
  padding: 15px 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 5px 5px 0 var(--coral);
  color: var(--paper);
  font-size: .95rem;
  font-weight: 800;
  text-decoration: none;
}

.extension-download:hover {
  background: var(--coral-dark);
  box-shadow: 3px 3px 0 var(--ink);
  transform: translateY(-2px);
}

.instruction-list {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: .84rem;
}

.instruction-list li {
  margin: 9px 0;
}

.instruction-list code,
.extension-note code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: .9em;
}

.extension-note {
  margin-top: 24px;
  padding: 13px;
  border-left: 4px solid var(--blue);
  background: var(--paper-deep);
  color: var(--muted);
  font-size: .8rem;
}

.extension-details {
  margin-top: 18px;
  color: var(--muted);
}

.extension-details summary {
  color: var(--blue);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 820px) {
  .app-shell,
  .container {
    width: min(100% - 30px, 680px);
    padding-top: 18px;
  }

  .hero-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 25px;
  }

  .hero-stamp {
    align-self: flex-end;
  }

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

  .rules-panel {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .site-header,
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 17px;
  }

  .site-nav {
    width: 100%;
  }

  .site-nav-link,
  .site-nav a {
    padding-left: 0;
    padding-right: 18px;
  }

  .hero-copy h1 {
    font-size: clamp(2.8rem, 14vw, 4.5rem);
  }

  .hero-stamp {
    align-self: flex-start;
    transform: rotate(-2deg);
  }

  .form-panel,
  .rules-panel,
  .state-card,
  .result-card,
  .extension-card {
    border-radius: 18px;
    padding: 23px 19px;
  }

  .field-label-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .verification-actions {
    grid-template-columns: 1fr;
  }

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

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}
