:root {
  color-scheme: light;
  --cream: #f4eadd;
  --cream-dark: #e8decf;
  --brown: #3e2b22;
  --orange: #d97b46;
  --white: #fff;
  --muted: #76665d;
  --error: #a63e2f;
  --success: #477044;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.72), transparent 58%),
    var(--cream);
  color: var(--brown);
  font-family: "Roboto", sans-serif;
  line-height: 1.6;
}

.card {
  position: relative;
  width: min(100%, 440px);
  padding: clamp(1.75rem, 6vw, 2.75rem);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(62, 43, 34, 0.12);
  border-top: 5px solid var(--orange);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(62, 43, 34, 0.12);
}

h1 {
  color: var(--brown);
  font-family: "Oswald", sans-serif;
  font-size: clamp(2rem, 8vw, 2.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.screen[hidden] {
  display: none;
}

.screen-intro {
  max-width: 34ch;
  margin: 0 auto 0.25rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
  text-align: center;
}

.label {
  display: block;
  margin-bottom: -0.5rem;
  color: var(--brown);
  font-family: "Oswald", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(62, 43, 34, 0.3);
  border-radius: 4px;
  outline: none;
  background: rgba(244, 234, 221, 0.48);
  color: var(--brown);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#code-input {
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  text-align: center;
}

input::placeholder {
  color: rgba(62, 43, 34, 0.45);
}

input:focus {
  border-color: var(--orange);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(217, 123, 70, 0.18);
}

button {
  width: 100%;
  min-height: 52px;
  padding: 0.8rem 1.25rem;
  border: 2px solid var(--brown);
  border-radius: 4px;
  background: var(--brown);
  color: var(--white);
  cursor: pointer;
  font-family: "Oswald", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--orange);
  background: var(--orange);
}

button:focus-visible {
  outline: 3px solid rgba(217, 123, 70, 0.48);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.result {
  min-height: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.result.success { color: var(--success); }
.result.failure { color: var(--error); }
.result.error { color: #a45b20; }

.spinner {
  width: 48px;
  height: 48px;
  align-self: center;
  margin: 0.75rem 0;
  border: 4px solid var(--cream-dark);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-text {
  color: var(--muted);
  text-align: center;
}

.waiting-msg {
  padding: 1rem;
  border-left: 4px solid var(--orange);
  border-radius: 4px;
  background: rgba(217, 123, 70, 0.12);
  color: var(--brown);
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

.win-emoji {
  color: var(--orange);
  font-size: 3.5rem;
  line-height: 1;
  text-align: center;
}

.win-msg {
  color: var(--brown);
  font-family: "Oswald", sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-transform: uppercase;
}

.coupon-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border: 2px dashed var(--orange);
  border-radius: 6px;
  background: var(--cream);
  animation: fadeIn 0.3s ease both;
}

.coupon-section .label {
  margin: 0;
  text-align: center;
}

.coupon-section svg {
  max-width: 100%;
}

.coupon-hint {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 420px) {
  body {
    padding: 1rem;
  }

  .card {
    gap: 1.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
