:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body {
  margin: 0;
  padding: 0;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
}

.wrapper {
  width: min(960px, 100%);
  padding: 24px 16px 48px;
  box-sizing: border-box;
}

h1, h2 {
  margin-top: 0;
  font-weight: 600;
  letter-spacing: 0.03em;
}

h1 {
  font-size: clamp(1.8rem, 2.3vw, 2.4rem);
  text-align: center;
  margin-bottom: 24px;
}

.panels {
  display: grid;
  gap: 20px;
}

@media (min-width: 900px) {
  .panels {
    grid-template-columns: 1fr 1fr;
  }
  .panel.history {
    grid-column: 1 / -1;
  }
}

.panel {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 45px -30px rgba(15, 23, 42, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
  color: #e2e8f0;
  opacity: 0.9;
  letter-spacing: 0.02em;
}

textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: inherit;
  resize: vertical;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
}

textarea:focus {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #0f172a;
  background: #38bdf8;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px -15px rgba(56, 189, 248, 0.9);
  background: #0ea5e9;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.status {
  margin: 0 0 12px;
  font-size: 0.95rem;
  min-height: 1.2em;
  color: #e2e8f0;
  opacity: 0.85;
}

.status[data-type="success"] {
  color: #4ade80;
}

.status[data-type="error"] {
  color: #f87171;
}

.counts {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.counts span {
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  padding: 6px 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.current-code {
  margin-top: 16px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  display: none;
  flex-direction: column;
  gap: 14px;
}

.current-code.active {
  display: flex;
}

.code-value {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  background: rgba(15, 23, 42, 0.5);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  text-align: center;
}

.redeem-link {
  font-family: inherit;
  color: #38bdf8;
  word-break: break-all;
  text-decoration: none;
}

.redeem-link:hover {
  text-decoration: underline;
}

.qr-wrapper {
  display: flex;
  justify-content: center;
}

.qr-surface {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  border-radius: 16px;
  background: #e2e8f0;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.16);
}

.qr-wrapper canvas,
.qr-wrapper img {
  width: 220px;
  height: 220px;
  image-rendering: pixelated;
  display: block;
}

.help-text {
  font-size: 0.88rem;
  opacity: 0.7;
  margin-top: 8px;
  line-height: 1.4;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.history-list li {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(30, 41, 59, 0.65);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: inherit;
  font-size: 0.95rem;
}

select:focus {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

.empty-state {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed rgba(148, 163, 184, 0.3);
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.75;
}

.history-toggle {
  margin-top: 12px;
  align-self: flex-start;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  font-size: 0.85rem;
  padding: 6px 14px;
}

.history-toggle:hover:not(:disabled) {
  background: rgba(14, 165, 233, 0.25);
}

.site-footer {
  margin-top: 32px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 25px -18px rgba(8, 145, 178, 0.9);
  border: 1px solid rgba(248, 250, 252, 0.35);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-title {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.footer-sponsor-link {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 500;
}

.footer-sponsor-link:hover {
  text-decoration: underline;
}
