:root {
  --bg: #0f1221;
  --panel: #1a1f37;
  --panel-2: #232a4d;
  --text: #e8ecf8;
  --muted: #9aa3c4;
  --accent: #6c8cff;
  --accent-2: #4ad6a0;
  --danger: #ff6b6b;
  --warn: #ffc857;
  --border: #2c3358;
  --radius: 12px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1c2350, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 33, 0.6);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

h1 {
  font-size: 26px;
  margin: 0 0 6px;
}
h2 {
  font-size: 19px;
  margin: 0 0 12px;
}
.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.row.wrap-top {
  align-items: flex-start;
}
.grow {
  flex: 1 1 auto;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

input[type='text'],
input[type='password'],
input[type='number'] {
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
}
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.field {
  margin-bottom: 14px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #0b1020;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border);
}
.btn.success {
  background: var(--accent-2);
}
.btn.warn {
  background: var(--warn);
}
.btn.danger {
  background: var(--danger);
  color: #fff;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.btn.google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  padding: 12px 16px;
}
.btn.google[disabled] {
  opacity: 0.5;
}
.btn.google .g-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: conic-gradient(
    from -45deg,
    #ea4335 0deg 90deg,
    #4285f4 90deg 180deg,
    #34a853 180deg 270deg,
    #fbbc05 270deg 360deg
  );
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 8px 0 0;
  min-height: 18px;
}
.hint {
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tab.active {
  background: var(--panel-2);
  color: var(--text);
}

/* Share link */
.sharebox {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sharebox input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* Participants */
.participants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.pcard {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.pcard .pname {
  font-size: 14px;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pcard.offline {
  opacity: 0.45;
}
.pcard.me {
  border-color: var(--accent);
}
.cardface {
  font-size: 28px;
  font-weight: 700;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--panel);
}
.cardface.hidden {
  color: var(--muted);
}
.cardface.voted {
  background: linear-gradient(160deg, #2d3974, #1c2350);
  color: var(--accent);
}
.cardface.revealed {
  background: linear-gradient(160deg, #1f4d3d, #14352a);
  color: var(--accent-2);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.stat .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.open {
  color: var(--accent-2);
  border-color: var(--accent-2);
}
.badge.frozen {
  color: var(--warn);
  border-color: var(--warn);
}
.badge.revealed {
  color: var(--accent);
  border-color: var(--accent);
}
.consensus {
  color: var(--accent-2);
  font-weight: 600;
}

.retained-banner {
  background: linear-gradient(135deg, #1f4d3d, #14352a);
  border: 1px solid var(--accent-2);
  border-radius: 10px;
  padding: 18px 24px;
  margin-bottom: 16px;
  text-align: center;
}
.retained-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
  margin-bottom: 6px;
}
.retained-value {
  font-size: 42px;
  font-weight: 700;
  color: var(--accent-2);
  line-height: 1;
}
.retained-unit {
  font-size: 18px;
  font-weight: 400;
  opacity: 0.75;
}

/* History list */
.history {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--panel-2);
}
.history .h-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history .h-value {
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
}
.history .h-date {
  color: var(--muted);
  font-size: 12px;
}
.delete-history-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.delete-history-btn:hover {
  opacity: 1;
}

.quickpicks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
}
.chip:hover {
  border-color: var(--accent);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Overlay / modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.modal-actions {
  margin-top: 18px;
}

.center {
  text-align: center;
}
[hidden] {
  display: none !important;
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
