/* ===== Light Theme ===== */
[data-theme="light"] {
  --bg: #f5f5f5;
  --card: #ffffff;
  --card2: #f0f0f0;
  --accent: #c8ff00;
  --accent2: #00d4ff;
  --text: #1a1a1a;
  --text2: #666666;
  --text3: #999999;
  --border: #e0e0e0;
}

/* 蓝色主题 */
[data-theme="blue"] {
  --bg: #0a1628;
  --card: #132244;
  --card2: #1e3a5f;
  --accent: #64b5f6;
  --accent2: #90caf9;
  --text: #e3f2fd;
  --text2: #90b4c8;
  --text3: #5f8aa8;
  --border: #1e3a5f;
}

/* 紫色主题 */
[data-theme="purple"] {
  --bg: #1a0a2e;
  --card: #2d1b4e;
  --card2: #3d2a5e;
  --accent: #ce93d8;
  --accent2: #e1bee7;
  --text: #f3e5f5;
  --text2: #b39ddb;
  --text3: #9575cd;
  --border: #3d2a5e;
}

/* 绿色主题 */
[data-theme="green"] {
  --bg: #0a1f0a;
  --card: #1a3d1a;
  --card2: #2a5a2a;
  --accent: #a5d6a7;
  --accent2: #c8e6c9;
  --text: #e8f5e9;
  --text2: #a5d6a7;
  --text3: #81c784;
  --border: #2a5a2a;
}

/* ===== Match Page Layout ===== */
.main-layout {
  display: flex;
  min-height: 100dvh;
}

/* ===== Left Mode Nav ===== */
.mode-nav {
  width: 56px;
  background: var(--card);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}

.mode-nav-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 8px;
}

.mode-title {
  font-size: 16px;
  text-align: center;
  padding: 0 8px 8px;
}

.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:hover:not(.disabled) {
  background: var(--card2);
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: #000;
}

.mode-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-icon { font-size: 20px; }

/* ===== Mobile Mode Switch ===== */
.mode-switch-mobile {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
}
.mode-switch-mobile::-webkit-scrollbar { display: none; }

.mode-pill {
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 16px;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 70px;
}

.mode-pill span:first-child {
  font-size: 13px;
  font-weight: 500;
}

.mode-pill.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.mode-pill.active span:first-child {
  font-weight: 700;
}

.pill-sub {
  font-size: 10px;
  opacity: 0.7;
}

.mode-pill.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Desktop Mode Type Selector ===== */
.mode-type-selector {
  display: none;
  padding: 16px;
  gap: 12px;
  background: var(--bg);
}

.type-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.type-card:hover:not(.disabled) {
  border-color: var(--accent2);
}

.type-card.active {
  border-color: var(--accent);
  background: rgba(200, 255, 0, 0.05);
}

.type-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.type-icon {
  font-size: 24px;
}

.type-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.type-desc {
  font-size: 11px;
  color: var(--text2);
}

.type-info {
  font-size: 10px;
  color: var(--text3);
  text-align: center;
  line-height: 1.3;
  margin-top: 2px;
}

/* ===== Rules Preview ===== */
.tournament-type-info {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.tournament-type-info:last-of-type {
  margin-bottom: 0;
}

.tournament-type-info .type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.tournament-type-info .type-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  margin-bottom: 4px;
}

.tournament-type-info .type-stats strong {
  color: var(--accent);
}

.tournament-type-info .type-time {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text2);
}
.rules-preview {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}

.preview-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.preview-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.preview-link:hover {
  text-decoration: underline;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-row span:first-child {
  color: var(--text2);
}

.preview-row span:last-child {
  font-weight: 600;
  color: var(--accent);
}

/* ===== Content ===== */
.content {
  flex: 1;
  margin-left: 100px;
  min-height: 100dvh;
  padding-bottom: 40px;
}

/* ===== Step Tabs ===== */
.step-tabs {
  display: flex;
  overflow-x: auto;
  padding: 12px 16px;
  gap: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  scrollbar-width: none;
}

.step-tabs::-webkit-scrollbar { display: none; }

.step-tab {
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 14px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.step-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.step-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Step Pages ===== */
.step-page { display: none; }
.step-page.active { display: block; }

.step-header {
  padding: 20px 0 16px;
}

.step-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.step-sub {
  color: var(--text2);
  font-size: 13px;
}

/* ===== Form Sections ===== */
.form-section {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
}

.form-hint {
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
}

.count-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-input {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.count-sep {
  font-size: 18px;
  color: var(--text3);
}

/* ===== Court Selector ===== */
.court-selector {
  display: flex;
  gap: 8px;
}

.court-btn {
  flex: 1;
  padding: 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.court-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Rule Selector ===== */
.rule-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-option {
  cursor: pointer;
}

.rule-option input {
  display: none;
}

.rule-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  transition: all 0.2s;
}

.rule-option input:checked + .rule-card {
  border-color: var(--accent);
  background: rgba(200, 255, 0, 0.05);
}

.rule-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.rule-desc {
  font-size: 12px;
  color: var(--text2);
}

/* ===== Mode Selector ===== */
.mode-selector {
  display: flex;
  gap: 8px;
}

.mode-opt {
  flex: 1;
  padding: 10px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-opt.active {
  border-color: var(--accent);
  color: var(--accent);
}

.mode-opt.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Buttons ===== */
.primary-btn {
  width: 100%;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.04) 100%),
    var(--card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -1px 0 rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.primary-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 40px rgba(0,0,0,0.4),
    inset 0 2px 0 rgba(255,255,255,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.1);
  border-color: rgba(255,255,255,0.25);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.3),
    inset 0 2px 4px rgba(0,0,0,0.1);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%),
    var(--card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 10px 20px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    0 4px 16px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.secondary-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}

.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.25);
}

.secondary-btn:active {
  transform: translateY(0);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.2),
    inset 0 1px 2px rgba(0,0,0,0.1);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

/* ===== Player Registration ===== */
.player-input-section {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.player-input-row {
  flex: 1;
  display: flex;
  gap: 8px;
}

.player-input-row .form-input {
  flex: 1;
}

.player-input-row .form-select {
  width: 70px;
}

.player-lists {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-list-box {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.list-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: var(--card2);
  border-bottom: 1px solid var(--border);
}

.player-list {
  padding: 8px;
  min-height: 80px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.player-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card2);
  border-radius: 50px;
  padding: 6px 10px;
  font-size: 13px;
}

.player-tag .remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}

.player-tag .remove:hover {
  color: var(--danger);
}

/* ===== Match Preview ===== */
.match-preview {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
}

.preview-loading {
  text-align: center;
  color: var(--text2);
  padding: 20px;
}

.match-preview-grid {
  display: grid;
  gap: 8px;
}

.preview-match {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--card2);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.preview-match .round {
  color: var(--text3);
  min-width: 30px;
}

.preview-match .players {
  flex: 1;
  color: var(--text);
}

.preview-match .court-badge {
  background: var(--card);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text2);
}

/* ===== Court Tabs ===== */
.court-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.court-tabs::-webkit-scrollbar { display: none; }

.court-tab {
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
}

.court-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

/* ===== Match List ===== */
.match-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.match-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.match-card-header {
  padding: 12px 14px;
  background: var(--card2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.match-round {
  font-size: 12px;
  color: var(--text2);
}

.match-court {
  font-size: 11px;
  background: var(--accent);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.match-card-body {
  padding: 14px;
}

.match-teams {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.match-team {
  flex: 1;
  text-align: center;
}

.match-team.players {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.match-team.score {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.match-vs {
  color: var(--text3);
  font-size: 14px;
  font-weight: 600;
}

.match-status {
  text-align: center;
  padding: 8px;
  background: var(--card2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.match-status.completed {
  color: var(--success);
  cursor: default;
}

/* ===== Rankings ===== */
.ranking-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}

.ranking-header {
  padding: 12px 14px;
  background: var(--card2);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

.ranking-list {
  padding: 8px;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.ranking-row:last-child {
  border-bottom: none;
}

.ranking-pos {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--card2);
  color: var(--text2);
}

.ranking-pos.gold {
  background: #ffd700;
  color: #000;
}

.ranking-pos.silver {
  background: #c0c0c0;
  color: #000;
}

.ranking-pos.bronze {
  background: #cd7f32;
  color: #fff;
}

.ranking-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.ranking-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text2);
}

.ranking-stats span {
  min-width: 40px;
  text-align: right;
}

.ranking-stats .points {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}

/* ===== Score Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-form .modal-body {
  padding: 20px;
}

.modal-form .form-section {
  margin-bottom: 16px;
}

.modal-form .btn-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-form .btn-row .primary-btn,
.modal-form .btn-row .secondary-btn {
  flex: 1;
  margin: 0;
}

.modal-rules-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.modal-rules-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.rule-selector-modal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-option-modal {
  display: block;
  cursor: pointer;
}

.rule-option-modal input {
  display: none;
}

.rule-card-modal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
}

.rule-option-modal input:checked + .rule-card-modal {
  border-color: var(--accent);
  background: rgba(200, 255, 0, 0.05);
}

.rule-option-modal .rule-name {
  font-weight: 600;
  font-size: 14px;
}

.rule-option-modal .rule-desc {
  font-size: 11px;
  color: var(--text2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: var(--card2);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.modal-footer .primary-btn,
.modal-footer .secondary-btn {
  flex: 1;
  margin: 0;
}

.match-info {
  text-align: center;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 16px;
}

.score-input-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.score-team {
  text-align: center;
}

.team-label {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card2);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-btn:active {
  background: var(--accent);
  border-color: var(--accent);
}

.score-num {
  font-size: 36px;
  font-weight: 700;
  min-width: 50px;
  text-align: center;
}

.score-vs {
  font-size: 16px;
  color: var(--text3);
  font-weight: 600;
}

.score-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  margin-top: 12px;
}

.score-validation {
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
  min-height: 20px;
  transition: color 0.2s;
}

.score-validation.error {
  color: #e74c3c;
}

.score-validation.success {
  color: #27ae60;
}

#confirmScoreBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== QR Code Section ===== */
.qr-section {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.qr-section.show {
  display: flex;
}

.qr-card {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 320px;
  overflow: hidden;
}

.qr-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

.qr-close {
  background: var(--card2);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
}

.qr-body {
  padding: 24px;
  text-align: center;
}

#qrCanvas {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin: 0 auto 12px;
  max-width: 200px;
}

.qr-hint {
  font-size: 12px;
  color: var(--text3);
}

.qr-save-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.share-btn:hover {
  background: var(--card2);
}

.share-btn:active {
  transform: scale(0.98);
}

/* ===== FAB Button (for tournaments list) */
.fab-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 28px;
  cursor: pointer;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.fab-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ===== Tournament Card ===== */
.tournament-card {
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.2s;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.08) 100%),
    rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    inset 1px 0 0 rgba(255, 255, 255, 0.1),
    inset -1px 0 0 rgba(255, 255, 255, 0.05);
  overflow: visible;
  cursor: pointer;
  padding: 16px;
  margin-bottom: 12px;
}
.tournament-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}
.tournament-card:hover {
  transform: translateY(-6px) scale(1.02);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.12) 100%),
    rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    inset 2px 0 0 rgba(255, 255, 255, 0.15),
    inset -2px 0 0 rgba(255, 255, 255, 0.08);
}
.tournament-card:active {
  transform: translateY(-2px) scale(0.98);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.03) 100%),
    rgba(255, 255, 255, 0.08);
  box-shadow:
    0 6px 24px rgba(0,0,0,0.35),
    0 2px 6px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  /* Hide left mode nav, show mobile mode switch */
  .mode-nav {
    display: none;
  }

  .mode-switch-mobile {
    display: flex;
  }

  .mode-type-selector {
    display: none;
  }

  .content {
    margin-left: 0 !important;
  }
}

@media (min-width: 769px) {
  /* Show left mode nav, hide mobile mode switch */
  .mode-nav {
    display: flex;
  }

  .mode-switch-mobile {
    display: none;
  }

  .mode-type-selector {
    display: flex;
  }

  .content {
    margin-left: 56px;
  }
}

/* ===== Tournament List View ===== */
.tournament-list-view {
  padding: 16px;
}
.tournament-list-header {
  margin-bottom: 16px;
}
.tournament-list-header h2 {
  font-size: 20px;
  margin-bottom: 12px;
}
.tournament-list-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.list-tab {
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text2);
  border-radius: 20px;
  cursor: pointer;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}
.list-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}
.list-tab.active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.tc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tc-name {
  font-weight: 600;
  font-size: 16px;
}
.tc-code {
  font-family: monospace;
  font-size: 12px;
  color: var(--text2);
  background: var(--card);
  padding: 2px 8px;
  border-radius: 4px;
}
.tc-info {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 8px;
}
.tc-status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.tc-status.ongoing {
  background: #4CAF50;
  color: #fff;
}
.tc-status.setup {
  background: #FF9800;
  color: #fff;
}
.tc-status.completed {
  background: #9E9E9E;
  color: #fff;
}
.tc-rule {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: var(--accent);
  color: #000;
}
.tc-slogan {
  font-size: 14px;
  color: var(--text);
  font-style: italic;
  margin-bottom: 6px;
  padding-left: 4px;
}
.tc-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}
.tc-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tc-progress {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tc-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg2);
  border-radius: 3px;
  overflow: hidden;
}
.tc-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.tc-time {
  font-size: 12px;
  color: var(--text2);
}
.tc-players {
  font-size: 13px;
  margin-bottom: 8px;
  line-height: 1.4;
}
.player-group {
  display: block;
  color: var(--text2);
}
.tc-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.tc-qr-btn {
  padding: 6px 12px;
  border: none;
  background: var(--accent, #c8ff00);
  color: #000;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.step-nav-hidden {
  display: none !important;
}

/* ===== Back Button ===== */
.back-btn {
  position: fixed;
  top: 70px;
  left: 16px;
  padding: 8px 16px;
  background: var(--card2);
  color: var(--text);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  z-index: 100;
  font-size: 14px;
}
.version-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text2);
}
.version-footer a {
  color: var(--accent, #c8ff00);
}

/* ===== New Tournament Modal ===== */
.modal-desc {
  text-align: center;
  margin-bottom: 16px;
  color: var(--text2);
}
.new-tournament-types {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-rules-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal-rules-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-rules-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.modal-rules-link:hover {
  text-decoration: underline;
}
.modal-rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-rules-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.modal-rules-name {
  font-weight: 600;
}
.modal-rules-info {
  font-size: 11px;
  color: var(--text2);
}
.type-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--border);
  background: var(--card2);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.type-btn:hover {
  border-color: var(--accent, #c8ff00);
}
.type-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.type-btn .type-icon {
  font-size: 24px;
}
.type-btn .type-name {
  font-weight: 600;
  font-size: 16px;
}
.type-btn .type-desc {
  font-size: 13px;
  color: var(--text2);
}

/* ===== Tournament Card Dropdown ===== */
.tc-dropdown {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}
.tc-dropdown.show {
  display: block;
}
.tc-dropdown-backdrop {
  position: absolute;
  inset: 0;
}
.tc-dropdown-menu {
  position: absolute;
  top: var(--dropdown-y, 0);
  right: var(--dropdown-x, 16px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.tc-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.tc-dropdown-item:hover {
  background: var(--card2);
}

/* ===== Tournament Card More Button ===== */
.tc-more-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.tc-more-btn:hover {
  background: var(--card2);
}

/* ===== Inline Detail Expanded ===== */
.tournament-card.expanded {
  background: var(--card2);
}
.tc-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tc-inline-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tournament-card.expanded .tc-inline-detail {
  display: block;
}
.tournament-card.expanded .tc-actions {
  display: none;
}
.tc-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 8px;
}
.tc-section-title:first-child {
  margin-top: 0;
}

/* Inline match rows */
.tc-match-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--card);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.tc-match-teams {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tc-match-team {
  flex: 1;
  text-align: center;
}
.tc-match-vs {
  color: var(--text3);
  font-size: 11px;
}
.tc-match-score {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  min-width: 24px;
  text-align: center;
}
.tc-match-edit {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}
.tc-match-edit.completed {
  background: var(--card2);
  color: var(--text2);
  cursor: default;
}

/* Inline ranking rows */
.tc-ranking-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 13px;
}
.tc-ranking-pos {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
}
.tc-ranking-pos.gold { background: #ffd700; color: #000; }
.tc-ranking-pos.silver { background: #c0c0c0; color: #000; }
.tc-ranking-pos.bronze { background: #cd7f32; color: #fff; }
.tc-ranking-name {
  flex: 1;
  font-weight: 500;
}
.tc-ranking-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text2);
}
.tc-ranking-stats .pts {
  color: var(--accent);
  font-weight: 700;
}

/* Load More / Progress Indicator */
.load-more-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.load-more-container:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.load-more-container:active {
  transform: scale(0.99);
  background: rgba(255, 255, 255, 0.06);
}

.load-more-bar {
  flex: 1;
  height: 6px;
  background: var(--card2);
  border-radius: 3px;
  overflow: hidden;
}

.load-more-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.load-more-text {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  white-space: nowrap;
  min-width: 45px;
  text-align: center;
}

.load-more-btn-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--card2);
  border-radius: 20px;
}

.load-more-btn-inner .icon {
  font-size: 12px;
  transition: transform 0.3s ease;
}

.load-more-container:hover .icon {
  transform: rotate(180deg);
}

