:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: #121d34;
  --panel-2: #1d2942;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7f9ff;
  --muted: #9fb4da;
  --accent: #4da3ff;
  --bad: #ff8a8a;
  --good: #72e6be;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #14244a 0, var(--bg) 58%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}

body.locked {
  overflow: hidden;
}

body.locked .app-shell {
  display: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 16, 31, 0.9);
}

.auth-card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.auth-card p,
.panel-head p,
.topbar p,
.field span,
.auth-status small {
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  margin-top: 4px;
  font-size: 22px;
}

input,
button,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

input {
  min-height: 48px;
  padding: 0 12px;
  text-align: center;
}

textarea {
  min-height: 210px;
  padding: 14px;
  resize: vertical;
}

.auth-message {
  min-height: 20px;
  color: #ffd08a;
  font-size: 13px;
}

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.topbar,
.panel-head,
.action-row,
.tabs,
.segmented,
.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar {
  margin-bottom: 14px;
}

.top-actions {
  justify-content: flex-end;
}

.auth-status {
  display: grid;
  justify-items: end;
}

.auth-status span {
  font-weight: 900;
}

.tabs {
  width: min(100%, 520px);
  margin: 0 auto 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.tab,
.lottery-btn,
.ghost-btn,
.icon-btn,
.danger-btn,
.rank-type-btn {
  background: rgba(255, 255, 255, 0.07);
  font-weight: 850;
  padding: 0 16px;
}

.danger-btn {
  background: rgba(255, 99, 132, 0.2);
  color: #ffb3bf;
}

.tab,
.tabs button {
  flex: 1;
}

.tab.active,
.lottery-btn.active,
.rank-type-btn.active,
.primary-btn {
  background: linear-gradient(180deg, #62b4ff, #3d86ff);
  color: white;
  font-weight: 900;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.32fr) minmax(0, 0.68fr);
  gap: 14px;
}

.live-board,
.workspace-column {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel,
.settings-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18, 29, 52, 0.94);
}

.summary-grid,
.board-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.board-stat-grid {
  grid-template-columns: 1fr;
}

.summary-grid article,
.board-stat-grid article {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.summary-grid span,
.board-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-grid strong,
.board-stat-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.segmented {
  justify-content: flex-end;
}

.rank-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.rank-current {
  margin-top: 12px;
  color: var(--muted);
}

.rank-list,
.preview-list,
.entry-list,
.license-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.preview-card,
.entry-card,
.rank-card,
.license-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.entry-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.empty {
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: var(--muted);
}

.draw-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.draw-ball-input.special {
  border-color: rgba(255, 208, 111, 0.5);
}

.settle-result {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: 18px 14px;
  background: rgba(7, 16, 31, 0.72);
  overflow: auto;
}

.settings-card {
  width: min(100%, 760px);
  margin: 0 auto;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

summary {
  padding: 14px;
  cursor: pointer;
  font-weight: 900;
}

.license-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

.license-summary span {
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.full {
  width: 100%;
  margin-top: 14px;
}

.danger-text {
  color: var(--bad);
}

@media (max-width: 820px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .draw-grid,
  .license-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
  }
}
