:root {
  --bg: #1a1a1a;
  --surface: #262626;
  --text: #f5f5f5;
  --muted: #999;
  --accent: #d4af37;
  --error: #d3202a;
  --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

header#app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid #333;
}
header h1 { margin: 0; font-size: 18px; }

#user-menu { position: relative; }
#user-menu > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 8px;
  border-radius: 22px;
  user-select: none;
  transition: background 0.15s;
}
#user-menu > summary:hover { background: #333; }
#user-menu > summary::-webkit-details-marker { display: none; }
.user-menu-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex: none;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}
.user-menu-content {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid #444;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  min-width: 240px;
  z-index: 10;
  padding: 4px;
}
.user-email {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid #333;
  overflow-wrap: anywhere;
}
.user-menu-item {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  margin-top: 4px;
}
.user-menu-item:hover { background: #333; }
button.user-menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin-top: 0;
}

.user-avatar.avatar-mana { background: #1a1a1a; border: 1px solid #444; padding: 4px; }
.user-avatar.avatar-mana img { width: 100%; height: 100%; display: block; }
.user-avatar.avatar-card {
  background-color: #1a1a1a;
  background-size: cover;
  background-position: center;
  color: transparent;
}

.picker-content { display: flex; flex-direction: column; gap: 16px; }
.picker-content h2 { margin: 0; font-size: 18px; }
.picker-content h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.picker-content section { margin: 0; }
.picker-content input[type=text] {
  width: 100%;
  background: #1a1a1a;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 10px;
  font-size: 14px;
}

.icon-mana-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.icon-mana-grid button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #444;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s;
}
.icon-mana-grid button:hover { border-color: var(--accent); }
.icon-mana-grid button img { width: 28px; height: 28px; }

.icon-card-preview { display: flex; flex-direction: column; gap: 8px; align-items: stretch; margin-top: 8px; }
.icon-card-preview img { width: 100%; border-radius: var(--radius); }
.icon-card-preview .btn { align-self: stretch; }

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.btn {
  display: inline-block;
  padding: 12px 16px;
  border: 1px solid #444;
  background: #333;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: #3d3d3d; }
.btn.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
}
.provider-logo { width: 18px; height: 18px; flex: none; }
.btn.provider-google { background: #131314; color: #E3E3E3; border-color: #8E918F; }
.btn.provider-google:hover { background: #1F1F1F; }
.btn.provider-microsoft { background: #2F2F2F; color: #FFFFFF; border-color: #8C8C8C; }
.btn.provider-microsoft:hover { background: #3A3A3A; }

.login-card { max-width: 360px; margin: 60px auto; text-align: center; }

#wheel-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }

#wheel-filters {
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 2;
}
#wheel-filters > summary {
  list-style: none;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid #444;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
#wheel-filters > summary::-webkit-details-marker { display: none; }
#wheel-filters > summary::before {
  content: '▸';
  font-size: 12px;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.15s;
}
#wheel-filters[open] > summary::before { transform: rotate(90deg); }
.filter-summary-badge {
  margin-left: auto;
  background: var(--accent);
  color: #1a1a1a;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}
.filter-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid #444;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.filter-pips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.filter-pip {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #444;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s;
}
.filter-pip img { width: 22px; height: 22px; display: block; }
.filter-pip:hover { opacity: 0.8; }
.filter-pip.active { opacity: 1; border-color: var(--accent); }
.filter-pip.active:hover { opacity: 1; }
.filter-deck-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.filter-deck-actions { display: flex; gap: 4px; align-items: center; }
.filter-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  text-decoration: underline;
}
.filter-link-sep { color: var(--muted); }
.filter-deck-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.filter-deck-list li {
  border-bottom: 1px solid #2a2a2a;
}
.filter-deck-list li:last-child { border-bottom: none; }
.filter-deck-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 14px;
}
.filter-deck-list input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
  flex: none;
}
.filter-deck-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 24px;
}
.filter-reset {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  text-decoration: underline;
}
#wheel-no-match { text-align: center; color: var(--muted); padding: 32px 0; }
.wheel-frame { position: relative; width: 100%; max-width: 480px; aspect-ratio: 1; }
#wheel-canvas {
  width: 100%; height: 100%;
  transform-origin: 50% 50%;
  will-change: transform;
}
#pointer {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 3px #000, 0 1px 1px #000;
  z-index: 1;
  pointer-events: none;
}
.wheel-actions { display: flex; gap: 12px; }

.manage-toolbar { display: flex; justify-content: space-between; margin-bottom: 16px; }
#deck-list { list-style: none; padding: 0; margin: 0; }
#deck-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
#deck-list img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; }
#deck-list .deck-meta { flex: 1; min-width: 0; }
#deck-list .deck-meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#deck-list .deck-meta .sub { color: var(--muted); font-size: 13px; }
#deck-list button.delete {
  background: transparent;
  color: var(--error);
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
}

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #444;
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: calc(100% - 32px);
  margin: auto;
  overflow-wrap: anywhere;
}
dialog * { max-width: 100%; min-width: 0; }
dialog::backdrop { background: rgba(0,0,0,0.7); }
dialog form, #result-content, .confirm-content { display: flex; flex-direction: column; gap: 12px; }
.confirm-content h2 { margin: 0; font-size: 18px; }
.confirm-content p { margin: 0; color: var(--muted); }
.btn.danger { background: var(--error); color: #fff; border-color: var(--error); font-weight: 600; }
.btn.danger:hover { background: #a3181f; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
dialog input, dialog select {
  background: #1a1a1a;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 10px;
  font-size: 16px;
}
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 8px 0 0; }

.suggestions {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.suggestions li { padding: 8px 12px; cursor: pointer; }
.suggestions li:hover, .suggestions li.active { background: #333; }

#selected-card { display: flex; gap: 12px; align-items: center; }
#selected-art { width: 80px; border-radius: 4px; }

.color-pips { display: flex; gap: 4px; align-items: center; }
.color-pips .pip { width: 18px; height: 18px; display: block; }

#result-art { width: 100%; border-radius: var(--radius); }
.error { color: var(--error); font-size: 14px; }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid #444;
  z-index: 100;
}
