* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0f1117;
  color: #e1e4e8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

/* Navbar */
.navbar {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  height: 90px;
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: visible;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.nav-brand {
  color: #58a6ff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  align-self: center;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-links a {
  color: #8b949e;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: #e1e4e8;
}

.nav-link-btn {
  background: none;
  border: none;
  color: #8b949e;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}

.nav-link-btn:hover {
  color: #e1e4e8;
}

/* Account popover menu */
.nav-account-wrapper {
  position: relative;
}

.nav-account-btn {
  background: none;
  border: 1px solid transparent;
  color: #8b949e;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s, border-color 0.2s;
}

.nav-account-btn:hover {
  background: #21262d;
  border-color: #30363d;
  color: #e1e4e8;
}

.nav-account-caret {
  font-size: 0.7rem;
  margin-left: 2px;
  opacity: 0.6;
}

.nav-account-popover {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  min-width: 160px;
  padding: 4px 0;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.nav-account-popover.open {
  display: block;
}

.nav-popover-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  color: #c9d1d9;
  text-decoration: none;
  font-size: 0.85rem;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.nav-popover-item:hover {
  background: #21262d;
  color: #e1e4e8;
  text-decoration: none;
}

.nav-popover-divider {
  height: 1px;
  background: #30363d;
  margin: 4px 0;
}

.nav-popover-logout {
  color: #f85149;
}

.nav-popover-logout:hover {
  color: #f85149;
  background: rgba(248, 81, 73, 0.1);
}

/* Home logo */
.hero-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.home-logo {
  max-width: 80%;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Navbar logo */
.nav-logo {
  width: 220px;
  height: auto;
  border-radius: 4px;
  position: relative;
  top: 10px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

/* Main content */
main {
  flex: 1;
  padding: 2rem 0;
}

/* Typography */
h1, h2, h3, h4 {
  color: #e1e4e8;
  margin-bottom: 1rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a {
  color: #58a6ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Cards */
.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  color: #8b949e;
  font-size: 0.9rem;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #e1e4e8;
  font-size: 0.95rem;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: #58a6ff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Disabled fields */
.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
  background: #161b22;          /* slightly lighter than normal bg */
  color: #8b949e;               /* muted text */
  border-color: #21262d;        /* softer border */
  cursor: not-allowed;
  opacity: 1;                   /* override default browser fade */
}




/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid #30363d;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-primary {
  background: #238636;
  color: #fff;
  border-color: #238636;
}

.btn-primary:hover {
  background: #2ea043;
  text-decoration: none;
}

.btn-danger {
  background: #da3633;
  color: #fff;
  border-color: #da3633;
}

.btn-danger:hover {
  background: #f85149;
  text-decoration: none;
}

.btn-secondary {
  background: #21262d;
  color: #c9d1d9;
}

.btn-secondary:hover {
  background: #30363d;
  text-decoration: none;
}

.btn-warning {
  background: #9e6a03;
  color: #fff;
  border-color: #9e6a03;
}

.btn-warning:hover {
  background: #bb8009;
  text-decoration: none;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #21262d;
}

th {
  color: #8b949e;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}

tr:hover {
  background: #161b22;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-draft { background: #21262d; color: #8b949e; }
.badge-registration { background: #0d419d; color: #79c0ff; }
.badge-active { background: #0f5323; color: #56d364; }
.badge-completed { background: #272c17; color: #e3b341; }
.badge-cancelled { background: #3d1e20; color: #f85149; }

.badge-registered { background: #1a3a3a; color: #39d0d8; }

.badge-pending { background: #21262d; color: #8b949e; }
.badge-submitted { background: #0d419d; color: #79c0ff; }
.badge-confirmed { background: #1a3a1a; color: #7ee787; }
.badge-verified { background: #0f5323; color: #56d364; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #3d1e20;
  color: #f85149;
  border: 1px solid #f8514933;
}

.alert-success {
  background: #1a3a1a;
  color: #56d364;
  border: 1px solid #56d36433;
}

.alert-info {
  background: #0d2744;
  color: #79c0ff;
  border: 1px solid #79c0ff33;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #58a6ff;
}

.stat-label {
  font-size: 0.8rem;
  color: #8b949e;
  margin-top: 0.25rem;
}

/* Seating inputs */
.seating-input {
  width: 60px;
  text-align: center;
}

/* Match result inputs */
.result-inputs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.result-inputs input {
  width: 60px;
  text-align: center;
  padding: 0.4rem;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #e1e4e8;
}

.result-inputs span {
  color: #8b949e;
  font-size: 0.85rem;
}

/* Section spacing */
.section {
  margin-bottom: 2rem;
}

/* Footer */
.footer {
  border-top: 1px solid #30363d;
  padding: 1rem 0;
  text-align: center;
  color: #484f58;
  font-size: 0.8rem;
  margin-top: auto;
}

/* Calendar */
.calendar-container {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 1rem;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
  table-layout: fixed;
}

.calendar-day-header {
  background: #0d1117;
  color: #8b949e;
  padding: 0.5rem 0.25rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  overflow: hidden;
}

.calendar-cell {
  background: #0d1117;
  min-height: 90px;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}

.calendar-cell-empty {
  background: #0a0d12;
}

.calendar-today {
  outline: 2px solid #58a6ff;
  outline-offset: -2px;
}

.calendar-has-events {
  background: #111820;
}

.calendar-date {
  font-size: 0.8rem;
  color: #8b949e;
  margin-bottom: 2px;
}

.calendar-event {
  display: block;
  font-size: 0.7rem;
  padding: 2px 3px;
  border-radius: 3px;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.3;
  cursor: pointer;
  min-width: 0;
}

.calendar-event:hover {
  text-decoration: none;
  filter: brightness(1.2);
  white-space: normal;
  word-break: break-word;
}

/* Avatars */
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  flex-shrink: 0;
}

.avatar-sm {
  width: 20px;
  height: 20px;
}

.avatar-lg {
  width: 64px;
  height: 64px;
}

.avatar-xl {
  width: 80px;
  height: 80px;
}

.player-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Deck grid on list page */
.deck-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

/* ═══════════════════════════════════════
   DECK EDITOR
   ═══════════════════════════════════════ */

#deck-editor {
  display: flex;
  flex-direction: column;
  margin: -2rem 0;
  min-height: calc(100vh - 120px);
}

.de-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.de-name-input {
  flex: 1;
  min-width: 0;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 7px 10px;
  color: #e1e4e8;
  font-size: 14px;
  font-weight: 800;
  outline: none;
}

.de-name-input:focus {
  border-color: #58a6ff;
}

.de-card-count {
  font-size: 12px;
  color: #8b949e;
  white-space: nowrap;
}

.de-panels {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.de-mobile-toggle {
  display: none;
}

/* ── Card Browser (left panel) ── */
.de-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #30363d;
  overflow: hidden;
  min-width: 0;
}

.de-search-bar {
  padding: 10px 12px 6px;
  flex-shrink: 0;
}

.de-search-input {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 9px 10px;
  color: #e1e4e8;
  font-size: 13px;
  outline: none;
}

.de-search-input:focus {
  border-color: #58a6ff;
}

.de-filter-bar {
  padding: 0 12px 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.de-chip-btn {
  border: 1px solid #30363d;
  background: #21262d;
  color: #8b949e;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.de-chip-btn:hover {
  background: #30363d;
  color: #e1e4e8;
}

.de-chip-btn.active {
  background: rgba(35, 134, 54, 0.2);
  color: #56d364;
  border-color: rgba(35, 134, 54, 0.3);
}

.de-chip-danger {
  color: #f85149 !important;
  background: rgba(248, 81, 73, 0.1) !important;
  border-color: rgba(248, 81, 73, 0.2) !important;
}

.de-sort-select {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 5px 6px;
  color: #8b949e;
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

.de-view-toggle {
  display: flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #30363d;
}

.de-toggle-btn {
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  background: transparent;
  color: #484f58;
}

.de-toggle-btn.active {
  background: #30363d;
  color: #e1e4e8;
}

.de-filters-panel {
  margin: 0 12px 8px;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  flex-shrink: 0;
}

.de-filter-group {
  margin-bottom: 8px;
}

.de-filter-group:last-child {
  margin-bottom: 0;
}

.de-filter-label {
  font-size: 11px;
  font-weight: 800;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.de-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.de-filter-chip {
  font-size: 11px !important;
  padding: 3px 8px !important;
}

.de-filter-chip.active {
  background: rgba(35, 134, 54, 0.2) !important;
  color: #56d364 !important;
  border-color: rgba(35, 134, 54, 0.3) !important;
}

.de-results-count {
  padding: 0 12px 6px;
  font-size: 11px;
  color: #484f58;
}

.de-results {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}

.de-empty-msg {
  color: #484f58;
  padding: 20px;
  text-align: center;
  font-size: 12px;
}

/* ── Results Grid ── */
.de-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.de-result-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #161b22;
  border: 1px solid #30363d;
  cursor: pointer;
}

.de-result-card.in-deck {
  border-color: #238636;
  border-width: 2px;
}

.de-card-img {
  width: 100%;
  display: block;
  aspect-ratio: 488 / 680;
  object-fit: cover;
  background: #0d1117;
}

.de-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
}

.de-card-name {
  font-size: 10px;
  font-weight: 800;
  color: rgba(255,255,255,0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.de-add-btn {
  border: none;
  background: rgba(35, 134, 54, 0.3);
  color: #56d364;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.de-add-btn:hover {
  background: rgba(35, 134, 54, 0.5);
}

.de-add-btn:active {
  background: rgba(35, 134, 54, 0.7);
  transform: scale(0.95);
}

.de-in-deck-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #238636;
  color: #fff;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 900;
}

/* ── Results List ── */
.de-results-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.de-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #161b22;
  border: 1px solid #21262d;
}

.de-result-row.in-deck {
  border-color: rgba(35, 134, 54, 0.3);
  background: rgba(35, 134, 54, 0.05);
}

.de-result-thumb {
  width: 48px;
  height: 67px;
  border-radius: 4px;
  object-fit: cover;
  background: #0d1117;
  flex-shrink: 0;
  cursor: pointer;
}

.de-result-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.de-result-name {
  font-size: 12px;
  font-weight: 700;
  color: #e1e4e8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.de-result-meta {
  font-size: 10px;
  color: #484f58;
  margin-top: 1px;
}

.de-result-count {
  font-size: 12px;
  font-weight: 900;
  color: #56d364;
  min-width: 20px;
  text-align: center;
}

/* ── Deck Panel (right) ── */
.de-deck {
  width: 380px;
  min-width: 320px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d1117;
}

.de-deck-header {
  padding: 8px 12px;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.de-deck-label {
  font-size: 12px;
  font-weight: 900;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.de-cost-curve {
  padding: 8px 12px 6px;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
}

.de-curve-label {
  font-size: 10px;
  font-weight: 800;
  color: #484f58;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.de-curve-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 32px;
}

.de-curve-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 0;
  transition: background 0.15s;
}

.de-curve-col:hover {
  background: rgba(88, 166, 255, 0.1);
}

.de-curve-col.de-curve-selected {
  background: rgba(88, 166, 255, 0.15);
}

.de-curve-count {
  font-size: 8px;
  color: #8b949e;
  line-height: 1;
  min-height: 9px;
}

.de-curve-bar {
  width: 100%;
  background: #21262d;
  border-radius: 2px;
  transition: height 0.2s;
}

.de-curve-bar.active {
  background: rgba(35, 134, 54, 0.5);
}

.de-curve-bar.selected {
  background: #58a6ff !important;
}

.de-curve-num {
  font-size: 8px;
  color: #484f58;
  line-height: 1;
}

.de-curve-selected .de-curve-num {
  color: #58a6ff;
  font-weight: 900;
}

.de-deck-contents {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

.de-section-header {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #484f58;
  text-transform: uppercase;
  padding: 4px 2px 6px;
}

/* Deck list view */
.de-deck-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  background: #161b22;
  border: 1px solid #21262d;
  margin-bottom: 4px;
}

.de-deck-thumb {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  background: #0d1117;
  flex-shrink: 0;
  cursor: pointer;
}

.de-deck-row-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.de-deck-row-name {
  font-size: 12px;
  font-weight: 700;
  color: #e1e4e8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.de-deck-row-id {
  font-size: 9px;
  color: #484f58;
}

.de-deck-row-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.de-deck-row-count {
  min-width: 18px;
  text-align: center;
  font-weight: 900;
  font-size: 12px;
  color: #e1e4e8;
}

.de-sm-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #8b949e;
  cursor: pointer;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.de-sm-btn:hover {
  background: #21262d;
  color: #e1e4e8;
}

.de-sm-btn:active {
  background: #30363d;
  transform: scale(0.95);
}

.de-sm-btn-danger {
  color: #f85149 !important;
  background: rgba(248, 81, 73, 0.1) !important;
}

/* Deck grid view */
.de-deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.de-deck-grid-card {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #161b22;
  border: 1px solid #21262d;
}

.de-deck-grid-img {
  width: 100%;
  display: block;
  aspect-ratio: 488 / 680;
  object-fit: cover;
  background: #0d1117;
  cursor: pointer;
}

.de-deck-grid-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 900;
}

.de-deck-grid-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 3px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.de-tiny-btn {
  width: 28px;
  height: 26px;
  border-radius: 5px;
  border: none;
  background: rgba(0,0,0,0.50);
  color: rgba(255,255,255,0.80);
  cursor: pointer;
  font-weight: 900;
  font-size: 15px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.de-tiny-btn:active {
  background: rgba(0,0,0,0.70);
  transform: scale(0.95);
}

.de-tiny-btn-danger {
  color: #f85149;
}

/* Deck footer */
.de-deck-footer {
  padding: 8px 12px;
  border-top: 1px solid #21262d;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* ── Zoom overlay ── */
.de-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
/* Card-detail zoom must sit above scanner / import overlays */
#de-zoom-overlay {
  z-index: 10001;
}
 
.de-zoom-content {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.de-zoom-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.de-zoom-name {
  font-weight: 900;
  color: #e1e4e8;
  font-size: 14px;
}

.de-zoom-id {
  color: #484f58;
  font-size: 11px;
  margin-top: 2px;
}

.de-zoom-close {
  border: none;
  background: #21262d;
  color: #8b949e;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.de-zoom-img-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.de-zoom-img {
  width: min(320px, 80vw);
  height: auto;
  border-radius: 10px;
  object-fit: cover;
  background: #0d1117;
}

.de-zoom-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid #21262d;
}

.de-zoom-meta-label {
  font-size: 11px;
  font-weight: 800;
  color: #484f58;
  text-transform: uppercase;
}

.de-zoom-meta-val {
  font-size: 12px;
  color: #8b949e;
}

.de-zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
  border-top: 1px solid #21262d;
}

.de-zoom-count {
  min-width: 30px;
  text-align: center;
  font-weight: 900;
  font-size: 16px;
  color: #e1e4e8;
}

.de-zoom-label {
  font-size: 12px;
  color: #484f58;
}

/* ═══════════════════════════════════════
   CARD SCANNER MODAL
   ═══════════════════════════════════════ */

.de-scanner-modal {
  max-width: 480px;
  width: 90vw;
}

.de-scanner-video-wrap {
  position: relative;
  width: 100%;
  background: #0d1117;
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
  min-height: 160px;
  max-height: 65vh;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.de-scanner-video-wrap video {
  width: 100%;
  height: 100%;
  max-height: 60vh;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}

.de-scanner-fallback {
  text-align: center;
  padding: 40px 20px;
  color: #8b949e;
  font-size: 13px;
}

.de-scanner-fallback p {
  margin: 4px 0;
}

.de-scanner-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

.de-scanner-state {
  text-align: center;
  padding: 20px 0;
  color: #8b949e;
}

.de-scanner-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #30363d;
  border-top-color: #58a6ff;
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: de-spin 0.8s linear infinite;
}

@keyframes de-spin {
  to { transform: rotate(360deg); }
}

.de-scanner-results-title {
  font-size: 13px;
  font-weight: 700;
  color: #e1e4e8;
  margin: 0 0 10px;
  text-align: left;
}

.de-scanner-results-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.de-scanner-match {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 8px;
}

.de-scanner-match-img {
  width: 52px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  background: #161b22;
  flex-shrink: 0;
  cursor: pointer;
}

.de-scanner-match-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.de-scanner-match-name {
  font-size: 13px;
  font-weight: 700;
  color: #e1e4e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.de-scanner-match-conf {
  font-size: 11px;
  color: #8b949e;
  margin-top: 2px;
}

.de-scanner-add-btn {
  flex-shrink: 0;
}

.de-scanner-no-match {
  color: #f85149;
  font-size: 13px;
  padding: 20px 0;
}

/* Card guide overlay — crop region shown on camera feed */
/* Sizing must stay in sync with capturePhoto() in deck-editor.js */
.de-scanner-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 70%;
  aspect-ratio: 5 / 7;
  max-width: 80%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(88, 166, 255, 0.9);
  border-radius: 10px;
  outline: 9999px solid rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;
}

.de-scanner-guide::after {
  content: 'Align card \2022  Tap to capture';
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Edge-detection overlay canvas — draws detected card outline */
.de-scanner-edge-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* Auto-suggestion popover on live camera feed */
.de-scanner-suggestions {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  z-index: 5;
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 45%;
  overflow-y: auto;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.de-scanner-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.de-scanner-suggestion:hover,
.de-scanner-suggestion:active {
  background: rgba(88, 166, 255, 0.15);
}

.de-scanner-suggestion-img {
  width: 32px;
  height: 45px;
  object-fit: cover;
  border-radius: 3px;
  background: #0d1117;
  flex-shrink: 0;
}

.de-scanner-suggestion-info {
  flex: 1;
  min-width: 0;
}

.de-scanner-suggestion-name {
  font-size: 12px;
  font-weight: 700;
  color: #e1e4e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.de-scanner-suggestion-conf {
  font-size: 10px;
  color: #8b949e;
  margin-top: 1px;
}

.de-scanner-suggestion-add {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 8px;
}

.de-scanner-suggestions-label {
  font-size: 10px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 2px 2px;
  font-weight: 600;
}

.de-scanner-best-match {
  border-color: #3fb950;
}

/* Responsive */
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .nav-links {
    gap: 0.75rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .calendar-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .calendar-grid {
    min-width: 600px;
  }
  .calendar-cell {
    min-height: 80px;
    padding: 0.25rem;
  }
  .calendar-event {
    font-size: 0.65rem;
  }
}

/* Deck editor responsive */
@media (max-width: 699px) {
  .de-card-count { display: none !important; }
  .de-deck {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    border-right: none !important;
  }
  .de-browser {
    border-right: none !important;
  }
  .de-panels {
    flex-direction: column;
  }
}

/* ═══════════════════════════════════════
   RIFTBOUND ICON FONT
   ═══════════════════════════════════════ */

@font-face {
  font-family: 'Riftbound Icons';
  src: url('/css/riftbound_FONT.ttf') format('truetype');
  font-display: swap;
}

.rb-icon {
  font-family: 'Riftbound Icons', sans-serif;
  font-style: normal;
  font-weight: normal;
  font-size: 1.1em;
  line-height: 1;
  vertical-align: middle;
}

/* ═══════════════════════════════════════
   WIDER LAYOUT FOR DECK EDITOR
   ═══════════════════════════════════════ */

main.de-wide {
  max-width: 1600px;
  padding: 0 0.5rem;
}

/* ═══════════════════════════════════════
   DECK TYPE BAR (editor)
   ═══════════════════════════════════════ */

.de-type-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.de-type-label {
  font-size: 11px;
  font-weight: 800;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.de-type-select {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 5px 8px;
  color: #e1e4e8;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.de-type-select:focus {
  border-color: #58a6ff;
}

.de-type-separator {
  color: #484f58;
  font-weight: 800;
  font-size: 14px;
}

.de-subtype-input {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 5px 8px;
  color: #e1e4e8;
  font-size: 12px;
  outline: none;
  width: 140px;
}

.de-subtype-input:focus {
  border-color: #58a6ff;
}

.de-subtype-input::placeholder {
  color: #484f58;
}

/* ═══════════════════════════════════════
   KEYWORD FILTER CHIPS
   ═══════════════════════════════════════ */

.de-kw-green {
  background: #21705b !important;
  color: #fff !important;
  border-color: #21705b !important;
}

.de-kw-green.active {
  background: #2a9975 !important;
  color: #fff !important;
  border-color: #2a9975 !important;
  box-shadow: 0 0 0 2px rgba(33, 112, 91, 0.5);
}

.de-kw-pink {
  background: #ce356b !important;
  color: #fff !important;
  border-color: #ce356b !important;
}

.de-kw-pink.active {
  background: #e04d83 !important;
  color: #fff !important;
  border-color: #e04d83 !important;
  box-shadow: 0 0 0 2px rgba(206, 53, 107, 0.5);
}

.de-kw-gray {
  background: #6d6e6b !important;
  color: #fff !important;
  border-color: #6d6e6b !important;
}

.de-kw-gray.active {
  background: #8a8b88 !important;
  color: #fff !important;
  border-color: #8a8b88 !important;
  box-shadow: 0 0 0 2px rgba(109, 110, 107, 0.5);
}

.de-kw-olive {
  background: #94b131 !important;
  color: #000 !important;
  border-color: #94b131 !important;
}

.de-kw-olive.active {
  background: #a8c748 !important;
  color: #000 !important;
  border-color: #a8c748 !important;
  box-shadow: 0 0 0 2px rgba(148, 177, 49, 0.5);
}

/* ═══════════════════════════════════════
   CHOSEN + SIDEBOARD STYLES (deck editor)
   ═══════════════════════════════════════ */

.de-chosen-star {
  color: #f0c040;
  font-size: 13px;
}

.de-chosen-btn {
  font-size: 12px !important;
  color: #484f58 !important;
  background: transparent !important;
  border-color: transparent !important;
}

.de-chosen-btn.active {
  color: #f0c040 !important;
}

.de-chosen-btn:hover {
  color: #f0c040 !important;
}

.de-sb-btn {
  font-size: 9px !important;
  font-weight: 900 !important;
  color: #484f58 !important;
  background: transparent !important;
  border-color: transparent !important;
}

.de-sb-btn.active {
  color: #d2a8ff !important;
}

.de-sb-btn:hover {
  color: #d2a8ff !important;
}

.de-deck-row-chosen {
  border-color: rgba(240, 192, 64, 0.4) !important;
  background: rgba(240, 192, 64, 0.05) !important;
}

.de-deck-row-sb {
  border-color: rgba(210, 168, 255, 0.3) !important;
  background: rgba(210, 168, 255, 0.05) !important;
}

.de-section-sideboard {
  color: #d2a8ff !important;
}

.de-deck-grid-chosen {
  border-color: rgba(240, 192, 64, 0.5) !important;
}

.de-deck-grid-chosen-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  color: #f0c040;
  font-size: 16px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.de-grid-chosen-btn {
  position: absolute;
  top: 3px;
  left: 3px;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 4px;
  color: rgba(255,255,255,0.5);
  font-size: 16px;
  cursor: pointer;
  padding: 1px 4px;
  line-height: 1;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.de-grid-chosen-btn:hover {
  color: #f0c040;
  background: rgba(0,0,0,0.8);
}

.de-grid-chosen-btn.active {
  color: #f0c040;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.de-deck-grid-sb {
  border-color: rgba(210, 168, 255, 0.4) !important;
}

/* ═══════════════════════════════════════
   DECK LIST PAGE - TYPE BADGES + STATS
   ═══════════════════════════════════════ */

.deck-type-badge[data-deck-type="Aggro"] { background: #6e1a1a; color: #ff6b6b; }
.deck-type-badge[data-deck-type="MidRange"] { background: #4a3000; color: #ffa94d; }
.deck-type-badge[data-deck-type="Control"] { background: #0d2744; color: #79c0ff; }
.deck-type-badge[data-deck-type="Tempo"] { background: #1a3a3a; color: #39d0d8; }
.deck-type-badge[data-deck-type="Ramp"] { background: #1a3a1a; color: #7ee787; }
.deck-type-badge[data-deck-type="Combo"] { background: #3d1e42; color: #d2a8ff; }
.deck-type-badge[data-deck-type="Token"] { background: #272c17; color: #e3b341; }

/* W/L/D Stats row */
.deck-stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.deck-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
}

.deck-stat-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #8b949e;
  cursor: pointer;
  font-weight: 900;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.deck-stat-btn:hover {
  background: #21262d;
  color: #e1e4e8;
}

.deck-stat-btn:active {
  background: #30363d;
  transform: scale(0.95);
}

.deck-stat-val {
  min-width: 22px;
  text-align: center;
  font-weight: 900;
  font-size: 1rem;
  color: #e1e4e8;
}

.deck-stat-wins { color: #56d364; }
.deck-stat-losses { color: #f85149; }
.deck-stat-draws { color: #8b949e; }

.deck-stat-label {
  font-size: 0.8rem;
  color: #484f58;
  font-weight: 700;
}

.deck-stat-separator {
  color: #30363d;
  font-size: 1rem;
  margin: 0 4px;
}

.deck-event-stats {
  font-size: 0.8rem;
  color: #8b949e;
}

.deck-event-val {
  font-weight: 700;
  color: #8b949e;
  margin-right: 2px;
}
