:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-strong: #111111;
  --text: #ffffff;
  --muted: #888888;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #ffffff;
  --accent-strong: #ffffff;
  --accent-text: #000000;
  --secondary: #111111;
  --secondary-hover: #1f1f1f;
  --danger: #ff4d4d;
  --danger-bg: #2a0a0a;
  --danger-hover: #3a0a0a;
  --focus: #ffffff;
  --shadow: 0 0 0 1px var(--line), 0 8px 30px rgba(0, 0, 0, 0.4);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 64px;
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(5px);
}

.brand {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

nav a,
.ghost {
  font-size: 0.875rem;
  color: #fff;
  transition: all 0.2s;
  cursor: pointer;
  background: none;
  border: 1px solid #fff;
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
}

nav a:hover,
.ghost:hover {
  color: var(--text);
  border-color: #fff;
}

.shell {
  width: min(1200px, calc(100% - 3rem));
  margin: 3rem auto;
}

.home-grid,
.admin-grid {
  display: grid;
  gap: 2rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.panel-header {
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.05em;
  font-weight: 700;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 1.5rem;
}

.tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  border-radius: 0;
}

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.primary {
  min-height: 48px;
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary:hover {
  background: transparent;
  color: var(--accent);
}

.secondary {
  min-height: 40px;
  padding: 0.5rem 1rem;
  background: var(--secondary);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.secondary:hover {
  background: var(--secondary-hover);
}

/* Captcha - Layout preserved from working version, Geist style applied */
.captcha-card {
  display: grid;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  padding: 1.25rem;
}

.dialog-card {
  display: grid;
  gap: 2rem;
  padding: 2rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.log-list,
.pair-list {
  display: grid;
  gap: 1rem;
  max-height: min(70vh, 600px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.log-list article,
.pair-list article {
  display: grid;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 1.5rem;
}

.log-list pre {
  margin: 0;
  padding: 1rem;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  overflow-x: auto;
}

.captcha-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.captcha-header strong {
  font-size: 0.875rem;
  font-weight: 600;
}

.captcha-board {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 8 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-size: 100% 100%;
  touch-action: none;
}

.captcha-slot {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(255,255,255,0.2);
}

.captcha-piece {
  position: absolute;
  top: 38px;
  left: 0;
  width: 54px;
  height: 54px;
  cursor: grab;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.8));
}

.captcha-piece:active {
  cursor: grabbing;
}

/* Admin Dashboard Specifics */
.admin-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.status-card {
  padding: 1rem;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
}

.button-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.button-group .primary {
  grid-column: span 2;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
  padding: 0;
}

.captcha-board.is-solved .captcha-slot {
  border-color: #00ff00;
  box-shadow: 0 0 20px rgba(0,255,0,0.3);
}

label {
  display: grid;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  color: var(--text);
  padding: 0 0.75rem;
  transition: border-color 0.2s;
}

textarea {
  height: auto;
  padding: 0.75rem;
  resize: vertical;
  min-height: calc(2 * 1.5rem + 1.5rem);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #888;
}

.summary,
.draw-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 1.5rem;
  display: grid;
  gap: 0.5rem;
}

.draw-card {
  background: #00120a;
  border-color: #004d2a;
}

output {
  min-height: 1.25rem;
  font-size: 0.875rem;
  color: #fff;
}

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

.participant-list {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  padding: 0;
  margin: 0;
  list-style: none;
  flex: 1;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.participant-list li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: var(--surface-strong);
}

.participant-list strong {
  font-size: 0.875rem;
  font-weight: 500;
}

.participant-list span {
  font-size: 0.75rem;
  color: var(--muted);
}

.footer {
  width: min(1200px, calc(100% - 3rem));
  margin: 0 auto 4rem;
  color: var(--muted);
  font-size: 0.75rem;
}

@media (min-width: 760px) {
  .home-grid,
  .admin-grid {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: stretch;
    gap: 2rem;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.75rem;
  }
  
  .panel {
    padding: 1rem;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.badge {
  font-size: 0.75rem;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  color: var(--muted);
}
