.tb-app {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  #tb-app .tb-hidden {
    display: none;
  }

  .tb-active-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .tb-tournament-header {
    flex: 1;
    min-width: 0;
  }

  .tb-tournament-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-base);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tb-tournament-date {
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  #tb-app .tb-title-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent);
    color: var(--text-base);
    font-weight: 700;
    font-size: 1.25rem;
    outline: none;
    min-width: 200px;
  }

  #tb-app .tb-edit-icon {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    background: currentcolor;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
    mask-size: contain;
    opacity: 0.5;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 0.5rem;
  }

  .tb-controls-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .tb-btn-next-match {
    display: none;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
  }

  @media (min-width: 768px) {
    .tb-btn-next-match {
      display: flex;
    }
  }

  .tb-btn-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #059669;
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
  }

  .tb-share-label {
    display: none;
  }

  @media (min-width: 768px) {
    .tb-share-label {
      display: inline;
    }
  }

  .tb-btn-back {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
  }

  .tb-btn-back:hover {
    color: var(--accent);
    border-color: var(--accent);
  }

  .tb-back-short {
    display: inline;
  }

  .tb-back-full {
    display: none;
  }

  @media (min-width: 640px) {
    .tb-back-short {
      display: none;
    }

    .tb-back-full {
      display: inline;
    }
  }

  .tb-setup-view {
    display: flex;
  }

  .tb-setup-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    width: 100%;
  }

  @media (min-width: 768px) {
    .tb-setup-grid {
      grid-template-columns: 1fr 1fr;
      align-items: start;
    }
  }

  .tb-setup-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }

  .tb-setup-card-header {
    text-align: center;
  }

  .tb-setup-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-base);
    margin: 0 0 0.5rem;
  }

  .tb-setup-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
  }

  .tb-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .tb-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .tb-input {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-base);
    font-size: 1rem;
    outline: none;
    width: 100%;
    box-sizing: border-box;
  }

  .tb-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.15);
  }

  .tb-input-row {
    display: flex;
    gap: 0.5rem;
  }

  .tb-input-row .tb-input {
    flex: 1;
  }

  .tb-btn-add {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .tb-btn-add:active {
    transform: scale(0.95);
  }

  .tb-players-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .tb-btn-clear {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0;
  }

  .tb-btn-clear:hover {
    color: #dc2626;
  }

  .tb-player-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
  }

  #tb-app .tb-player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
  }

  #tb-app .tb-player-item:hover {
    border-color: var(--accent);
  }

  #tb-app .tb-player-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-base);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    padding-right: 1rem;
  }

  #tb-app .tb-player-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
  }

  #tb-app .tb-player-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
  }

  #tb-app .tb-player-remove:hover {
    color: #ef4444;
  }

  #tb-app .tb-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  #tb-app .tb-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
  }

  #tb-app .tb-toggle-label:hover {
    background: var(--bg-page);
  }

  #tb-app .tb-toggle {
    position: relative;
    width: 2.5rem;
    height: 1.5rem;
    flex-shrink: 0;
  }

  #tb-app .tb-toggle-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
  }

  #tb-app .tb-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 9999px;
    transition: background 0.2s;
  }

  #tb-app .tb-toggle-input:checked + .tb-toggle-track {
    background: var(--accent);
  }

  #tb-app .tb-toggle-thumb {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    width: 1rem;
    height: 1rem;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
  }

  #tb-app .tb-toggle-input:checked ~ .tb-toggle-thumb {
    transform: translateX(1rem);
  }

  #tb-app .tb-toggle-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-base);
  }

  .tb-btn-generate {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.75rem;
    padding: 1rem;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: opacity 0.2s;
  }

  .tb-btn-generate:hover:not(.tb-btn-disabled) {
    opacity: 0.9;
    transform: scale(1.02);
  }

  .tb-btn-generate:active:not(.tb-btn-disabled) {
    transform: scale(0.98);
  }

  #tb-app .tb-btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .tb-setup-side {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .tb-how-card {
    background: #1e1b4b;
    color: white;
    border-radius: 1.5rem;
    padding: 1.5rem;
  }

  .tb-how-title {
    font-weight: 700;
    font-size: 1.125rem;
    margin: 0 0 0.5rem;
  }

  .tb-how-text {
    color: rgba(199, 210, 254, 0.9);
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0;
  }

  .tb-history-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 1.5rem;
    flex: 1;
  }

  .tb-history-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .tb-history-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
  }

  #tb-app .tb-history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 2rem;
    font-style: italic;
  }

  #tb-app .tb-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
  }

  #tb-app .tb-history-item:hover {
    border-color: var(--accent);
    background: rgba(244, 63, 94, 0.03);
  }

  #tb-app .tb-history-load {
    background: none;
    border: none;
    text-align: left;
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden;
    padding: 0;
  }

  #tb-app .tb-history-name {
    font-weight: 700;
    color: var(--text-base);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
  }

  #tb-app .tb-history-date {
    font-size: 0.625rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
  }

  #tb-app .tb-history-badge-winner {
    color: #16a34a;
    font-weight: 700;
    font-size: 0.625rem;
    background: rgba(22, 163, 74, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }

  #tb-app .tb-history-badge-active {
    color: #f97316;
  }

  #tb-app .tb-history-delete {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    margin-left: 0.5rem;
  }

  #tb-app .tb-history-delete:hover {
    background: rgba(239, 68, 68, 0.2);
  }

  .tb-bracket-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
  }

  .tb-mobile-bracket {
    display: block;
  }

  @media (min-width: 768px) {
    .tb-mobile-bracket {
      display: none;
    }
  }

  .tb-desktop-bracket {
    display: none;
    flex: 1;
    min-height: 600px;
    max-height: 80vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    position: relative;
    overflow: auto;
  }

  @media (min-width: 768px) {
    .tb-desktop-bracket {
      display: block;
    }
  }

  .tb-cursor-grab {
    cursor: grab;
  }

  #tb-app .tb-cursor-grabbing {
    cursor: grabbing;
  }

  .tb-drag-hint {
    position: absolute;
    bottom: 1rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  #tb-app .tb-tabs {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.25rem;
    position: sticky;
    top: 0;
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(4px);
    z-index: 20;
    margin-bottom: 1rem;
  }

  #tb-app .tb-round-tab {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    cursor: pointer;
  }

  #tb-app .tb-round-tab-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }

  #tb-app .tb-rounds {
    position: relative;
    min-height: 500px;
    margin-top: 1rem;
  }

  #tb-app .tb-round-content {
    width: 100%;
    transition: all 0.3s;
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(2rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 2rem;
  }

  #tb-app .tb-round-active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
    position: relative;
  }

  #tb-app .tb-round-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
  }

  #tb-app .tb-match-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #tb-app .tb-match-card-bye {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    position: relative;
  }

  #tb-app .tb-match-card::before,
  #tb-app .tb-match-card-bye::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
  }

  #tb-app .tb-match-card::before {
    background: var(--border-color);
  }

  #tb-app .tb-match-card-bye::before {
    background: var(--accent);
  }

  #tb-app .tb-match-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  #tb-app .tb-match-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0 0.75rem;
  }

  #tb-app .tb-match-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    color: var(--text-base);
  }

  #tb-app .tb-match-btn:hover:not([disabled]) {
    background: var(--bg-page);
  }

  #tb-app .tb-match-btn[disabled] {
    cursor: default;
  }

  #tb-app .tb-match-btn-winner {
    background: rgba(99, 102, 241, 0.1);
    font-weight: 700;
    color: #4338ca;
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.2);
  }

  #tb-app .tb-player-label {
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #tb-app .tb-player-empty-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
  }

  #tb-app .tb-winner-icon {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    background: #4338ca;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.2,2H19.5H18C17.1,2 16,3 16,4H8C8,3 6.9,2 6,2H4.5H3.8C2.8,2 2,2.8 2,3.8V4.5C2,8.9 5.6,12.5 10,12.5V15H7V17H17V15H14V12.5C18.4,12.5 22,8.9 22,4.5V3.8C22,2.8 21.2,2 20.2,2Z'/%3E%3C/svg%3E");
    mask-size: contain;
  }

  #tb-app .tb-score-input {
    width: 3rem;
    height: 2.25rem;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    background: var(--bg-page);
    color: var(--text-base);
    flex-shrink: 0;
  }

  #tb-app .tb-score-input:focus {
    border-color: var(--accent);
    outline: none;
  }

  #tb-app .tb-bye-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
  }

  #tb-app .tb-bye-name {
    font-weight: 700;
    color: var(--text-base);
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #tb-app .tb-bracket-wrapper {
    position: relative;
  }

  #tb-app .tb-round-header {
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 30;
  }

  #tb-app .tb-desktop-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #tb-app .tb-desktop-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }

  #tb-app .tb-desktop-card-bye {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    position: relative;
    width: 100%;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.75rem 1rem;
    box-sizing: border-box;
  }

  #tb-app .tb-connector-dot-left {
    position: absolute;
    top: 50%;
    left: -6px;
    width: 12px;
    height: 12px;
    background: var(--border-color);
    border-radius: 50%;
    transform: translateY(-50%);
    border: 2px solid var(--bg-surface);
    box-sizing: content-box;
  }

  #tb-app .tb-connector-dot-right {
    position: absolute;
    top: 50%;
    right: -6px;
    width: 12px;
    height: 12px;
    background: rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    transform: translateY(-50%);
    border: 2px solid var(--bg-surface);
    box-sizing: content-box;
  }

  #tb-app .tb-connectors {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
  }

  #tb-app .tb-trophy-icon {
    width: 1rem;
    height: 1rem;
    display: inline-block;
    color: #4338ca;
    margin-left: 0.25rem;
  }

  #tb-app .tb-icon-xs {
    width: 0.75rem;
    height: 0.75rem;
    display: inline-block;
  }

  #tb-app .tb-icon-sm {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
  }

  #tb-app .tb-icon-md {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
  }

  #tb-app .tb-icon-lg {
    width: 1.5rem;
    height: 1.5rem;
    display: inline-block;
  }

  #tb-app .tb-highlight {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.4);
  }

  #tb-app .tb-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    z-index: 9999;
  }

  #tb-app .tb-toast-victory {
    background: #4338ca;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    font-weight: 700;
    padding: 1rem 2rem;
  }

  #tb-app .tb-toast-success {
    background: #059669;
  }

  #tb-app .tb-toast-error {
    background: #dc2626;
  }

  #tb-app .tb-toast-info {
    background: var(--accent);
  }