:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #627080;
  --line: #dde3ea;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
}

h2 {
  margin-bottom: 18px;
  font-size: 19px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1.2fr);
  align-items: start;
  gap: 18px;
  padding: 24px clamp(20px, 5vw, 64px);
}

.side-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  overflow: auto;
}

.codes-panel {
  display: flex;
  flex-direction: column;
  max-height: min(680px, calc(100vh - 145px));
}

.register-panel {
  align-self: start;
  max-height: none;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

.status {
  min-height: 22px;
  max-height: 88px;
  margin: 14px 0 0;
  color: var(--muted);
  overflow: auto;
  overflow-wrap: anywhere;
}

.status.error {
  color: var(--danger);
}

.players-summary {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.players-list {
  display: grid;
  gap: 8px;
  max-height: min(60vh, 520px);
  overflow: auto;
  overscroll-behavior: contain;
}

.player-row {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.player-main,
.player-meta {
  min-width: 0;
  overflow: auto;
  white-space: nowrap;
}

.player-main {
  color: var(--text);
}

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

#codes-count {
  min-width: 34px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #e6f4f1;
  color: var(--accent-dark);
  text-align: center;
  font-weight: 800;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.tab {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.tab:hover,
.tab.active {
  background: var(--accent);
  color: white;
}

.redeem-button {
  width: 100%;
  margin-bottom: 4px;
}

.codes-list {
  display: grid;
  gap: 18px;
  flex: 1;
  min-height: 0;
  max-height: min(440px, 52vh);
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.code-group {
  display: grid;
  gap: 10px;
}

.code-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.code-group-heading h3 {
  margin: 0;
  font-size: 15px;
}

.code-group-heading span {
  min-width: 28px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2f6;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.code {
  min-width: 0;
  overflow: auto;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.code-status {
  max-width: min(42vw, 280px);
  overflow: auto;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  min-width: 0;
  margin: 0;
  overflow: auto;
  text-align: right;
  white-space: nowrap;
  font-weight: 800;
}

.players-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}

.players-dialog::backdrop {
  background: rgb(23 32 42 / 0.45);
}

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

.dialog-heading h2 {
  margin: 0;
}

.dialog-close {
  min-height: 36px;
  padding: 0 14px;
}

@media (max-width: 760px) {
  .topbar,
  .input-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .codes-panel {
    max-height: 72vh;
  }

  .codes-list {
    max-height: 55vh;
  }
}
