/* Application shell overrides extracted from index.html. Keep loaded after the
   legacy inline sheet so the existing cascade remains unchanged. */
.app-sidebar:not([hidden]),
.app-topbar:not([hidden]) {
  display: flex;
}

.app-sidebar:not([hidden]),
.app-topbar:not([hidden]) {
  visibility: visible;
}

.app-sidebar {
  width: 232px;
  padding: 24px 14px 18px;
  background: #fff;
  border-right-color: #dfe7e1;
}

.sidebar-brand {
  padding-bottom: 23px;
  border-bottom-color: #dfe7e1;
}

.brand-symbol {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #176b4d;
  color: #fff;
}

.nav-links {
  gap: 3px;
  margin-top: 21px;
}

.nav-link {
  border-radius: 8px;
  color: #66736b;
  font-size: .84rem;
}

.nav-link:hover {
  background: #f3f7f4;
  color: #176b4d;
}

.nav-link.active {
  background: #e5f1e9;
  color: #0f553c;
}

.app-topbar {
  min-height: 64px;
  height: 64px;
  margin-left: 232px;
  padding: 0 32px;
  background: #fff;
  border-bottom: 1px solid #e5eae7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: none;
}

.topbar-title p#topbar-breadcrumb {
  margin: 0;
  color: #096839;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: normal;
}

.topbar-title h1 {
  font-size: 1.22rem;
  font-weight: 650;
  letter-spacing: -.01em;
}

.page {
  width: calc(100% - 232px);
  max-width: 1360px;
  margin-left: 232px;
  padding: 34px 38px 52px;
}

.dashboard-page {
  padding-top: 30px;
}

.page.active {
  display: block;
}

.page:not(.active):not(#auth-screen) {
  display: none;
}

.nav-link {
  min-height: 40px;
  padding: 10px 12px;
  gap: 0;
}

.sidebar-footer {
  display: none;
}

@media (max-width: 900px) {
  .app-sidebar {
    width: 250px;
  }

  .app-topbar {
    margin-left: 0;
    padding: 12px 22px;
  }

  .page {
    width: 100%;
    margin-left: 0;
    padding: 28px 24px 44px;
  }

  /* The late replay refinement in index.html restores desktop shell sizing.
     Reapply the mobile shell geometry after the inline sheet. */
  #replay-view {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 22px 15px 36px;
  }
}

/* ==================== EXTRACTED: App Shell & Navigation ==================== */
/* Phase 2: application shell and dashboard. Shared tokens live in style.css. */
    body {
      background: var(--color-page);
    }


    .app-sidebar {
      position: fixed;
      inset: 0 auto 0 0;
      z-index: 50;
      width: 248px;
      padding: 28px 16px 20px;
      background: #fff;
      border-right: 1px solid var(--border-light);
      display: flex;
      flex-direction: column;
    }

    .sidebar-brand {
      display: flex;
      gap: 11px;
      align-items: center;
      padding: 0 10px 29px;
      border-bottom: 1px solid var(--border-light);
      color: var(--text-primary);
    }

    .brand-symbol {
      width: 38px;
      height: 38px;
      border-radius: 11px;
      display: grid;
      place-items: center;
      background: #e4f3e9;
      color: var(--accent-blue);
    }

    .brand-symbol svg {
      width: 21px;
      height: 21px;
    }

    .sidebar-brand strong {
      display: block;
      font-size: .94rem;
      letter-spacing: -.01em;
    }

    .sidebar-brand small {
      display: block;
      margin-top: 3px;
      color: var(--text-faint);
      font-size: .57rem;
      font-weight: 800;
      letter-spacing: .13em;
    }

    .nav-links {
      display: grid;
      gap: 5px;
      margin: 24px 0 0;
    }

    .nav-link {
      width: 100%;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 11px 12px;
      border: 0;
      border-radius: 9px;
      background: transparent;
      color: var(--text-secondary);
      font-size: .88rem;
      font-weight: 650;
      text-align: left;
    }

    .nav-link:hover,
    .nav-link.active {
      background: #eaf6ed;
      color: #126b34;
    }

    .sidebar-footer {
      margin-top: auto;
      padding: 15px 10px 0;
      border-top: 1px solid var(--border-light);
      color: var(--text-faint);
      font-size: .73rem;
    }

    .app-topbar {
      position: sticky;
      top: 0;
      z-index: 30;
      min-height: 80px;
      margin-left: 248px;
      padding: 14px 40px;
      background: rgba(255, 255, 255, .92);
      border-bottom: 1px solid var(--border-light);
      backdrop-filter: blur(10px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
    }

    .topbar-title {
      min-width: 0;
    }

    .topbar-title p,
    .section-kicker {
      margin: 0 0 4px;
      color: #16803c;
      font-size: .83rem;
      font-weight: 800;
      letter-spacing: .13em;
    }

    .topbar-title h1 {
      font-size: 1.15rem;
      letter-spacing: -.02em;
    }

    .topbar-user {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .user-avatar {
      width: 35px;
      height: 35px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #e4f3e9;
      color: #126b34;
      font-size: .78rem;
      font-weight: 800;
    }

    .user-identity {
      display: grid;
      gap: 2px;
      min-width: 86px;
    }

    .user-identity strong {
      font-size: .82rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .user-identity small {
      color: var(--text-faint);
      font-size: .67rem;
    }

    .logout-button {
      width: auto;
      padding: 8px 12px;
      font-size: .76rem;
    }

    .mobile-menu-toggle,
    .sidebar-backdrop {
      display: none;
    }

    .page {
      width: calc(100% - 248px);
      max-width: 1320px;
      margin-left: 248px;
      margin-right: 0;
      padding: 38px 40px;
    }

    #replay-view {
      width: calc(100% - 248px);
      max-width: 1320px;
      margin-left: 248px;
      margin-right: 0;
    }

    .dashboard-page {
      padding-top: 36px;
    }

    .dashboard-welcome {
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      gap: 28px;
      padding: 30px 32px;
      border: 1px solid #dbe9df;
      border-radius: 18px;
      background: #fff;
      box-shadow: 0 8px 24px rgba(30, 43, 34, .04);
    }

    .dashboard-welcome h2 {
      max-width: 640px;
      font-size: clamp(1.7rem, 3vw, 2.45rem);
      letter-spacing: -.045em;
      line-height: 1.05;
    }

    .dashboard-welcome h2 span {
      color: #16803c;
    }

    .welcome-copy {
      max-width: 610px;
      margin-top: 12px;
      color: var(--text-secondary);
      line-height: 1.6;
    }

    .dashboard-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 9px;
      flex-shrink: 0;
    }

    .dashboard-action {
      width: auto;
      min-height: 42px;
      padding: 10px 14px;
      font-size: .82rem;
    }

    .primary-btn.dashboard-action {
      background: #16803c;
      box-shadow: none;
    }

    .primary-btn.dashboard-action:hover {
      background: #11652f;
      box-shadow: none;
    }

    .summary-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px;
      margin-top: 18px;
    }

    .summary-card {
      min-width: 0;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      align-items: flex-start;
      gap: 14px;
      padding: 21px;
      background: #fff;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      box-shadow: 0 5px 16px rgba(30, 43, 34, .035);
    }

    .summary-card p {
      color: var(--text-secondary);
      font-size: .77rem;
      font-weight: 650;
    }

    .summary-card strong {
      display: block;
      margin: 5px 0 3px;
      font-size: 1.55rem;
      letter-spacing: -.04em;
    }

    .summary-card small {
      color: var(--text-faint);
      font-size: .76rem;
    }

    /* Shared polish: role-aware navigation, editor, replay identities. */
    body {
      font-family: 'Be Vietnam Pro', system-ui, sans-serif;
    }

    .summary-grid {
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .participant-bot-id {
      color: var(--text-faint);
      font-size: .8rem;
      overflow-wrap: anywhere;
    }

    .source-editor-shell {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      min-width: 0;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }

    .source-line-numbers {
      display: none;
      box-sizing: border-box;
      margin: 0;
      padding: 14px 10px;
      overflow: hidden;
      border-right: 1px solid var(--border-light);
      background: #f5f7f5;
      color: #849087;
      font: .82rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
      text-align: right;
      user-select: none;
    }

    .source-editor-shell .source-editor {
      width: 100%;
      border: 0;
      border-radius: 0;
      resize: vertical;
    }

    .source-editor-shell:focus-within {
      border-color: var(--color-brand);
      box-shadow: 0 0 0 3px rgba(22, 128, 60, .12);
    }

    .bot-revision-technical {
      color: var(--text-faint);
      font-size: .72rem;
    }

    .bot-revision-technical summary {
      width: max-content;
      cursor: pointer;
      color: var(--text-secondary);
      font-weight: 600;
    }

    .bot-revision-technical[open] summary {
      margin-bottom: 6px;
    }

    .tournament-lifecycle {
      display: flex;
      gap: 8px;
      margin: 22px 0 14px;
      padding: 0 0 7px;
      overflow-x: auto;
      list-style: none;
      scrollbar-width: thin;
    }

    .tournament-lifecycle li {
      flex: 0 0 auto;
      padding: 7px 10px;
      border-radius: 999px;
      background: #fff;
      color: var(--text-faint);
      font-size: .72rem;
      font-weight: 600;
    }

    .tournament-lifecycle li.is-complete {
      border-color: #b8d8c3;
      color: var(--color-success);
    }

    .tournament-lifecycle li.is-current {
      border-color: var(--color-brand);
      background: #edf7f0;
      color: var(--color-brand);
    }

    .replay-player-identity {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 2px;
      min-width: 0;
      flex: 1;
    }

    .replay-player-b-label {
      text-align: right;
      grid-template-columns: auto minmax(0, 1fr);
    }

    .replay-player-name {
      color: var(--text-primary);
      font-size: .88rem;
      font-weight: 700;
      letter-spacing: 0;
      overflow-wrap: anywhere;
    }

    .replay-player-bot,
    .replay-player-pieces {
      color: var(--text-faint);
      font-size: .68rem;
      font-weight: 500;
      letter-spacing: 0;
    }

    .replay-player-score {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      align-self: center;
      min-width: 42px;
      height: 42px;
      margin-left: 8px;
      padding: 0 9px;
      border: 1px solid #cce4d4;
      border-radius: 12px;
      background: #edf8f1;
      color: #176b50;
      font-size: 1.35rem;
      font-weight: 850;
      line-height: 1;
      font-variant-numeric: tabular-nums;
      grid-column: 2;
      grid-row: 1 / span 3;
    }

    .replay-player-b-label .replay-player-score {
      grid-column: 1;
      order: -1;
      margin-right: 8px;
      margin-left: 0;
    }

    .replay-player-identity.is-leading .replay-player-score {
      border-color: #74bd91;
      background: #dff3e6;
      box-shadow: 0 0 0 4px rgba(51, 157, 98, .1);
    }

    .replay-versus {
      align-self: center;
      color: var(--text-faint);
      font-size: .72rem;
      font-weight: 600;
    }

    .replay-piece.replay-player-a {
      background: var(--color-player-a);
    }

    .replay-piece.replay-player-b {
      background: var(--color-player-b);
    }

    .bottom-nav {
      display: none;
    }

    @media (max-width: 900px) {
      body[data-role="competitor"] .bottom-nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 1200;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 7px max(10px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
        border-top: 1px solid var(--border-light);
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 -8px 24px rgba(23, 35, 29, .07);
      }

      body[data-role="competitor"] .bottom-nav button {
        min-height: 44px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--text-secondary);
        font: 600 .72rem 'Be Vietnam Pro', system-ui, sans-serif;
      }

      body[data-role="competitor"] .bottom-nav button.active {
        background: #edf7f0;
        color: var(--color-brand);
      }

      body[data-role="competitor"] .page {
        padding-bottom: 88px;
      }

      body[data-role="competitor"] #mobile-menu-toggle {
        display: none;
      }
    }

    /* Shared back navigation: keep workspace, tournament and replay exits
       visually consistent while leaving modal close buttons untouched. */
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back,
    #bot-workspace-back,
    #back-to-tournaments,
    #replay-view .replay-back-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 34px;
      width: auto;
      margin: 0;
      padding: 7px 11px;
      border: 1px solid #d7e4da;
      border-radius: 9px;
      background: #fff;
      color: #526159;
      font: inherit;
      font-size: .76rem;
      font-weight: 700;
      line-height: 1.2;
      text-decoration: none;
      cursor: pointer;
      transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
    }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back:hover,
    #bot-workspace-back:hover,
    #back-to-tournaments:hover,
    #replay-view .replay-back-link:hover {
      border-color: #9fc7ab;
      background: #f1faf4;
      color: #176b50;
      box-shadow: 0 3px 10px rgba(23, 107, 80, .08);
    }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back:focus-visible,
    #bot-workspace-back:focus-visible,
    #back-to-tournaments:focus-visible,
    #replay-view .replay-back-link:focus-visible {
      outline: 3px solid rgba(22, 128, 60, .18);
      outline-offset: 2px;
    }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back .workspace-inline-icon,
    #bot-workspace-back .workspace-inline-icon,
    #back-to-tournaments .td-icon,
    #replay-view .replay-back-link .ui-icon {
      width: 25px;
      height: 25px;
      flex: 0 0 17px;
    }
    #back-to-tournaments .breadcrumb-separator,
    #back-to-tournaments #td-breadcrumb-name {
      display: none;
    }

    /* Keep the source workspace breadcrumb in normal flow so the back button
       can never cover the workspace heading. */
    .bot-workspace-page .bot-source-workspace {
      padding: 16px;
    }
    .bot-workspace-page .bot-workspace-breadcrumb {
      position: static;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
      margin: 0 0 18px;
    }
    .bot-workspace-page .bot-workspace-breadcrumb > span:not(.source-workspace-status) {
      display: inline;
      color: #a0ada5;
      font-size: .78rem;
    }
    .bot-workspace-page .bot-workspace-breadcrumb .source-workspace-status {
      margin-left: auto;
    }
    #replay-view .replay-series-card {
      margin-top: 14px;
      padding: 14px 18px 12px;
      border: 1px solid #dce6df;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 7px 20px rgba(23, 35, 29, .03);
    }
    #replay-view .replay-series-card .replay-players {
      display: flex;
      width: min(100%, 560px);
      align-items: center;
      justify-content: center;
      gap: 12px;
      margin: 0 auto;
      padding: 0;
      border: 0;
    }
    #replay-view .replay-series-card .replay-player-identity {
      display: grid;
      flex: 1 1 0;
      min-width: 0;
      padding: 6px 10px;
      border: 0;
      background: transparent;
      box-shadow: none;
    }
    #replay-view .replay-series-card .replay-player-a-label {
      border: 2px solid #dce6df;
      border-left-width: 4px;
      border-radius: 10px;
      background: #fbfdfb;
    }
    #replay-view .replay-series-card .replay-player-b-label {
      border: 2px solid #dce6df;
      border-right-width: 4px;
      border-radius: 10px;
      background: #fbfdfb;
    }
    #replay-view .replay-series-card .replay-player-identity.is-current-side-a {
      border-color: var(--color-player-a);
      background: rgba(29, 78, 216, .045);
    }
    #replay-view .replay-series-card .replay-player-identity.is-current-side-b {
      border-color: var(--color-player-b);
      background: rgba(194, 65, 12, .045);
    }
    #replay-view .replay-series-card .replay-player-name {
      font-size: .9rem;
      font-weight: 750;
    }
    #replay-view .replay-series-card .replay-player-score {
      min-width: 38px;
      height: 38px;
      border: 0;
      border-radius: 9px;
      background: #f2f6f3;
      box-shadow: none;
      font-size: 1.18rem;
    }
    #replay-view .replay-series-card .replay-versus {
      color: #25342c;
      font-size: 1rem;
      font-weight: 800;
    }
    #replay-series-slot:empty { display: none; }
    #replay-series-slot #replay-series-controls {
      justify-content: center;
      width: fit-content;
      max-width: 100%;
      margin: 10px auto 0;
      padding: 0;
      border: 0;
      background: transparent;
    }
    #replay-series-slot #replay-series-controls::before { display: none; }
    #replay-series-slot #replay-series-controls .secondary-btn {
      min-width: 62px;
      padding: 8px 12px;
      text-align: center;
    }
    #replay-view .replay-layout {
      grid-template-columns: minmax(0, 1.55fr) minmax(280px, .65fr);
      gap: 16px;
      margin-top: 14px;
      align-items: stretch;
    }
    #replay-view .replay-board-panel,
    #replay-view .replay-timeline-panel {
      padding: 16px;
      border: 1px solid #dce6df;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 7px 20px rgba(23, 35, 29, .03);
    }
    #replay-view .replay-panel-heading {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }
    #replay-view .replay-panel-heading h3 {
      margin: 0;
      color: #1b2921;
      font-size: .95rem;
      letter-spacing: -.01em;
    }
    #replay-view .replay-panel-count {
      display: inline-flex;
      min-height: 24px;
      align-items: center;
      padding: 4px 9px;
      border-radius: 999px;
      background: #f0f3f1;
      color: #3f4d45;
      font-size: .68rem;
      font-weight: 700;
      white-space: nowrap;
    }
    #replay-view .replay-board-wrap {
      width: min(100%, 520px);
      max-width: 520px;
      margin: 0 auto 10px;
    }
    #replay-view .replay-current-move {
      min-height: 0;
      margin: 8px 0 4px;
      padding: 7px 10px;
      border-left: 3px solid #b8c8bc;
      border-radius: 5px;
      background: #f7faf8;
      color: #68766e;
      font-size: .72rem;
    }
    #replay-view .replay-current-move-a {
      border-left-color: #7eaef0;
      background: #f1f6ff;
      color: #245fae;
    }
    #replay-view .replay-current-move-b {
      border-left-color: #ed9a75;
      background: #fff5ef;
      color: #a7431c;
    }
    #replay-view .replay-scrubber-label { margin-top: 8px; }
    #replay-view .replay-controls {
      position: relative;
      justify-content: center;
      padding-top: 12px;
    }
    #replay-view .replay-play {
      flex-basis: 40px;
      min-width: 40px;
    }
    #replay-view .replay-play .replay-control-label { display: none; }
    #replay-view .replay-speed-label {
      position: absolute;
      right: 0;
      margin-left: 0;
    }
    #replay-view .replay-timeline-panel h3::after { display: none; content: none; }
    #replay-view:not(.live-match-view) .replay-selected-move { display: none; }
    #replay-view .replay-timeline {
      max-height: 430px;
      margin-top: 0;
      gap: 9px;
    }
    #replay-view .replay-move {
      display: grid;
      grid-template-columns: auto auto minmax(0, 1fr);
      align-items: center;
      gap: 8px;
      min-height: 48px;
      padding: 12px;
      border: 1px solid #dfe6e1;
      border-radius: 8px;
      background: #fff;
    }
    #replay-view .replay-move::before { display: none; }
    #replay-view .replay-move-number {
      color: #7d8982;
      font-size: .68rem;
      font-variant-numeric: tabular-nums;
    }
    #replay-view .replay-move-player {
      max-width: 132px;
      overflow: hidden;
      padding: 4px 8px;
      border-radius: 999px;
      font-size: .68rem;
      font-weight: 750;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #replay-view .replay-move-player-a {
      background: #e5f0ff;
      color: #2563c7;
    }
    #replay-view .replay-move-player-b {
      background: #ffebe2;
      color: #c34b1b;
    }
    #replay-view .replay-move-path {
      min-width: 0;
      overflow: hidden;
      color: #27362e;
      font-size: .76rem;
      font-variant-numeric: tabular-nums;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #replay-view .replay-move-side-a { border-left: 3px solid #7eaef0; }
    #replay-view .replay-move-side-b { border-left: 3px solid #ed9a75; }
    #replay-view .replay-details {
      grid-template-columns: 1fr;
      gap: 2px;
      margin-top: 16px;
      padding-top: 14px;
      border-top: 1px solid #e4ebe6;
    }
    #replay-view .replay-detail {
      display: grid;
      grid-template-columns: 88px minmax(0, 1fr);
      align-items: center;
      gap: 12px;
      padding: 8px 0;
      border: 0;
      background: transparent;
    }
    #replay-view .replay-detail small {
      margin: 0;
      text-transform: none;
      letter-spacing: 0;
    }
    @media (max-width: 900px) {
      #replay-view .replay-layout { grid-template-columns: 1fr; }
      #replay-view .replay-board-wrap { width: min(100%, 580px); max-width: 580px; }
    }
    @media (max-width: 600px) {
      #replay-view .replay-heading-row,
      #replay-view .replay-header-subline { align-items: flex-start; }
      #replay-view .replay-series-card .replay-players { gap: 4px; }
      #replay-view .replay-series-card .replay-player-identity { padding: 5px; }
      #replay-view .replay-series-card .replay-player-bot,
      #replay-view .replay-series-card .replay-player-pieces { display: none; }
      #replay-view .replay-speed-label {
        position: static;
        width: 100%;
        margin: 4px 0 0;
      }
    }


/* CSS extracted from the application shell. */

    /* Additions to existing style.css for Dashboard/Tournaments */
    .nav-bar {
      display: flex;
      gap: 20px;
      padding: 15px 24px;
      background: var(--bg-card);
      border-bottom: 1px solid var(--border-light);
      align-items: center;
      box-shadow: var(--shadow-sm);
    }

    .nav-brand {
      font-weight: bold;
      font-size: 1.2rem;
      color: var(--accent-blue);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .nav-links {
      display: flex;
      gap: 15px;
      margin-left: 20px;
    }

    .nav-link {
      cursor: pointer;
      color: var(--text-secondary);
      text-decoration: none;
      padding: 6px 12px;
      border: 0;
      background: transparent;
      font: inherit;
      border-radius: 8px;
    }

    .nav-link:hover,
    .nav-link.active {
      background: var(--bg-soft);
      color: var(--accent-blue);
    }

    .ui-message,
    .table-message {
      color: var(--text-secondary);
      text-align: center;
      padding: 22px;
    }

    .ui-message p {
      margin-bottom: 12px;
    }

    .table-message .secondary-btn {
      width: auto;
      margin-left: 12px;
      padding: 6px 10px;
    }

    .page {
      display: none;
      padding: 24px;
      max-width: 1200px;
      margin: 0 auto;
      width: 100%;
    }

    .page.active {
      display: block;
      animation: fadeIn 0.2s ease;
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
      }

      to {
        opacity: 1;
      }
    }

    .card-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 20px;
      margin-top: 20px;
    }

    .card {
      background: var(--bg-card);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-md);
      padding: 20px;
      box-shadow: var(--shadow-sm);
    }

    .data-table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 15px;
      background: var(--bg-card);
      border-radius: var(--radius-md);
      overflow: hidden;
      box-shadow: var(--shadow-sm);
    }

    .data-table th,
    .data-table td {
      padding: 12px 16px;
      text-align: left;
      border-bottom: 1px solid var(--border-light);
    }

    .data-table th {
      background: var(--bg-soft);
      color: var(--text-secondary);
      font-weight: 600;
      font-size: 0.85rem;
    }

    .data-table tr:last-child td {
      border-bottom: none;
    }

    .page-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
    }

    .status-badge {
      padding: 4px 8px;
      border-radius: 12px;
      font-size: 0.75rem;
      font-weight: bold;
    }

    .status-draft {
      background: #e2e8f0;
      color: #475569;
    }

    .status-registration_open {
      background: #dbeafe;
      color: #1e40af;
    }

    .status-registration_closed {
      background: #fff5df;
      color: #87611b;
    }

    .status-scheduled,
    .status-queued {
      background: #f1f5f2;
      color: #607066;
    }

    .status-in_progress,
    .status-active {
      background: #e4f1eb;
      color: #176b50;
    }

    .status-failed,
    .status-error {
      background: #fff0ef;
      color: #a0463e;
    }

    .status-running {
      background: #fef08a;
      color: #854d0e;
    }

    .status-completed {
      background: #bbf7d0;
      color: #166534;
    }

    .status-cancelled {
      background: #fecaca;
      color: #991b1b;
    }

    /* Phase 2: application shell and dashboard. Shared tokens live in style.css. */
    body {
      background: var(--color-page);
    }

    .app-sidebar {
      position: fixed;
      inset: 0 auto 0 0;
      z-index: 50;
      width: 248px;
      padding: 28px 16px 20px;
      background: #fff;
      border-right: 1px solid var(--border-light);
      display: flex;
      flex-direction: column;
    }

    .sidebar-brand {
      display: flex;
      gap: 11px;
      align-items: center;
      padding: 0 10px 29px;
      border-bottom: 1px solid var(--border-light);
      color: var(--text-primary);
    }

    .brand-symbol {
      width: 38px;
      height: 38px;
      border-radius: 11px;
      display: grid;
      place-items: center;
      background: #e4f3e9;
      color: var(--accent-blue);
    }

    .brand-symbol svg {
      width: 21px;
      height: 21px;
    }

    .sidebar-brand strong {
      display: block;
      font-size: .94rem;
      letter-spacing: -.01em;
    }

    .sidebar-brand small {
      display: block;
      margin-top: 3px;
      color: var(--text-faint);
      font-size: .57rem;
      font-weight: 800;
      letter-spacing: .13em;
    }

    .nav-links {
      display: grid;
      gap: 5px;
      margin: 24px 0 0;
    }

    .nav-link {
      width: 100%;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 11px 12px;
      border: 0;
      border-radius: 9px;
      background: transparent;
      color: var(--text-secondary);
      font-size: .88rem;
      font-weight: 650;
      text-align: left;
    }

    .nav-link:hover,
    .nav-link.active {
      background: #eaf6ed;
      color: #126b34;
    }

    .sidebar-footer {
      margin-top: auto;
      padding: 15px 10px 0;
      border-top: 1px solid var(--border-light);
      color: var(--text-faint);
      font-size: .73rem;
    }

    .app-topbar {
      position: sticky;
      top: 0;
      z-index: 30;
      min-height: 80px;
      margin-left: 248px;
      padding: 14px 40px;
      background: rgba(255, 255, 255, .92);
      border-bottom: 1px solid var(--border-light);
      backdrop-filter: blur(10px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
    }

    .topbar-title {
      min-width: 0;
    }

    .topbar-title p,
    .section-kicker {
      margin: 0 0 4px;
      color: #16803c;
      font-size: .83rem;
      font-weight: 800;
      letter-spacing: .13em;
    }

    .topbar-title h1 {
      font-size: 1.15rem;
      letter-spacing: -.02em;
    }

    .topbar-user {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .user-avatar {
      width: 35px;
      height: 35px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #e4f3e9;
      color: #126b34;
      font-size: .78rem;
      font-weight: 800;
    }

    .user-identity {
      display: grid;
      gap: 2px;
      min-width: 86px;
    }

    .user-identity strong {
      font-size: .82rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .user-identity small {
      color: var(--text-faint);
      font-size: .67rem;
    }

    .logout-button {
      width: auto;
      padding: 8px 12px;
      font-size: .76rem;
    }

    .mobile-menu-toggle,
    .sidebar-backdrop {
      display: none;
    }

    .page {
      width: calc(100% - 248px);
      max-width: 1320px;
      margin-left: 248px;
      margin-right: 0;
      padding: 38px 40px;
    }

    #replay-view {
      width: calc(100% - 248px);
      max-width: 1320px;
      margin-left: 248px;
      margin-right: 0;
    }

    .dashboard-page {
      padding-top: 36px;
    }

    .dashboard-welcome {
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      gap: 28px;
      padding: 30px 32px;
      border: 1px solid #dbe9df;
      border-radius: 18px;
      background: #fff;
      box-shadow: 0 8px 24px rgba(30, 43, 34, .04);
    }

    .dashboard-welcome h2 {
      max-width: 640px;
      font-size: clamp(1.7rem, 3vw, 2.45rem);
      letter-spacing: -.045em;
      line-height: 1.05;
    }

    .dashboard-welcome h2 span {
      color: #16803c;
    }

    .welcome-copy {
      max-width: 610px;
      margin-top: 12px;
      color: var(--text-secondary);
      line-height: 1.6;
    }

    .dashboard-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 9px;
      flex-shrink: 0;
    }

    .dashboard-action {
      width: auto;
      min-height: 42px;
      padding: 10px 14px;
      font-size: .82rem;
    }

    .primary-btn.dashboard-action {
      background: #16803c;
      box-shadow: none;
    }

    .primary-btn.dashboard-action:hover {
      background: #11652f;
      box-shadow: none;
    }

    .summary-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px;
      margin-top: 18px;
    }

    .summary-card {
      min-width: 0;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      align-items: flex-start;
      gap: 14px;
      padding: 21px;
      background: #fff;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      box-shadow: 0 5px 16px rgba(30, 43, 34, .035);
    }

    .summary-card p {
      color: var(--text-secondary);
      font-size: .77rem;
      font-weight: 650;
    }

    .summary-card strong {
      display: block;
      margin: 5px 0 3px;
      font-size: 1.55rem;
      letter-spacing: -.04em;
    }

    .summary-card small {
      color: var(--text-faint);
      font-size: .7rem;
    }

    .summary-icon {
      width: 22px;
      height: 22px;
      flex: 0 0 auto;
      color: #7aa88b;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .stat-card__header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .dashboard-list-toolbar {
      display: flex;
      align-items: center;
      gap: 10px;
      margin: -2px 0 12px;
    }

    .dashboard-list-toolbar .bot-search {
      flex: 1;
      max-width: 300px;
    }

    .dashboard-filter {
      position: relative;
      display: inline-flex;
      align-items: center;
    }

    .dashboard-filter > .ui-icon {
      position: absolute;
      left: 11px;
      width: 16px;
      height: 16px;
      color: var(--text-faint);
      pointer-events: none;
    }

    .dashboard-filter select {
      min-height: 42px;
      padding: 9px 12px 9px 34px;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      background: #fff;
      color: var(--text-primary);
    }

    .dashboard-section {
      margin-top: 34px;
    }

    .section-header {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 13px;
    }

    .section-header h3 {
      font-size: 1.1rem;
      letter-spacing: -.02em;
    }

    .queue-status {
      padding: 7px 10px;
      border: 1px solid var(--border-light);
      border-radius: 999px;
      background: #fff;
      color: var(--text-secondary);
      font-size: .72rem;
      white-space: nowrap;
    }

    .recent-tournaments-card {
      overflow-x: auto;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
      box-shadow: 0 5px 16px rgba(30, 43, 34, .035);
    }

    .dashboard-page .data-table {
      margin: 0;
      border-radius: 0;
      box-shadow: none;
    }

    .dashboard-page .data-table th {
      background: #f8faf8;
    }

    .dashboard-page .data-table td {
      vertical-align: middle;
    }

    .status-badge {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      padding: 4px 9px;
      font-size: .66rem;
      letter-spacing: .02em;
    }

    .status-registration_open {
      background: #e4f3e9;
      color: #126b34;
    }

    .status-running {
      background: #fff4dd;
      color: #8a5b12;
    }

    .status-completed {
      background: #edf0ef;
      color: #55625a;
    }

    .visually-hidden {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    @media (max-width: 900px) {
      .app-sidebar {
        width: 264px;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 12px 0 30px rgba(30, 43, 34, .1);
      }

      .app-sidebar.open {
        transform: translateX(0);
      }

      .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: block;
        border: 0;
        background: rgba(20, 32, 24, .28);
      }

      .app-topbar {
        margin-left: 0;
        padding: 13px 24px;
      }

      .mobile-menu-toggle {
        width: 40px;
        height: 40px;
        display: grid;
        align-content: center;
        gap: 4px;
        border: 1px solid var(--border-light);
        border-radius: 9px;
        background: #fff;
      }

      .mobile-menu-toggle span {
        width: 17px;
        height: 2px;
        margin: 0 auto;
        background: var(--text-primary);
      }

      .topbar-title {
        margin-right: auto;
      }

      .page,
      #replay-view {
        width: 100%;
        max-width: none;
        margin-left: 0;
        margin-right: 0;
        padding: 30px 24px;
      }

      .dashboard-welcome {
        align-items: flex-start;
        flex-direction: column;
      }

      .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }

      .summary-card {
        padding: 17px;
        gap: 10px;
      }

    }

    @media (max-width: 640px) {
      .app-topbar {
        min-height: 68px;
        padding: 10px 16px;
        gap: 8px;
      }

      .topbar-title p,
      .user-identity small {
        display: none;
      }

      .topbar-title h1 {
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .user-identity {
        display: none;
      }

      .topbar-user {
        flex-shrink: 0;
        gap: 6px;
      }

      .logout-button {
        padding: 8px 9px;
        font-size: .72rem;
      }

      .page {
        padding: 22px 16px 30px;
      }

      .dashboard-welcome {
        padding: 24px 21px;
        border-radius: 15px;
      }

      .dashboard-welcome h2 {
        font-size: 1.72rem;
      }

      .dashboard-actions {
        width: 100%;
      }

      .dashboard-action {
        flex: 1;
        justify-content: center;
      }

      .summary-grid {
        grid-template-columns: 1fr;
        gap: 10px;
      }

      .summary-card {
        padding: 16px 17px;
      }

      .summary-card strong {
        font-size: 1.35rem;
      }

       .dashboard-list-toolbar {
         align-items: stretch;
         flex-direction: column;
       }

       .dashboard-list-toolbar .bot-search {
         max-width: none;
       }

       .dashboard-filter,
       .dashboard-filter select {
         width: 100%;
       }

      .section-header {
        align-items: flex-start;
        flex-direction: column;
      }

      .queue-status {
        white-space: normal;
      }

      .dashboard-page .data-table th,
      .dashboard-page .data-table td {
        padding: 11px 12px;
      }

      .dashboard-page .data-table th:nth-child(2),
      .dashboard-page .data-table td:nth-child(2) {
        display: none;
      }
    }

    /* Phase 3A: bot workspace */
    .workspace-header {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 28px;
      padding-bottom: 23px;
      border-bottom: 1px solid var(--border-light);
    }

    .workspace-header h2 {
      margin-top: 5px;
      font-size: clamp(1.65rem, 3vw, 2.2rem);
      letter-spacing: -.04em;
    }

    .workspace-header>div>p:last-child {
      max-width: 680px;
      margin-top: 10px;
      color: var(--text-secondary);
      line-height: 1.6;
    }

    .workspace-primary-action {
      width: auto;
      min-width: 128px;
      padding: 11px 16px;
      background: #16803c;
      box-shadow: none;
    }

    .workspace-primary-action:hover {
      background: #11652f;
      box-shadow: none;
    }

    .bots-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      margin: 22px 0 16px;
    }

    .bot-search {
      flex: 1;
      max-width: 360px;
    }

    .bot-search input {
      width: 100%;
      min-height: 42px;
      padding: 9px 13px;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      background: #fff;
      color: var(--text-primary);
    }

    .bot-search input::placeholder {
      color: var(--text-faint);
    }

    .bots-count {
      color: var(--text-secondary);
      font-size: .77rem;
      white-space: nowrap;
    }

    .bot-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 14px;
      min-height: 164px;
    }

    .bot-card {
      min-width: 0;
      padding: 20px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
      box-shadow: 0 5px 16px rgba(30, 43, 34, .035);
    }

    .bot-card-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 14px;
    }

    .bot-card-title {
      min-width: 0;
      font-size: 1rem;
      overflow-wrap: anywhere;
    }

    .bot-card-id {
      display: block;
      margin-top: 5px;
      color: var(--text-faint);
      font-size: .67rem;
      font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .bot-config {
      display: grid;
      gap: 11px;
      margin: 19px 0;
    }

    .bot-config-row {
      display: grid;
      gap: 4px;
    }

    .bot-config-row>span {
      color: var(--text-faint);
      font-size: .64rem;
      font-weight: 800;
      letter-spacing: .08em;
      text-transform: uppercase;
    }

    .bot-config-row code {
      display: block;
      overflow-wrap: anywhere;
      color: var(--text-primary);
      font-size: .76rem;
      line-height: 1.5;
    }

    .bot-source-workspace {
      margin-top: 28px;
      padding: 24px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
      box-shadow: 0 5px 16px rgba(30, 43, 34, .035);
    }

    .bot-workspace-page {
      min-width: 0;
    }

    .bot-workspace-page .bot-source-workspace {
      margin-top: 0;
      min-height: calc(100vh - 132px);
    }

    .bot-workspace-breadcrumb {
      display: flex;
      align-items: center;
      gap: 9px;
      margin-bottom: 24px;
      color: var(--text-faint);
      font-size: .78rem;
    }

    .breadcrumb-back {
      border: 0;
      padding: 4px 0;
      background: transparent;
      color: var(--text-secondary);
      font: inherit;
      font-weight: 700;
      cursor: pointer;
    }

    .breadcrumb-back:hover {
      color: #176b4d;
    }

    .breadcrumb-back:focus-visible {
      outline: 3px solid rgba(22, 128, 60, .18);
      outline-offset: 3px;
      border-radius: 4px;
    }

    .source-workspace-status {
      color: var(--text-secondary);
      font-size: .8rem;
    }

    .bot-workspace-breadcrumb .source-workspace-status {
      margin-left: auto;
    }

    .bot-workspace-heading {
      min-width: 0;
    }

    .bot-workspace-heading h2 {
      margin: 5px 0 8px;
      font-size: clamp(1.55rem, 2.2vw, 2.1rem);
      letter-spacing: -.025em;
    }

    .workspace-save-action {
      width: auto;
      min-width: 0;
      white-space: nowrap;
    }

    .bot-workspace-info-row {
      display: flex;
      align-items: end;
      gap: 14px;
      margin-top: 24px;
      padding-top: 20px;
      border-top: 1px solid var(--border-light);
    }

    .workspace-name-field {
      display: grid;
      gap: 5px;
      flex: 1 1 auto;
      min-width: 190px;
      color: var(--text-secondary);
      font-size: .75rem;
      font-weight: 700;
    }

    .workspace-name-field .input-shell {
      min-height: 38px;
    }

    .bot-workspace-info-row .source-runtime-picker {
      flex: 0 0 150px;
    }

    .bot-workspace-page .bot-source-grid {
      margin-top: 30px;
      grid-template-columns: minmax(0, 1.75fr) minmax(270px, .75fr);
    }

    .bot-workspace-page .source-editor {
      height: clamp(420px, 58vh, 720px);
      min-height: 420px;
      max-height: 720px;
      overflow: auto;
      resize: vertical;
    }

    .bot-workspace-page .source-editor[readonly] {
      background: #27342d;
      color: #d4e1d7;
      cursor: default;
    }

    .workspace-save-hint {
      color: var(--text-faint);
      font-size: .78rem;
    }

    .bot-workspace-page .bot-revision-panel {
      padding-left: 24px;
    }

    .bot-workspace-page .bot-revision-list {
      max-height: 58vh;
    }

    .bot-workspace-page .bot-revision-item {
      background: #fff;
    }

    .editor-panel-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
    }

    .editor-panel-head label {
      font-weight: 700;
    }

    .editor-filename {
      color: #b7cdbd;
      font: .72rem ui-monospace, SFMono-Regular, Consolas, monospace;
    }

    .editor-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-top: 8px;
    }

    .editor-footer .field-help {
      margin-top: 0;
    }

    
    /* === Tactical Replay & Sandbox Enhancements === */
    .editor-sandbox {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      color: #176b4d;
      font-size: .74rem;
      font-weight: 700;
      background: #eaf6ee;
      padding: 3px 10px;
      border-radius: 999px;
      border: 1px solid #cce8d6;
    }

    .editor-sandbox::before {
      content: '';
      display: inline-block;
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: #10b981;
      box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
      animation: pulseGreen 2s infinite ease-in-out;
    }

    @keyframes pulseGreen {
      0%, 100% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.25); opacity: 0.65; }
    }

    .replay-piece {
      transition: transform .18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .18s ease;
      box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
    }

    .replay-piece:hover {
      transform: scale(1.12);
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
    }

    @keyframes capturePulse {
      0% { transform: scale(0.92); box-shadow: inset 0 0 0 2px #dc2626; }
      50% { transform: scale(1.04); box-shadow: inset 0 0 0 3px #ef4444, 0 0 10px rgba(239, 68, 68, 0.4); }
      100% { transform: scale(1); box-shadow: inset 0 0 0 2px #dc2626; }
    }

    
    /* === Victory & Goal Reached Celebratory Effects === */
    .replay-cell.goal {
      background: radial-gradient(circle at center, #fefbf2 20%, #fef5e0 100%);
      border: 1.5px dashed #d97706 !important;
      position: relative;
    }

    .goal-flag {
      position: absolute;
      top: 3px;
      right: 3px;
      z-index: 2;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 16px;
      height: 16px;
      color: #d97706;
      opacity: .92;
      filter: drop-shadow(0 1px 2px rgba(217, 119, 6, 0.4));
      transition: transform .3s ease;
    }

    .replay-cell.goal-reached,
    .replay-cell.victory-cell {
      background: radial-gradient(circle at center, #fffbeb 0%, #fef3c7 60%, #fde68a 100%) !important;
      box-shadow: 0 0 24px rgba(245, 158, 11, 0.75), inset 0 0 0 3px #f59e0b !important;
      border-style: solid !important;
      border-color: #f59e0b !important;
      z-index: 10;
      animation: victoryCellPulse 1.8s infinite ease-in-out;
    }

    .replay-cell.goal-reached .goal-flag,
    .replay-cell.victory-cell .goal-flag {
      color: #b45309;
      transform: scale(1.35) rotate(-5deg);
      animation: flagCelebrate 1.2s infinite alternate ease-in-out;
    }

    .replay-piece.victory-piece {
      transform: scale(1.18) !important;
      box-shadow: 0 0 16px rgba(245, 158, 11, 0.9), 0 4px 10px rgba(0, 0, 0, 0.3) !important;
      border-color: #fde68a !important;
      animation: victoryPieceBounce 1.4s infinite ease-in-out;
    }

    @keyframes victoryCellPulse {
      0%, 100% {
        box-shadow: 0 0 16px rgba(245, 158, 11, 0.6), inset 0 0 0 2px #f59e0b;
      }
      50% {
        box-shadow: 0 0 28px rgba(245, 158, 11, 0.95), inset 0 0 0 3.5px #d97706;
      }
    }

    @keyframes flagCelebrate {
      0% { transform: scale(1.2) rotate(-8deg); }
      100% { transform: scale(1.4) rotate(8deg); }
    }

    @keyframes victoryPieceBounce {
      0%, 100% { transform: scale(1.15) translateY(0); }
      50% { transform: scale(1.22) translateY(-4px); }
    }

    #replay-view .replay-series-card .replay-player-identity.is-winner {
      border-color: #f59e0b !important;
      background: linear-gradient(135deg, rgba(254, 243, 199, 0.5), rgba(253, 230, 138, 0.3)) !important;
      box-shadow: 0 0 20px rgba(245, 158, 11, 0.28), 0 4px 12px rgba(23, 35, 29, 0.06) !important;
      position: relative;
    }

    #replay-view .replay-series-card .replay-player-identity.is-winner::after {
      content: '🏆 THẮNG CUỘC';
      position: absolute;
      top: -10px;
      padding: 1px 7px;
      border-radius: 999px;
      background: linear-gradient(135deg, #f59e0b, #d97706);
      color: #fff;
      font-size: .65rem;
      font-weight: 800;
      letter-spacing: .03em;
      box-shadow: 0 2px 6px rgba(217, 119, 6, 0.4);
      animation: winnerBadgePulse 2s infinite ease-in-out;
      z-index: 2;
    }

    #replay-view .replay-series-card .replay-player-a-label.is-winner::after {
      left: 12px;
      right: auto;
    }

    #replay-view .replay-series-card .replay-player-b-label.is-winner::after {
      right: 12px;
      left: auto;
    }

    @keyframes winnerBadgePulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.06); }
    }

    #replay-view .replay-series-card .replay-player-identity.is-winner .replay-player-score {
      background: #fef3c7;
      color: #b45309;
      font-weight: 850;
      box-shadow: inset 0 0 0 1.5px #f59e0b;
    }

    .replay-current-move.is-victory-announcement {
      background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
      border-left: 4px solid #f59e0b !important;
      color: #78350f !important;
      font-weight: 750 !important;
      font-size: .84rem !important;
      box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
      animation: announcementGlow 1.8s infinite ease-in-out;
    }

    @keyframes announcementGlow {
      0%, 100% { box-shadow: 0 4px 14px rgba(245, 158, 11, 0.2); }
      50% { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.45); }
    }

    #r-winner.has-winner {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: #b45309;
      background: #fef3c7;
      padding: 2px 8px;
      border-radius: 6px;
      font-weight: 750;
      border: 1px solid #fde68a;
    }

    .replay-cell.capture {
      background: #fef2f2;
      box-shadow: inset 0 0 0 2px #ef4444;
      animation: capturePulse .4s ease-out;
    }

    .replay-cell.move-from {
      background: #fffbeb;
      box-shadow: inset 0 0 0 2px #f59e0b;
    }

    .replay-cell.move-to {
      background: #ecfdf5;
      box-shadow: inset 0 0 0 2px #10b981;
    }

    .editor-sandbox {
      color: #176b4d;
      font-size: .72rem;
      font-weight: 700;
    }

    .bot-source-header,
    .bot-revision-heading,
    .source-editor-actions {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }

    .bot-source-header h3 {
      margin: 4px 0 6px;
      font-size: 1.2rem;
    }

    .bot-source-header .section-kicker {
      margin: 0;
    }

    .source-runtime {
      flex: 0 0 auto;
      padding: 6px 9px;
      border: 1px solid #cfe0d4;
      border-radius: 7px;
      color: #176b4d;
      background: #f4faf5;
      font: 700 .75rem ui-monospace, SFMono-Regular, Consolas, monospace;
    }

    .source-runtime-picker {
      display: grid;
      gap: 4px;
      flex: 0 0 130px;
      color: var(--text-secondary);
      font-size: .72rem;
      font-weight: 700;
    }

    .source-runtime-picker select {
      min-height: 34px;
      padding: 6px 8px;
    }

    .workspace-source-mode {
      color: var(--text-faint);
      font-size: .68rem;
      font-weight: 600;
      line-height: 1.3;
    }

    .bot-source-grid {
      display: grid;
      grid-template-columns: minmax(0, 1.6fr) minmax(220px, .8fr);
      gap: 24px;
      margin-top: 22px;
    }

    .bot-editor-panel>label {
      display: block;
      margin-bottom: 8px;
      font-weight: 700;
    }

    .source-editor {
      display: block;
      width: 100%;
      box-sizing: border-box;
      min-height: 280px;
      padding: 14px;
      border: 1px solid #b9cbbf;
      border-radius: 9px;
      resize: vertical;
      background: #17231d;
      color: #edf7ef;
      font: .85rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
    }

    .source-editor:focus {
      border-color: #16803c;
      outline: 3px solid rgba(22, 128, 60, .16);
    }

    .source-editor-actions {
      margin-top: 16px;
    }

    .source-dirty {
      color: #8a5b12;
      font-size: .8rem;
    }

    .bot-revision-panel {
      min-width: 0;
      padding-left: 20px;
      border-left: 1px solid var(--border-light);
    }

    .bot-revision-heading h4 {
      margin: 0;
      font-size: .98rem;
    }

    .bot-revision-list {
      display: grid;
      gap: 8px;
      margin-top: 14px;
      max-height: 360px;
      overflow-y: auto;
    }

    .bot-revision-item {
      display: grid;
      gap: 6px;
      padding: 11px 12px;
      border: 1px solid var(--border-light);
      border-radius: 9px;
      background: #fbfdfb;
    }

    .bot-revision-item.selected {
      border-color: #93c5a2;
      background: #f2faf4;
    }

    .bot-revision-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      color: var(--text-secondary);
      font-size: .75rem;
    }

    .bot-revision-digest {
      overflow: hidden;
      color: var(--text-faint);
      font: .67rem ui-monospace, SFMono-Regular, Consolas, monospace;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .bot-revision-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .bot-card-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding-top: 14px;
      border-top: 1px solid var(--border-light);
    }

    .bot-card-footer small {
      color: var(--text-faint);
      font-size: .68rem;
    }

    .bot-actions {
      display: flex;
      gap: 7px;
    }

    .bot-action {
      width: auto;
      min-height: 32px;
      padding: 6px 9px;
      font-size: .72rem;
    }

    .bot-delete {
      border-color: #f4cccc;
      color: #b42318;
    }

    .bot-delete:hover {
      border-color: #e89b94;
      background: #fff4f2;
      color: #8e1d13;
    }

    /* My Bots: compact developer-platform cards */
    .bots-workspace-header {
      align-items: center;
      gap: 20px;
    }

    .bots-workspace-header .workspace-primary-action {
      flex: 0 0 auto;
      width: auto;
      white-space: nowrap;
    }

    .bot-search {
      position: relative;
      width: min(100%, 340px);
      max-width: 340px;
    }

    .bot-search .search-icon {
      position: absolute;
      top: 50%;
      left: 13px;
      width: 25px;
      height: 25px;
      color: var(--text-faint);
      pointer-events: none;
      transform: translateY(-50%);
    }

    .bot-search input {
      padding-left: 40px;
    }

    .bot-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 18px;
      align-items: stretch;
    }

    .bot-card {
      display: flex;
      min-height: 216px;
      flex-direction: column;
      padding: 20px;
      border-radius: 14px;
      box-shadow: 0 4px 14px rgba(23, 35, 29, .035);
    }

    .bot-card-header {
      align-items: flex-start;
      gap: 12px;
    }

    .bot-card-identity {
      display: flex;
      min-width: 0;
      align-items: flex-start;
      gap: 11px;
    }

    .bot-card-icon {
      display: inline-flex;
      width: 36px;
      height: 36px;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      border-radius: 10px;
      background: #e8f4ed;
      color: #176b50;
    }

    .bot-card-icon svg {
      width: 20px;
      height: 20px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .bot-card-title {
      margin: 3px 0 0;
      line-height: 1.3;
    }

    .bot-card-badges {
      display: flex;
      max-width: 46%;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 5px;
    }

    .bot-card-badge {
      padding: 4px 7px;
      border: 1px solid #cce6d7;
      border-radius: 999px;
      background: #f1faf4;
      color: #176b50;
      font-size: .68rem;
      font-weight: 750;
      line-height: 1;
      white-space: nowrap;
    }

    .bot-card-badge-muted {
      border-color: #e0e8e2;
      background: #f7faf8;
      color: #66736b;
    }

    .bot-card-body {
      flex: 1;
      padding: 22px 0 18px;
    }

    .bot-revision-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .bot-revision-icon {
      width: 18px;
      height: 18px;
      flex: 0 0 auto;
      color: #176b50;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .bot-revision-copy {
      display: grid;
      min-width: 0;
      gap: 4px;
    }

    .bot-revision-label {
      color: var(--text-faint);
      font-size: .68rem;
      font-weight: 750;
    }

    .bot-revision-copy code {
      overflow: hidden;
      color: var(--text-secondary);
      font-size: .78rem;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .bot-card-footer {
      min-height: 40px;
      padding-top: 14px;
    }

    .bot-actions {
      flex-wrap: nowrap;
      justify-content: flex-end;
    }

    .bot-action {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-height: 38px;
      white-space: nowrap;
    }

    .bot-action .ui-icon {
      width: 16px;
      height: 16px;
      flex: 0 0 auto;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .bot-card-footer small {
      display: inline-flex;
      min-width: 0;
      align-items: center;
      gap: 5px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    @media (max-width: 1080px) {
      .bot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

    @media (max-width: 640px) {
      .bots-workspace-header { align-items: stretch; }
      .bots-workspace-header .workspace-primary-action { width: fit-content; }
      .bot-grid { grid-template-columns: 1fr; }
      .bot-card-footer { align-items: center; }
      .bot-actions { width: auto; }
      .bot-action { flex: 0 0 auto; }
    }

    .bot-grid .ui-message {
      grid-column: 1 / -1;
      min-height: 164px;
      display: grid;
      place-content: center;
      border: 1px dashed #cbd8ce;
      border-radius: 15px;
      background: #fbfdfb;
    }

    .bot-empty-title {
      font-size: 1rem;
      color: var(--text-primary);
    }

    .bot-empty-copy {
      max-width: 420px;
      margin: 8px auto 15px;
      color: var(--text-secondary);
      line-height: 1.5;
    }

    .bot-empty-action {
      width: auto;
      justify-self: center;
      padding: 9px 13px;
    }

    .dialog-copy {
      margin: -2px 0 19px;
      color: var(--text-secondary);
      font-size: .83rem;
      line-height: 1.5;
    }

    .field-help {
      display: block;
      margin-top: 6px;
      color: var(--text-faint);
      font-size: .69rem;
      line-height: 1.45;
    }

    .field-help code {
      color: var(--text-secondary);
    }

    .form-error {
      margin: 0 0 12px;
      padding: 9px 10px;
      border: 1px solid #fecaca;
      border-radius: 9px;
      background: #fff4f2;
      color: #b42318;
      font-size: .76rem;
      line-height: 1.4;
    }

    .dialog-actions {
      display: flex;
      justify-content: flex-end;
      gap: 9px;
    }

    .dialog-actions .secondary-btn,
    .dialog-actions .primary-btn,
    .danger-btn {
      width: auto;
      min-width: 92px;
      padding: 10px 13px;
    }

    .danger-btn {
      border: 1px solid #b42318;
      border-radius: 10px;
      background: #b42318;
      color: #fff;
      font: inherit;
      font-size: .8rem;
      font-weight: 700;
    }

    .danger-btn:hover {
      background: #8e1d13;
    }

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

    @media (max-width: 640px) {
      .workspace-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 18px;
      }

      .bot-grid-empty,
      .tournament-grid-empty {
        margin-top: 20px;
      }

      .replay-match-header>div,
      .tournament-detail-hero>div:first-child {
        gap: 6px;
      }

      .replay-match-header .tournament-view-btn,
      .tournament-detail-hero .tournament-view-btn {
        margin-bottom: 6px;
      }

      .workspace-primary-action {
        width: 100%;
      }

      .bot-source-workspace {
        padding: 18px;
      }

      .bot-source-grid {
        grid-template-columns: 1fr;
      }

      .bot-revision-panel {
        padding-top: 20px;
        padding-left: 0;
        border-top: 1px solid var(--border-light);
        border-left: 0;
      }

      .bot-workspace-page .bot-source-workspace {
        min-height: auto;
      }

      .bot-workspace-breadcrumb {
        margin-bottom: 18px;
      }

      .bot-workspace-page .bot-source-header {
        align-items: stretch;
        flex-direction: column;
      }

      .bot-workspace-info-row {
        align-items: stretch;
        flex-direction: column;
      }

      .bot-workspace-info-row .source-runtime-picker {
        flex-basis: auto;
      }

      .workspace-save-action {
        width: 100%;
      }

      .editor-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
      }

      .bot-workspace-page .source-editor {
        min-height: 360px;
      }

      .bot-workspace-page .source-editor {
        height: 420px;
        max-height: none;
      }

      .source-editor-actions {
        align-items: stretch;
        flex-direction: column;
      }

      .source-editor-actions .primary-btn {
        width: 100%;
      }

      .bots-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
      }

      .bot-search {
        max-width: none;
      }

      .bots-count {
        white-space: normal;
      }

      .bot-grid {
        grid-template-columns: 1fr;
      }

      .bot-card {
        padding: 17px;
      }

      .bot-card-footer {
        align-items: flex-start;
        flex-direction: column;
      }

      .bot-actions {
        width: 100%;
      }

      .bot-action {
        flex: 1;
        justify-content: center;
      }

      .dialog-actions {
        flex-direction: column-reverse;
      }

      .dialog-actions .secondary-btn,
      .dialog-actions .primary-btn,
      .danger-btn {
        width: 100%;
      }
    }

    /* Phase 3B: tournament workspace */
    .tournament-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
      gap: 14px;
      min-height: 164px;
    }

    .tournament-filter-row {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      gap: 10px;
      margin: 14px 0;
    }

    .tournament-filter-row .input-shell {
      width: auto;
      min-width: 190px;
    }

    .tournament-card {
      display: grid;
      gap: 18px;
      min-width: 0;
      padding: 20px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
      box-shadow: 0 5px 16px rgba(30, 43, 34, .035);
    }

    .tournament-card h3 {
      overflow-wrap: anywhere;
    }

    .tournament-card-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      color: var(--text-secondary);
      font-size: .75rem;
    }

    .tournament-card-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      padding-top: 14px;
      border-top: 1px solid var(--border-light);
    }

    .tournament-card-footer small {
      color: var(--text-faint);
    }

    .tournament-view-btn {
      width: auto;
      padding: 8px 11px;
      font-size: .75rem;
    }

    .tournaments-page .tournament-card-footer .tournament-action-danger {
      width: auto;
      min-height: 32px;
      padding: 6px 9px;
      font-size: .72rem;
    }

    .tournament-detail-hero {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 22px;
      align-items: end;
      padding-bottom: 24px;
      border-bottom: 1px solid var(--border-light);
    }

    .tournament-detail-title {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
    }

    .tournament-detail-title h2 {
      overflow-wrap: anywhere;
    }

    .tournament-actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
    }

    .tournament-action {
      width: auto;
      padding: 9px 12px;
      font-size: .75rem;
    }

    .tournament-action-danger {
      border-color: #f4cccc;
      color: #b42318;
    }

    .tournament-overview {
      display: grid;
      grid-template-columns: minmax(250px, .8fr) minmax(0, 1.2fr);
      gap: 16px;
      margin-top: 22px;
    }

    .tournament-panel {
      min-width: 0;
      padding: 20px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
    }

    .tournament-panel-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
    }

    .participant-list {
      display: grid;
      gap: 0;
      margin: 15px 0 0;
      padding: 0;
      list-style: none;
    }

    .participant-list li {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      padding: 11px 0;
      overflow-wrap: anywhere;
    }

    .participant-list small {
      color: var(--text-faint);
    }

    .detail-register {
      width: auto;
      margin-top: 15px;
      padding: 9px 12px;
    }

    .tournament-schedule {
      display: grid;
      gap: 14px;
      margin-top: 22px;
    }

    .schedule-round {
      padding: 19px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
    }

    .standings-table-scroll,
    .schedule-table-scroll {
      max-width: 100%;
      overflow-x: auto;
      overscroll-behavior-inline: contain;
      scrollbar-width: thin;
    }

    .standings-table-scroll:focus-visible,
    .schedule-table-scroll:focus-visible {
      outline: 3px solid #176b4d;
      outline-offset: 3px;
    }

    .standings-table-scroll .data-table,
    .schedule-table-scroll .data-table {
      min-width: 620px;
    }

    .schedule-table th,
    .schedule-table td {
      white-space: nowrap;
    }

    .schedule-table th:nth-child(2),
    .schedule-table th:nth-child(3),
    .schedule-table td:nth-child(2),
    .schedule-table td:nth-child(3) {
      min-width: 130px;
      white-space: normal;
      overflow-wrap: anywhere;
    }

    .schedule-mobile-list {
      display: none;
    }

    .schedule-match-card {
      display: grid;
      gap: 14px;
      padding: 15px;
      border: 1px solid var(--border-light);
      border-radius: 12px;
      background: #fff;
    }

    .schedule-card-header,
    .schedule-card-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .schedule-card-players {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
      align-items: center;
      gap: 10px;
    }

    .schedule-card-player {
      display: grid;
      gap: 4px;
      min-width: 0;
    }

    .schedule-card-player:last-child {
      text-align: right;
    }

    .schedule-card-player small,
    .schedule-card-winner {
      color: var(--text-secondary);
      font-size: .72rem;
    }

    .schedule-card-player strong {
      overflow-wrap: anywhere;
    }

    .schedule-card-vs {
      color: var(--text-faint);
      font-size: .75rem;
      font-weight: 700;
    }

    .schedule-card-footer .secondary-btn {
      width: auto;
      flex: 0 0 auto;
      padding: 8px 11px;
    }

    .schedule-round h4 {
      margin-bottom: 12px;
      color: var(--text-secondary);
    }

    @media (max-width: 700px) {
      .tournament-detail-hero {
        grid-template-columns: 1fr;
        align-items: start;
      }

      .tournament-actions {
        justify-content: flex-start;
      }

      .tournament-overview {
        grid-template-columns: 1fr;
      }

      .tournament-card-footer {
        align-items: flex-start;
        flex-direction: column;
      }

      .tournament-filter-row {
        align-items: stretch;
        flex-direction: column;
      }

      .tournament-filter-row .input-shell {
        width: 100%;
      }

      .tournament-view-btn,
      .detail-register {
        width: 100%;
      }
    }

    @media (max-width: 640px) {
      .schedule-round {
        padding: 14px;
      }

      .schedule-table-scroll {
        display: none;
      }

      .schedule-mobile-list {
        display: grid;
        gap: 10px;
      }
    }

    .schedule-round-heading {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 13px;
    }

    .schedule-round-title {
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-primary);
      font-weight: 750;
    }

    .schedule-round-title .td-icon {
      width: 18px;
      height: 18px;
      color: #16803c;
    }

    .schedule-round-count {
      padding: 5px 9px;
      border-radius: 999px;
      background: #f1f7f2;
      color: var(--text-secondary);
      font-size: .72rem;
      font-weight: 650;
    }

    .schedule-table .schedule-match-row td:first-child {
      color: var(--text-secondary);
      font-weight: 700;
    }

    .schedule-winner-cell {
      color: #126b34;
      font-weight: 750;
    }

    .schedule-score-cell {
      min-width: 72px;
      color: var(--text-primary);
      font-size: .95rem;
      font-weight: 800;
      letter-spacing: .04em;
      text-align: center !important;
    }

    .schedule-action-cell .secondary-btn {
      width: auto;
      min-width: 104px;
      padding: 8px 11px;
      color: #126b34;
      border-color: #cfe4d4;
      background: #f4fbf5;
    }

    .schedule-action-cell .secondary-btn:hover {
      background: #e4f3e9;
    }

    .schedule-card-player.is-winner strong {
      color: #126b34;
    }

    .schedule-winner-mark {
      width: fit-content;
      margin-top: 2px;
      padding: 2px 6px;
      border-radius: 999px;
      background: #e4f3e9;
      color: #126b34;
      font-size: .58rem;
      font-weight: 800;
      letter-spacing: .04em;
    }

    .schedule-card-footer .schedule-card-winner {
      color: #126b34;
      font-weight: 650;
    }

    /* Phase 4: replay viewer */
    .replay-header {
      display: flex;
      justify-content: space-between;
      gap: 20px;
      align-items: end;
      padding-bottom: 22px;
      border-bottom: 1px solid var(--border-light);
    }

    .replay-header h2 {
      margin-top: 6px;
    }

    .replay-result {
      max-width: 360px;
      color: #16803c;
      font-weight: 700;
      text-align: right;
      overflow-wrap: anywhere;
    }

    .replay-loading {
      margin-top: 22px;
      padding: 48px 20px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
      color: var(--text-secondary);
      text-align: center;
    }

    .is-loading-skeleton {
      position: relative;
      overflow: hidden;
    }
    .is-loading-skeleton::after {
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      background: linear-gradient(105deg, transparent 25%, rgba(255,255,255,.62) 45%, transparent 65%);
      transform: translateX(-100%);
      animation: skeleton-shimmer 1.35s ease-in-out infinite;
    }
    .loading-skeleton-card {
      display: grid;
      grid-template-columns: 38px minmax(0, 1fr);
      align-content: center;
      gap: 8px 11px;
      min-height: 166px;
      padding: 20px;
      border: 1px solid #e1e9e3;
      border-radius: 14px;
      background: #fff;
    }
    .loading-skeleton-avatar,
    .loading-skeleton-line {
      display: block;
      border-radius: 7px;
      background: linear-gradient(90deg, #e8efea 0%, #f5f8f5 50%, #e8efea 100%);
      background-size: 220% 100%;
      animation: skeleton-pulse 1.2s ease-in-out infinite;
    }
    .loading-skeleton-avatar { grid-row: 1 / span 3; width: 38px; height: 38px; border-radius: 10px; }
    .loading-skeleton-line { height: 10px; }
    .loading-skeleton-line-title { width: 58%; height: 13px; }
    .loading-skeleton-line-wide { width: 92%; }
    .loading-skeleton-line-short { width: 64%; }
    .loading-skeleton-card.tournament-skeleton { min-height: 148px; }
    .loading-skeleton-row td { height: 54px; padding: 12px 16px; border-bottom: 1px solid #e5ebe6; }
    .loading-skeleton-row .loading-skeleton-line { width: 76%; height: 11px; }
    @keyframes skeleton-shimmer { to { transform: translateX(100%); } }
    @keyframes skeleton-pulse { 0%, 100% { opacity: .72; background-position: 100% 0; } 50% { opacity: 1; background-position: 0 0; } }

    .bot-grid {
      grid-template-columns: repeat(auto-fill, minmax(300px, 360px));
      align-items: start;
      justify-content: start;
      gap: 18px;
    }

    .bot-card {
      padding: 22px;
      border-radius: 12px;
      box-shadow: 0 6px 18px rgba(23, 35, 29, .04);
    }

    .bot-card-title {
      color: #17231d;
      font-size: 1.08rem;
      line-height: 1.3;
    }

    .bot-card-id {
      max-width: 180px;
      margin-top: 6px;
      color: #87958c;
      font-size: .62rem;
      opacity: .82;
    }

    .bot-config {
      gap: 13px;
      margin: 20px 0;
      padding: 14px;
      border: 1px solid #e3ebe5;
      border-radius: 9px;
      background: #f8faf8;
    }

    .bot-config-row>span {
      color: #66736b;
      font-size: .68rem;
      letter-spacing: .04em;
    }

    .bot-config-row code {
      color: #26372d;
      font-size: .78rem;
      line-height: 1.55;
      overflow-wrap: anywhere;
    }

    .bot-card-footer small {
      color: #66736b;
      font-size: .72rem;
    }

    .bot-delete {
      border-color: #e4c4c0;
      color: #9e3026;
    }

    .bot-delete:hover,
    .bot-delete:focus-visible {
      border-color: #c96d64;
      background: #fff5f3;
      color: #84251e;
    }

    .delete-bot-message {
      margin: 0 0 8px;
      color: #17231d;
      font-size: 1rem;
      line-height: 1.45;
    }

    .delete-bot-message strong {
      overflow-wrap: anywhere;
    }

    .tournaments-workspace-header h2 {
      margin-bottom: 7px;
      font-size: clamp(1.6rem, 3vw, 2rem);
    }

    .tournaments-workspace-header>div>p:last-child {
      margin-top: 0;
      color: #5d6c63;
      font-size: .94rem;
    }

    .tournament-grid {
      grid-template-columns: repeat(auto-fill, minmax(300px, 360px));
      align-items: start;
      justify-content: start;
      gap: 18px;
    }

    .tournament-grid .ui-message {
      min-height: 190px;
      max-width: 560px;
      margin: 0 auto;
      padding: 30px 24px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
      text-align: center;
    }

    .tournament-card {
      padding: 22px;
      border-radius: 12px;
      box-shadow: 0 6px 18px rgba(23, 35, 29, .04);
    }

    .tournament-card>div:first-child {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }

    .tournament-card h3 {
      min-width: 0;
      color: #17231d;
      font-size: 1.05rem;
      line-height: 1.35;
    }

    .tournament-card-meta {
      color: #5d6c63;
      font-size: .8rem;
    }

    .tournament-card-id {
      max-width: 170px;
      overflow: hidden;
      color: #87958c;
      font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
      font-size: .62rem;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .tournament-next-step {
      display: grid;
      gap: 5px;
      margin-top: 18px;
      padding: 15px 18px;
      border-left: 3px solid #8fc3a0;
      background: #f7faf7;
    }

    .tournament-next-step strong {
      color: #176b4d;
      font-size: .8rem;
    }

    .tournament-next-step p {
      margin: 0;
      color: #536259;
      font-size: .88rem;
      line-height: 1.5;
    }

    .tournament-next-step-cancelled {
      border-left-color: #9aa79f;
      background: #f5f6f5;
    }

    .tournament-next-step-cancelled strong {
      color: #526058;
    }

    .detail-empty {
      padding: 18px 0 4px;
      color: #5d6c63;
      font-size: .88rem;
    }

    .tournament-action {
      width: auto;
      min-width: 0;
      padding: 9px 13px;
      font-size: .78rem;
    }

    .tournament-action-danger {
      border-color: #e4c4c0;
      color: #9e3026;
    }

    .tournament-action-danger:hover,
    .tournament-action-danger:focus-visible {
      border-color: #c96d64;
      background: #fff5f3;
      color: #84251e;
    }

    #add-tourney-modal .modal-head h4 {
      color: #17231d;
      font-size: 1.25rem;
      font-weight: 700;
      letter-spacing: -.02em;
      text-transform: none;
    }

    #add-tourney-modal .dialog-copy {
      margin-top: -5px;
      margin-bottom: 22px;
      color: #5d6c63;
      font-size: .9rem;
    }

    #add-tourney-modal .form-group label {
      color: #34433a;
      font-size: .82rem;
      font-weight: 650;
    }

    #add-tourney-modal .input-shell {
      display: block;
      width: 100%;
      min-height: 44px;
      box-sizing: border-box;
      padding: 10px 12px;
      border: 1px solid #b8c8bc;
      border-radius: 8px;
      background: #fff;
      color: #17231d;
      font: inherit;
      outline: none;
    }

    #add-tourney-modal .input-shell:focus {
      border-color: #176b4d;
      box-shadow: 0 0 0 3px rgba(23, 107, 77, .13);
    }

    .replay-error-panel {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      margin-top: 22px;
      padding: 15px 18px;
      border: 1px solid #fecaca;
      border-radius: 12px;
      background: #fff7f7;
      color: #991b1b;
    }

    .replay-error-panel .secondary-btn {
      width: auto;
      flex: 0 0 auto;
    }

    .replay-layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(290px, .38fr);
      gap: 20px;
      margin-top: 22px;
      align-items: start;
    }

    .replay-board-panel,
    .replay-timeline-panel {
      min-width: 0;
      padding: 22px;
      border: 1px solid var(--border-light);
      border-radius: 15px;
      background: #fff;
    }

    .replay-timeline-panel {
      position: sticky;
      top: 22px;
      padding: 20px;
    }

    .replay-players {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      color: var(--text-secondary);
      font-size: .78rem;
      font-weight: 800;
      letter-spacing: .06em;
    }

    .replay-current-move {
      min-height: 1.2em;
      margin-top: 10px;
      color: var(--text-secondary);
      font-size: .78rem;
      text-align: center;
    }

    .replay-player-a,
    .replay-player-b {
      display: inline-flex;
      align-items: center;
      gap: 7px;
    }

    .replay-board-wrap {
      width: min(100%, 650px);
      max-width: 650px;
      margin: 18px auto 22px;
    }

    .coord-header {
      display: grid;
      grid-template-columns: repeat(9, 1fr);
      margin-left: 26px;
      color: var(--text-faint);
      font-size: .7rem;
      text-align: center;
    }

    .replay-board-row {
      display: grid;
      grid-template-columns: 26px minmax(0, 1fr);
    }

    .coord-side {
      display: grid;
      grid-template-rows: repeat(9, 1fr);
      color: var(--text-faint);
      font-size: .7rem;
      text-align: center;
      align-items: center;
    }

    .replay-board {
      display: grid;
      grid-template-columns: repeat(9, minmax(0, 1fr));
      grid-template-rows: repeat(9, minmax(0, 1fr));
      width: 100%;
      box-sizing: border-box;
      border: 2px solid #b8c8bc;
      border-radius: 3px;
      overflow: hidden;
      background: #f8fbf8;
      aspect-ratio: 1 / 1;
    }

    .replay-cell {
      display: grid;
      place-items: center;
      min-width: 0;
      min-height: 0;
      position: relative;
      box-sizing: border-box;
      aspect-ratio: 1 / 1;
      border: 1px solid #dfe8e1;
      background: #fbfdfb;
      transition: background .15s;
    }

    .replay-cell:nth-child(odd) {
      background: #f2f7f3;
    }

    .replay-cell.goal {
      background: #effaf2;
    }

    .replay-cell.move-from {
      background: #fef3c7;
    }

    .replay-cell.move-to {
      background: #dcfce7;
      box-shadow: inset 0 0 0 2px #16803c;
    }

    .replay-piece {
      display: grid;
      place-items: center;
      width: min(76%, 42px);
      box-sizing: border-box;
      aspect-ratio: 1;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, .9);
      color: #fff;
      line-height: 0;
      font-size: clamp(.58rem, 1.7vw, .85rem);
      font-weight: 900;
      box-shadow: 0 2px 5px rgba(23, 35, 29, .16);
    }

    .replay-player-a {
      background: #16803c;
    }

    .replay-player-b {
      background: #475569;
    }

    .replay-controls {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      gap: 7px;
      padding-top: 15px;
      border-top: 1px solid #e4ebe6;
    }

    .replay-controls .icon-btn,
    .replay-play {
      width: auto;
      min-width: 52px;
      min-height: 40px;
      padding: 8px 11px;
      font-size: .78rem;
    }

    .replay-step {
      min-width: 64px;
      text-align: center;
      font-weight: 800;
    }

    .replay-speed-label {
      display: flex;
      align-items: center;
      gap: 5px;
      color: var(--text-secondary);
      font-size: .72rem;
    }

    .replay-speed-label select {
      padding: 6px;
      border: 1px solid var(--border-light);
      border-radius: 7px;
      background: #fff;
    }

    .replay-timeline-panel h3 {
      margin-bottom: 5px;
      color: #17231d;
      font-size: 1.05rem;
    }

    .replay-details {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 9px;
      margin-top: 18px;
    }

    .replay-detail {
      min-width: 0;
      padding: 11px 12px;
      border-radius: 10px;
      background: var(--bg-soft);
    }

    .replay-detail small {
      display: block;
      margin-bottom: 4px;
      color: var(--text-faint);
      font-size: .65rem;
      font-weight: 800;
      letter-spacing: .07em;
      text-transform: uppercase;
    }

    .replay-detail strong {
      display: block;
      overflow-wrap: anywhere;
      font-size: .78rem;
    }

    .replay-timeline {
      display: grid;
      gap: 7px;
      max-height: 620px;
      overflow: auto;
    }

    .replay-move {
      width: 100%;
      padding: 10px;
      border: 1px solid var(--border-light);
      border-radius: 8px;
      background: #fff;
      color: var(--text-secondary);
      text-align: left;
      font-size: .75rem;
      overflow-wrap: anywhere;
    }

    .replay-move:hover,
    .replay-move.active {
      border-color: #16803c;
      background: #effaf2;
      color: #11652f;
    }

    @media (max-width:760px) {
      .replay-header {
        align-items: start;
        flex-direction: column;
      }

      .replay-result {
        text-align: left;
      }

      .replay-layout {
        grid-template-columns: 1fr;
      }

      .replay-match-header {
        gap: 14px;
      }

      .replay-result {
        width: 100%;
        box-sizing: border-box;
      }

      .replay-board-panel {
        padding: 14px;
      }

      .replay-board-wrap {
        margin-top: 14px;
      }

      .replay-controls {
        justify-content: center;
      }

      .replay-controls .icon-btn,
      .replay-play {
        flex: 1 1 42px;
        min-width: 0;
      }

      .replay-speed-label {
        flex: 1 0 100%;
        justify-content: center;
        margin: 4px 0 0;
      }

      .replay-timeline-panel {
        position: static;
      }

      .replay-board-panel,
      .replay-timeline-panel {
        padding: 15px;
      }

      .replay-timeline {
        max-height: 260px;
      }

      .replay-controls {
        justify-content: flex-start;
      }

      .replay-error-panel {
        align-items: flex-start;
        flex-direction: column;
      }

      .replay-error-panel .secondary-btn {
        width: 100%;
      }

      .replay-details {
        grid-template-columns: 1fr;
      }
    }

    /* Phase 7.1: one explicit visibility model for auth and workspace */
    [hidden] {
      display: none !important;
    }

    body {
      background: #f5f7f5;
      color: #17231d;
      font-family: "Avenir Next", "Segoe UI", sans-serif;
    }

/* Auth screen container - centered, responsive */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #f6f8f6 0%, #f0f2f0 100%);
  backdrop-filter: blur(10px);
  animation: fadeInScreen 0.4s cubic-bezier(.2, .8, .2, 1);
  isolation: isolate;
  z-index: 1000;
}

@keyframes fadeInScreen {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Auth container wrapper */
.auth-container {
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
}

/* Modern auth card with enhanced depth */
.auth-card {
  background: var(--auth-bg);
  border-radius: var(--auth-radius-xl);
  border: 1px solid var(--auth-border);
  box-shadow: var(--auth-shadow-xl);
  padding: 40px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: slideUpCard 0.5s cubic-bezier(.2, .8, .2, 1) 0.1s both;
}

@keyframes slideUpCard {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--auth-shadow-xl), 0 8px 32px rgba(22, 128, 60, .08);
}

/* Enhanced branding section */
.auth-branding {
  text-align: center;
  margin-bottom: 32px;
  position: relative;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--auth-brand), #0f9f58);
  border-radius: var(--auth-radius-lg);
  box-shadow: 0 8px 24px rgba(22, 128, 60, .2);
  color: white;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.auth-logo:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(22, 128, 60, .3);
}

.auth-logo svg {
  width: 32px;
  height: 32px;
  transition: transform 0.3s ease;
}

.auth-logo:hover svg {
  transform: rotate(5deg);
}

.brand-text h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--auth-text-primary);
  margin: 0 0 6px 0;
  letter-spacing: -0.03em;
}

.brand-text .brand-tagline {
  font-size: 0.875rem;
  color: var(--auth-text-secondary);
  margin: 0;
  font-weight: 500;
}

/* Enhanced form wrapper */
.auth-forms-wrapper {
  position: relative;
  min-height: 380px;
}

/* Individual forms with smooth transitions */
.auth-form {
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s cubic-bezier(.2, .8, .2, 1);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  visibility: hidden;
}

.auth-form.active-form {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
  position: relative;
  animation: fadeInForm 0.4s ease-out;
}

@keyframes fadeInForm {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Form header styling */
.form-header {
  margin-bottom: 28px;
}

.form-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--auth-text-primary);
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.form-description {
  font-size: 0.9375rem;
  color: var(--auth-text-secondary);
  margin: 0;
  line-height: 1.5;
  font-weight: 400;
}

/* Enhanced form fields */
.form-fields {
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.required-field {
  color: var(--auth-text-primary);
  font-weight: 600;
}

.required-field::after {
  content: " *";
  color: var(--auth-error);
  font-weight: 700;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-md);
  background: var(--auth-bg);
  color: var(--auth-text-primary);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s ease;
  outline: none;
  box-shadow: 0 1px 2px rgba(23, 32, 51, .02);
}

.input-wrapper input::placeholder {
  color: var(--auth-text-muted);
  font-weight: 400;
}

.input-wrapper input:focus {
  border-color: var(--auth-brand);
  box-shadow: 0 0 0 3px rgba(22, 128, 60, .1), 0 2px 8px rgba(22, 128, 60, .08);
  background: #fff;
}

.input-wrapper input:hover:not(:focus) {
  border-color: var(--auth-brand-dark);
  background: var(--auth-bg-darker);
}

.input-wrapper input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--auth-bg-darker);
}

.input-icon {
  position: absolute;
  left: 12px;
  width: 20px;
  height: 20px;
  color: var(--auth-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  pointer-events: none;
}

.input-wrapper input:focus ~ .input-icon,
.input-wrapper input:not(:placeholder-shown) ~ .input-icon {
  color: var(--auth-brand);
}

/* Enhanced password input */
.password-input-wrapper {
  position: relative;
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--auth-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--auth-radius-sm);
  transition: all 0.2s ease;
  padding: 0;
  z-index: 2;
}

.password-toggle-btn:hover {
  color: var(--auth-brand);
  background: rgba(22, 128, 60, .05);
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--auth-brand);
  outline-offset: 2px;
}

.password-toggle-btn svg {
  width: 18px;
  height: 18px;
  transition: all 0.2s ease;
}

.password-toggle-btn:hover svg {
  transform: scale(1.1);
}

.eye-slash-icon {
  display: none;
}

.password-toggle-btn .eye-icon {
  display: block;
}

.password-toggle-btn .eye-slash-icon {
  display: none;
}

.password-toggle-btn.is-visible .eye-icon {
  display: none !important;
}

.password-toggle-btn.is-visible .eye-slash-icon {
  display: block !important;
}

/* Error state styling */
.input-wrapper input:invalid:not(:focus) {
  border-color: var(--auth-error);
  background: var(--auth-error-bg);
}

.input-wrapper input:invalid:not(:focus) ~ .input-icon {
  color: var(--auth-error);
}

.error-message {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--auth-error);
  font-weight: 500;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.3s ease;
  position: relative;
  padding-left: 18px;
}

.error-message::before {
  content: "!";
  position: absolute;
  left: 0;
  font-weight: 600;
}

.input-wrapper input:invalid:not(:focus) ~ .error-message {
  opacity: 1;
  transform: translateY(0);
}

/* Enhanced button styling */
.form-actions {
  margin-bottom: 24px;
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--auth-radius-md);
  background: linear-gradient(135deg, var(--auth-brand), #0f9f58);
  color: white;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(22, 128, 60, .15);
}

.primary-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.6s ease;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(22, 128, 60, .25);
  background: linear-gradient(135deg, #11652f, #0d8650);
}

.primary-btn:hover:not(:disabled)::before {
  left: 100%;
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--auth-text-muted);
  box-shadow: none;
}

.btn-text {
  transition: opacity 0.2s ease;
}

.btn-loading {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
}

.spinner circle {
  stroke: currentColor;
  stroke-width: 4;
  fill: none;
}

.spinner path {
  fill: currentColor;
}

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

/* Auth switch links */
.auth-switch {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--auth-text-secondary);
}

.auth-switch p {
  margin: 0;
  font-weight: 400;
}

.text-link {
  background: none;
  border: none;
  color: var(--auth-brand);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  margin: 0 4px;
  text-decoration: none;
  position: relative;
  transition: all 0.2s ease;
}

.text-link::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--auth-brand);
  transform: scaleX(0);
  transition: transform 0.2s ease;
  transform-origin: center;
}

.text-link:hover {
  color: var(--auth-brand-hover);
}

.text-link:hover::after {
  transform: scaleX(1);
}

.text-link:focus-visible {
  outline: 2px solid var(--auth-brand);
  outline-offset: 2px;
}

/* Responsive design */
@media (max-width: 640px) {
  #auth-screen {
    padding: 16px;
  }
  
  .auth-card {
    padding: 28px 24px;
    border-radius: var(--auth-radius-lg);
  }
  
  .form-header h2 {
    font-size: 1.5rem;
  }
  
  .input-wrapper input {
    min-height: 48px;
    font-size: 0.875rem;
  }
  
  .primary-btn {
    min-height: 48px;
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 24px 20px;
  }
  
  .auth-logo {
    width: 56px;
    height: 56px;
  }
  
  .auth-logo svg {
    width: 28px;
    height: 28px;
  }
  
  .brand-text h1 {
    font-size: 1.25rem;
  }
  
  .form-header h2 {
    font-size: 1.375rem;
  }
  
  .form-description {
    font-size: 0.8125rem;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .auth-card {
    border-width: 2px;
  }
  
  .input-wrapper input {
    border-width: 2px;
  }
  
  .primary-btn {
    border: 2px solid var(--auth-brand-dark);
  }
}

    #auth-screen form {
      margin: 0;
    }

    #auth-screen form .primary-btn {
      width: 100%;
      margin-top: 4px;
    }

    .auth-switch {
      margin: 24px 0 0;
      color: #66736b;
      font-size: .76rem;
      text-align: center;
    }

    .text-button {
      display: inline;
      padding: 0;
      border: 0;
      background: transparent;
      color: #176b4d;
      font-size: inherit;
      font-weight: 750;
      text-decoration: underline;
      text-decoration-color: transparent;
      text-underline-offset: 3px;
    }

    .text-button:hover,
    .text-button:focus-visible {
      color: #0f553c;
      text-decoration-color: currentColor;
    }

    .primary-btn,
    .secondary-btn,
    .workspace-primary-action,
    .dashboard-action {
      min-height: 40px;
      border-radius: 8px;
      box-shadow: none;
      transform: none;
    }

    .primary-btn,
    .workspace-primary-action,
    .primary-btn.dashboard-action {
      background: #176b4d;
    }

    .primary-btn:hover,
    .workspace-primary-action:hover,
    .primary-btn.dashboard-action:hover {
      background: #0f553c;
    }

    .secondary-btn {
      border-color: #cbd8cf;
      color: #17231d;
    }

    .secondary-btn:hover {
      border-color: #176b4d;
      background: #edf4ef;
      color: #0f553c;
    }

    .summary-card,
    .recent-tournaments-card,
    .bot-card,
    .tournament-card,
    .tournament-panel,
    .replay-board-panel,
    .replay-timeline-panel {
      border-color: #dfe7e1;
      border-radius: 12px;
      box-shadow: 0 8px 24px rgba(23, 35, 29, .045);
    }

    .dashboard-welcome {
      align-items: center;
      padding: 4px 0 2px;
      background: transparent;
      border: 0;
      box-shadow: none;
    }

    .dashboard-welcome h2 {
      margin: 0 0 8px;
      font-size: clamp(1.75rem, 3vw, 2.25rem);
      line-height: 1.12;
    }

    .dashboard-welcome .welcome-copy {
      margin: 0;
      color: #5d6c63;
      font-size: .95rem;
      line-height: 1.5;
    }

    .dashboard-empty {
      max-width: 720px;
      margin: 0 auto;
      padding: 34px 28px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
      text-align: center;
    }

    .dashboard-empty h3 {
      margin: 4px 0 8px;
      color: #17231d;
      font-size: 1.25rem;
    }

    .dashboard-empty p:not(.section-kicker) {
      max-width: 460px;
      margin: 0 auto;
      color: #66736b;
      font-size: .94rem;
      line-height: 1.55;
    }

    .dashboard-empty-actions {
      display: flex;
      justify-content: center;
      gap: 10px;
      margin-top: 18px;
    }

    .summary-card {
      min-height: 116px;
      padding: 20px 22px;
      border-top: 2px solid #b8d8c3;
    }

    .summary-card p {
      margin-bottom: 6px;
      color: #536259;
      font-size: .84rem;
      font-weight: 650;
    }

    .summary-card strong {
      color: #17231d;
      font-size: 1.95rem;
      line-height: 1;
    }

    .summary-card small {
      margin-top: 7px;
      color: #66736b;
      font-size: .78rem;
    }

    .dashboard-section {
      margin-top: 30px;
    }

    .section-header {
      margin-bottom: 12px;
    }

    .section-header .section-kicker {
      margin-bottom: 5px;
      font-size: .68rem;
      letter-spacing: .08em;
    }

    .section-header h3 {
      font-size: 1.2rem;
    }

    .dashboard-welcome h2,
    .workspace-header h2,
    .tournament-detail-title h2,
    .replay-header h2 {
      color: #17231d;
      letter-spacing: -.045em;
    }

    .welcome-copy,
    .workspace-header>div>p:last-child,
    .dialog-copy {
      color: #66736b;
    }

    .section-kicker,
    .topbar-title p {
      color: #176b4d;
    }

    .data-table th {
      background: #f8faf8;
      color: #66736b;
    }

    .data-table td {
      color: #17231d;
    }

    .bot-config {
      background: #f8faf8;
      border-color: #dfe7e1;
    }

    .practice-dialog {
      width: min(1000px, calc(100vw - 32px));
    }

    .practice-dialog .modal-head {
      margin-bottom: 6px;
    }

    .practice-revision-meta {
      margin: 0;
      color: var(--text-faint);
      font-size: .76rem;
    }

    .practice-toolbar {
      display: flex;
      align-items: end;
      gap: 12px;
      margin: 18px 0;
      padding: 14px;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      background: var(--color-surface-subtle);
    }

    .practice-toolbar .form-group {
      flex: 1;
      margin: 0;
    }

    .practice-toolbar .primary-btn {
      flex: 0 0 auto;
    }

    .practice-status {
      margin: 0;
      color: var(--text-secondary);
      font-size: .875rem;
    }

    .practice-scenario-help {
      margin: 5px 0 0;
      color: var(--text-faint);
      font-size: .72rem;
    }

    .practice-output {
      display: grid;
      grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
      grid-template-areas: 'board result';
      gap: 18px;
      margin-top: 18px;
      align-items: start;
    }

    .practice-result {
      grid-area: result;
      padding: 16px;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      background: #f8faf8;
    }

    .practice-result h5 {
      margin: 0 0 6px;
      font-size: 1.05rem;
    }

    .practice-result-move {
      margin: 0 0 14px;
      color: var(--color-brand);
      font: 700 1.25rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
    }

    .practice-result-details {
      display: grid;
      grid-template-columns: max-content 1fr;
      gap: 7px 14px;
      margin: 0;
    }

    .practice-result-details dt {
      color: var(--text-secondary);
      font-size: .78rem;
      font-weight: 700;
    }

    .practice-result-details dd {
      margin: 0;
      color: var(--text-primary);
      font-size: .82rem;
      overflow-wrap: anywhere;
    }

    .practice-board-frame {
      grid-area: board;
      width: min(100%, 560px);
      margin: 0 auto;
    }

    .practice-board-frame .replay-board-wrap {
      width: 100%;
    }

    .practice-board-title {
      margin: 0 0 10px;
      font-size: .92rem;
    }

    .practice-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 8px 14px;
      margin-top: 10px;
      color: var(--text-secondary);
      font-size: .72rem;
    }

    .practice-legend-item {
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }

    .practice-legend-mark {
      width: 14px;
      height: 14px;
      display: inline-block;
      border: 2px solid var(--color-brand);
      border-radius: 3px;
      background: var(--color-board-highlight);
    }

    .practice-legend-mark.destination {
      border-style: dashed;
      background: transparent;
    }

    .practice-legend-mark.capture {
      border-color: var(--color-capture-highlight);
      border-radius: 50%;
      background: transparent;
    }

    .practice-legend-mark.goal {
      border-color: var(--color-goal);
      background: rgba(217, 119, 6, .12);
    }

    .practice-error-details {
      margin-top: 10px;
      color: var(--text-secondary);
      font-size: .76rem;
    }

    .practice-error-details p {
      margin: 6px 0 0;
      overflow-wrap: anywhere;
    }

    .practice-capture {
      box-shadow: inset 0 0 0 2px #b94a48;
    }

    .practice-capture-mark {
      position: absolute;
      inset: 4px 4px auto auto;
      z-index: 3;
      color: #b42318;
      font-weight: 800;
      line-height: 1;
    }

    .practice-selected-piece {
      outline: 2px solid #fff;
      outline-offset: -3px;
    }

    .modal-overlay {
      box-sizing: border-box;
      align-items: flex-start;
      overflow-y: auto;
      padding: 16px;
      background: rgba(23, 35, 29, .36);
      backdrop-filter: none;
    }

    .modal-box {
      width: min(92vw, 480px);
      padding: 28px;
      border-radius: 14px;
      box-shadow: 0 14px 32px rgba(23, 35, 29, .08);
      max-height: calc(100vh - 32px);
      max-height: calc(100dvh - 32px);
      margin: auto;
      overflow-y: auto;
    }

    .bots-workspace-header h2 {
      margin: 0 0 8px;
      font-size: clamp(1.6rem, 3vw, 2rem);
    }

    .bots-workspace-header>div>p:last-child {
      margin-top: 0;
      color: #5d6c63;
      font-size: .94rem;
    }

    .workspace-header>div {
      min-width: 0;
    }

    .bot-grid-empty,
    .tournament-grid-empty {
      margin-top: 24px;
    }

    .tournament-grid.tournament-grid-empty {
      display: block;
    }

    .tournament-grid.tournament-grid-empty .ui-message {
      width: min(100%, 440px);
      max-width: none;
      box-sizing: border-box;
      margin-right: auto;
      margin-left: auto;
    }

    .bot-grid .ui-message {
      min-height: 190px;
      max-width: 560px;
      margin: 0 auto;
      padding: 30px 24px;
      border-style: solid;
      border-color: #dfe7e1;
      border-radius: 12px;
      background: #fff;
      text-align: center;
    }

    .bot-empty-title {
      font-size: 1.12rem;
    }

    .bot-empty-copy {
      max-width: 390px;
      margin: 8px auto 18px;
      color: #5d6c63;
      font-size: .9rem;
    }

    .replay-match-header {
      align-items: center;
      padding-bottom: 18px;
    }

    .replay-match-header>div,
    .tournament-detail-hero>div:first-child {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 8px;
      min-width: 0;
    }

    .replay-match-header .tournament-view-btn,
    .tournament-detail-hero .tournament-view-btn {
      margin-bottom: 8px;
    }

    .replay-match-header .section-kicker,
    .replay-match-header h2,
    .tournament-detail-hero .dialog-copy {
      margin: 0;
    }

    .summary-grid {
      margin-top: 24px;
    }

    .replay-match-header h2 {
      margin-top: 5px;
      color: #17231d;
      font-size: clamp(1.55rem, 3vw, 2rem);
      letter-spacing: -.03em;
    }

    .replay-result {
      max-width: 420px;
      margin: 0;
      padding: 12px 15px;
      border: 1px solid #cfe4d5;
      border-radius: 10px;
      background: #f5fbf6;
      color: #176b4d;
      font-size: .88rem;
      line-height: 1.45;
      text-align: left;
    }

    .replay-players {
      padding: 0 2px 13px;
      border-bottom: 1px solid #e4ebe6;
      color: #17231d;
      font-size: .82rem;
      letter-spacing: .01em;
      text-transform: none;
    }

    .replay-players .replay-player-a,
    .replay-players .replay-player-b {
      background: transparent;
    }

    .replay-current-move {
      min-height: 2.7em;
      margin: 14px 0 0;
      color: #46564c;
      font-size: .88rem;
      line-height: 1.45;
    }

    .replay-cell.move-from {
      background: #fff4cf;
      box-shadow: inset 0 0 0 2px #d7a72d;
    }

    .replay-cell.move-to {
      background: #dff3e4;
      box-shadow: inset 0 0 0 2px #176b4d;
    }

    .replay-piece svg {
      display: block;
      flex: none;
      min-width: 0;
      min-height: 0;
      width: 70%;
      height: 70%;
      overflow: visible;
      color: currentColor;
    }

    .icon-sprite {
      position: absolute;
      width: 0;
      height: 0;
      overflow: hidden;
    }

    .goal-flag {
      position: absolute;
      top: 3px;
      right: 3px;
      z-index: 1;
      display: grid;
      place-items: center;
      width: 12px;
      height: 12px;
      color: #a86f16;
      opacity: .78;
      pointer-events: none;
    }

    .goal-flag svg {
      display: block;
      width: 100%;
      height: 100%;
    }

    .replay-controls button:disabled {
      cursor: not-allowed;
      opacity: .45;
    }

    .replay-step {
      min-width: 72px;
      color: #17231d;
      font-size: .82rem;
    }

    .replay-speed-label {
      margin-left: 4px;
      font-size: .78rem;
    }

    .replay-speed-label select {
      min-height: 36px;
      padding: 7px 9px;
      border-color: #b8c8bc;
      color: #17231d;
      font: inherit;
    }

    .replay-scrubber-label {
      display: grid;
      grid-column: 1 / -1;
      gap: 5px;
      color: #5d6c63;
      font-size: .74rem;
      margin-top: 12px;
      margin-bottom: 6px;
    }

    #replay-scrubber {
      width: 100%;
      accent-color: #176b4d;
    }

    .replay-selected-move {
      min-height: 2.8em;
      margin: 12px 0 0;
      padding: 10px 11px;
      border: 1px solid #dfe7e1;
      border-radius: 8px;
      background: #f8fbf8;
      color: #46564c;
      font-size: .78rem;
      line-height: 1.4;
    }

    .replay-cell.capture {
      background: #fff0ec;
      box-shadow: inset 0 0 0 2px #c96d64;
    }

    .replay-cell.move-to.capture {
      background: repeating-linear-gradient(135deg, #dff3e4 0 5px, #fff0ec 5px 10px);
      box-shadow: inset 0 0 0 2px #176b4d;
    }

    @media (prefers-reduced-motion: reduce) {

      .replay-move,
      .replay-cell {
        scroll-behavior: auto;
        transition: none;
      }
    }

    .replay-timeline-panel h3::after {
      display: block;
      margin-top: 7px;
      color: #718077;
      content: "Chọn một lượt để xem trạng thái bàn cờ";
      font-size: .76rem;
      font-weight: 400;
    }

    .replay-timeline {
      max-height: min(560px, 58vh);
      margin-top: 16px;
      padding-right: 3px;
      display: grid;
      gap: 8px;
      scrollbar-width: thin;
    }

    .replay-move {
      display: block;
      min-height: 44px;
      padding: 10px 11px;
      border-color: #dfe7e1;
      border-radius: 8px;
      color: #46564c;
      font-size: .78rem;
      line-height: 1.4;
      white-space: normal;
      overflow-wrap: anywhere;
    }

    .replay-move::before {
      display: inline-block;
      width: 7px;
      height: 7px;
      margin: 0 7px 1px 0;
      border-radius: 50%;
      background: #176b4d;
      content: "";
    }

    .replay-move:nth-child(even)::before {
      background: #475569;
    }

    .replay-move-unapplied {
      border-style: dashed;
      background: #fafafa;
      color: #66736b;
    }

    .replay-move-unapplied::before {
      background: #a0aaa3;
    }

    .replay-move:hover,
    .replay-move.active {
      border-color: #176b4d;
      background: #eff8f1;
      color: #11652f;
    }

    .replay-details {
      margin-top: 20px;
    }

    /* Replay refinement: keep the board dominant and the move history usable. */
    #replay-view {
      max-width: none;
      margin-left: 232px;
      margin-right: 0;
      width: calc(100% - 232px);
      box-sizing: border-box;
    }
    #replay-view .replay-header {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 18px;
      align-items: stretch;
      padding-bottom: 24px;
    }
    #replay-view .replay-result {
      display: flex;
      align-items: center;
      justify-content: center;
      width: min(680px, 100%);
      min-height: 66px;
      margin: 2px auto 0;
      padding: 16px 24px;
      box-sizing: border-box;
      border: 1px solid #cce4d4;
      border-radius: 16px;
      background: linear-gradient(135deg, #f2fbf5 0%, #ffffff 52%, #edf8f1 100%);
      color: #145c3e;
      font-size: clamp(.95rem, 1.5vw, 1.18rem);
      font-weight: 800;
      letter-spacing: .01em;
      line-height: 1.35;
      text-align: center;
      box-shadow: 0 10px 28px rgba(23, 107, 80, .09), inset 0 1px 0 rgba(255,255,255,.9);
      overflow-wrap: anywhere;
      position: relative;
    }

    /* Replay đã hiển thị tỉ số ngay trong hai khung đội; chỉ live mới cần dòng trạng thái này. */
    #replay-view:not(.live-match-view) #r-result-text {
      display: none;
    }

    #replay-view .replay-detail:has(#r-winner),
    #replay-view .replay-detail:has(#r-termination) {
      display: none;
    }
    #replay-view .replay-result::before {
      content: '';
      width: 7px;
      height: 7px;
      margin-right: 10px;
      flex: 0 0 7px;
      border-radius: 50%;
      background: #1d9b65;
      box-shadow: 0 0 0 5px rgba(29, 155, 101, .12);
    }
    #replay-view .replay-layout {
      grid-template-columns: minmax(0, 1.9fr) minmax(320px, .82fr);
      gap: 22px;
      margin-top: 20px;
    }
    #replay-view .replay-board-panel,
    #replay-view .replay-timeline-panel {
      border-color: #dce7df;
      border-radius: 14px;
      box-shadow: 0 8px 24px rgba(23, 35, 29, .035);
    }
    #replay-view .replay-board-panel { padding: 22px 24px 20px; }
    #replay-view .replay-timeline-panel { padding: 20px; }
    #replay-view .replay-players {
      align-items: stretch;
      gap: 16px;
      padding: 0 0 16px;
      font-size: .78rem;
    }
    #replay-view .replay-player-identity {
      display: grid;
      flex: 1 1 0;
      gap: 5px;
      min-width: 0;
      padding: 12px 14px;
      border: 1px solid #e1eae3;
      border-radius: 10px;
      background: #fbfdfb;
    }
    #replay-view .replay-player-a-label {
      border-color: var(--color-player-a);
    }
    #replay-view .replay-player-b-label {
      border-color: var(--color-player-b);
    }
    #replay-view .replay-player-identity.is-turn {
      box-shadow: 0 0 0 2px currentColor, 0 6px 16px rgba(23, 35, 29, .08);
    }
    #replay-view .replay-player-a-label.is-turn {
      color: var(--color-player-a);
    }
    #replay-view .replay-player-b-label.is-turn {
      color: var(--color-player-b);
    }
    #replay-view .replay-player-name {
      color: #172b20;
      font-size: .98rem;
      font-weight: 750;
      letter-spacing: -.01em;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #replay-view .replay-player-bot {
      color: #6e7c73;
      font-size: .76rem;
      font-weight: 500;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #replay-view .replay-versus {
      align-self: center;
      flex: 0 0 auto;
      color: #9aa69e;
      font-size: .72rem;
      font-weight: 800;
    }
    #replay-view .replay-board-wrap {
      width: min(100%, 700px);
      max-width: 700px;
      margin: 18px auto 20px;
    }
    #replay-view .replay-controls {
      display: flex;
      flex-wrap: nowrap;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding-top: 16px;
    }
    #replay-view .replay-control {
      display: inline-flex;
      flex: 0 0 40px;
      align-items: center;
      justify-content: center;
      gap: 6px;
      min-width: 40px;
      min-height: 40px;
      padding: 8px 10px;
      border-radius: 8px;
    }
    #replay-view .replay-play {
      flex-basis: 92px;
      min-width: 92px;
      color: #fff;
      background: #176b50;
      border-color: #176b50;
    }
    #replay-view .replay-play:hover,
    #replay-view .replay-play:focus-visible { background: #12563f; border-color: #12563f; }
    #replay-view .replay-control .ui-icon { width: 25px; height: 25px; }
    #replay-view .replay-step { flex: 0 0 72px; min-width: 72px; font-variant-numeric: tabular-nums; text-align: center; }
    #replay-view .replay-speed-label { flex: 0 0 auto; margin-left: 4px; white-space: nowrap; }
    #replay-view .replay-timeline-panel { min-height: 0; }
    #replay-view .replay-timeline-panel h3 { margin: 0; font-size: 1rem; }
    #replay-view .replay-timeline {
      max-height: min(480px, 52vh);
      margin-top: 14px;
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
    }
    #replay-view .replay-move {
      display: block;
      width: 100%;
      min-height: 42px;
      text-align: left;
      font-variant-numeric: tabular-nums;
    }
    #replay-view .replay-details { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    #replay-series-controls { display:flex; align-items:center; gap:8px; max-width:100%; margin:0 0 14px; padding:9px 11px; overflow-x:auto; border:1px solid #dfe8e1; border-radius:11px; background:#fbfdfb; scrollbar-width:thin; }
    #replay-series-controls::before { content:'Các ván'; flex:0 0 auto; color:#7b8980; font-size:.7rem; font-weight:800; letter-spacing:.06em; text-transform:uppercase; }
    #replay-series-controls .secondary-btn { width:auto; min-width:max-content; flex:0 0 auto; margin:0; padding:7px 10px; border:1px solid #d7e3da; border-radius:8px; background:#fff; color:#53645a; font-size:.74rem; white-space:nowrap; box-shadow:none; }
    #replay-series-controls .secondary-btn:hover { border-color:#9fc7ab; background:#f3faf5; color:#176b50; }
    #replay-series-controls .secondary-btn.active { border-color:#176b50; background:#e8f5ed; color:#176b50; font-weight:750; }
    #replay-view .replay-detail { min-width: 0; padding: 10px 11px; }
    #replay-view .replay-detail small { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
    #replay-view .replay-detail strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #replay-view .replay-match-id-value { display: flex; align-items: center; gap: 6px; min-width: 0; }
    #replay-view .replay-match-id-value strong { flex: 1 1 auto; min-width: 0; }
    #replay-view .replay-copy-id { flex: 0 0 auto; width: 30px; min-height: 30px; padding: 5px; }
    #replay-view .replay-copy-id .ui-icon { width: 25px; height: 25px; }

    @media (max-width: 900px) {
      #replay-view .replay-layout { grid-template-columns: minmax(0, 1fr); }
      #replay-view .replay-timeline-panel { position: static; }
      #replay-view .replay-timeline { max-height: 300px; }
    }

    @media (max-width: 600px) {
      #replay-view .replay-header { align-items: stretch; flex-direction: column; gap: 14px; }
      #replay-view .replay-result { max-width: none; }
      #replay-view .replay-board-panel,
      #replay-view .replay-timeline-panel { padding: 15px; }
      #replay-view .replay-players { gap: 8px; }
      #replay-view .replay-player-identity { padding: 10px; }
      #replay-view .replay-player-name { font-size: .86rem; }
      #replay-view .replay-player-bot { font-size: .68rem; }
      #replay-view .replay-player-score { min-width: 36px; height: 36px; font-size: 1.1rem; }
      #replay-view .replay-controls { flex-wrap: wrap; gap: 6px; }
      #replay-view .replay-control { flex-basis: 36px; min-width: 36px; padding: 7px; }
      #replay-view .replay-play { flex-basis: 78px; min-width: 78px; }
      #replay-view .replay-control-label { font-size: .72rem; }
      #replay-view .replay-speed-label { width: 100%; justify-content: center; margin: 3px 0 0; }
    }

    .replay-detail {
      border: 1px solid #e4ebe6;
      background: #f8faf8;
    }

    body.modal-open {
      overflow: hidden;
    }

    :focus-visible {
      outline: 3px solid #176b4d;
      outline-offset: 2px;
    }

    #register-bot-tourney-modal .modal-head h4,
    #tournament-action-modal .modal-head h4 {
      color: #17231d;
      font-size: 1.25rem;
      font-weight: 700;
      letter-spacing: -.02em;
      text-transform: none;
    }

    #register-bot-tourney-modal .modal-box {
      width: min(92vw, 520px);
      max-height: min(720px, calc(100dvh - 32px));
      padding: 26px;
      border-radius: 12px;
      overflow-y: auto;
    }

    #register-bot-tourney-modal .modal-head {
      align-items: flex-start;
      margin-bottom: 8px;
    }

    #register-bot-tourney-modal .modal-close {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      padding: 0;
      border-radius: 8px;
    }

    #register-bot-tourney-modal .modal-close-icon {
      width: 18px;
      height: 18px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    #register-bot-tourney-modal .registration-tournament-summary {
      display: flex;
      align-items: center;
      gap: 11px;
      margin: 16px 0 20px;
      padding: 12px 14px;
      border: 1px solid #dfe7e1;
      border-radius: 10px;
      background: #f7faf8;
      color: #17231d;
      font-size: .92rem;
      font-weight: 700;
      line-height: 1.35;
    }

    #register-bot-tourney-modal .registration-tournament-icon {
      width: 20px;
      height: 20px;
      flex: 0 0 auto;
      color: #176B50;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    #register-bot-tourney-modal .registration-summary-label {
      display: block;
      margin-bottom: 2px;
      color: #718078;
      font-size: .7rem;
      font-weight: 650;
      letter-spacing: .04em;
      text-transform: uppercase;
    }

    #register-bot-tourney-modal .registration-tournament-summary strong {
      display: block;
      font-weight: 700;
    }

    #register-bot-tourney-modal .dialog-actions {
      margin-top: 22px;
    }

    #register-bot-tourney-modal #submit-registration {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 40px;
      padding: 10px 15px;
    }

    #register-bot-tourney-modal #submit-registration .ui-icon {
      width: 16px;
      height: 16px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    #register-bot-tourney-modal .dialog-copy,
    #tournament-action-modal .dialog-copy {
      color: #5d6c63;
      font-size: .9rem;
      line-height: 1.5;
    }

    #register-bot-tourney-modal .form-group {
      margin-bottom: 8px;
    }

    #register-bot-tourney-modal .form-group label {
      margin-bottom: 7px;
      color: #34433a;
      font-size: .82rem;
      font-weight: 650;
    }

    #register-bot-tourney-modal .input-shell {
      display: block;
      box-sizing: border-box;
      min-height: 44px;
      padding: 10px 12px;
      border: 1px solid #b8c8bc;
      border-radius: 8px;
      background: #fff;
      color: #17231d;
      font: inherit;
      outline: none;
    }

    #register-bot-tourney-modal .input-shell:focus {
      border-color: #176b4d;
      box-shadow: 0 0 0 3px rgba(23, 107, 77, .13);
    }

    #register-bot-tourney-modal .input-shell[aria-invalid="true"] {
      border-color: #b42318;
    }

    .dialog-status,
    .dialog-empty-state {
      margin: 16px 0 0;
      color: #536259;
      font-size: .9rem;
      line-height: 1.5;
    }

    .dialog-empty-state {
      padding: 16px;
      border: 1px solid #dfe7e1;
      border-radius: 10px;
      background: #f8faf8;
    }

    .dialog-empty-state strong {
      display: block;
      color: #17231d;
      font-size: .96rem;
    }

    .dialog-empty-state p {
      margin: 6px 0 14px;
    }

    #register-bot-tourney-modal .field-help {
      display: block;
      margin: -1px 0 17px;
      color: #5d6c63;
      font-size: .78rem;
      line-height: 1.5;
    }

    #tournament-action-modal #tournament-action-support {
      margin-top: -8px;
    }

    @media (max-width: 900px) {
      #register-bot-tourney-modal .modal-box {
        width: min(94vw, 520px);
        padding: 22px 20px;
      }

      #register-bot-tourney-modal .dialog-actions {
        gap: 8px;
      }

      #register-bot-tourney-modal .dialog-actions button {
        flex: 1 1 0;
      }

    }

    @media (max-width: 640px) {
      #auth-screen.page {
        width: min(440px, calc(100% - 30px));
        margin-top: 8vh !important;
      }

      #auth-screen .card {
        padding: 24px 20px;
      }

      .workspace-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 18px;
      }

      .workspace-primary-action {
        width: 100%;
      }

      .bots-toolbar {
        align-items: stretch;
        flex-direction: column;
      }

      .bot-search {
        max-width: none;
        width: 100%;
      }

      .replay-layout {
        grid-template-columns: 1fr;
      }

      .replay-board-panel,
      .replay-timeline-panel {
        padding: 14px;
      }

      .replay-current-move {
        min-height: 1.45em;
        margin-top: 8px;
        line-height: 1.35;
      }

      .replay-board-wrap {
        margin: 10px auto 14px;
      }

      .replay-controls {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        justify-content: stretch;
      }

      .replay-controls .icon-btn,
      .replay-play {
        width: 100%;
        flex: none;
        min-width: 0;
        padding-inline: 3px;
        font-size: .7rem;
      }

      .replay-step {
        grid-column: 1 / span 2;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .replay-speed-label {
        grid-column: 3 / -1;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
      }

      .replay-speed-label select {
        min-width: 0;
        max-width: 100%;
      }

      .replay-timeline-panel {
        position: static;
      }

      .modal-overlay {
        padding: 10px;
      }

      .modal-box {
        width: min(100%, 480px);
        padding: 22px 18px;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
      }

      .practice-dialog {
        width: 100%;
      }

      .practice-toolbar {
        align-items: stretch;
        flex-direction: column;
      }

      .practice-toolbar .primary-btn {
        width: 100%;
      }

      .practice-output {
        grid-template-columns: 1fr;
        grid-template-areas: 'result' 'board';
      }

      .practice-result-details {
        grid-template-columns: 1fr;
        gap: 3px;
      }

      .practice-result-details dd {
        margin-bottom: 7px;
      }

      .dashboard-welcome {
        padding-top: 2px;
      }

      .dashboard-actions,
      .dashboard-empty-actions {
        width: 100%;
        flex-direction: column;
      }

      .dashboard-action,
      .dashboard-empty-actions button {
        width: 100%;
      }

      .dashboard-empty {
        padding: 24px 18px;
      }
    }

    /* Shared polish: role-aware navigation, editor, replay identities. */
    body {
      font-family: 'Be Vietnam Pro', system-ui, sans-serif;
    }

    .summary-grid {
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .participant-bot-id {
      color: var(--text-faint);
      font-size: .8rem;
      overflow-wrap: anywhere;
    }

    .source-editor-shell {
      display: grid;
      grid-template-columns: 48px minmax(0, 1fr);
      min-width: 0;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }

    .source-line-numbers {
      box-sizing: border-box;
      margin: 0;
      padding: 14px 10px;
      overflow: hidden;
      border-right: 1px solid var(--border-light);
      background: #f5f7f5;
      color: #849087;
      font: .82rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
      text-align: right;
      user-select: none;
    }

    .source-editor-shell .source-editor {
      width: 100%;
      border: 0;
      border-radius: 0;
      resize: vertical;
    }

    .source-editor-shell:focus-within {
      border-color: var(--color-brand);
      box-shadow: 0 0 0 3px rgba(22, 128, 60, .12);
    }

    .bot-revision-technical {
      color: var(--text-faint);
      font-size: .72rem;
    }

    .bot-revision-technical summary {
      width: max-content;
      cursor: pointer;
      color: var(--text-secondary);
      font-weight: 600;
    }

    .bot-revision-technical[open] summary {
      margin-bottom: 6px;
    }

    .tournament-lifecycle {
      display: flex;
      gap: 8px;
      margin: 22px 0 14px;
      padding: 0 0 7px;
      overflow-x: auto;
      list-style: none;
      scrollbar-width: thin;
    }

    .tournament-lifecycle li {
      flex: 0 0 auto;
      padding: 7px 10px;
      border-radius: 999px;
      background: #fff;
      color: var(--text-faint);
      font-size: .72rem;
      font-weight: 600;
    }

    .tournament-lifecycle li.is-complete {
      border-color: #b8d8c3;
      color: var(--color-success);
    }

    .tournament-lifecycle li.is-current {
      border-color: var(--color-brand);
      background: #edf7f0;
      color: var(--color-brand);
    }

    .replay-player-identity {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 2px;
      min-width: 0;
      flex: 1;
    }

    .replay-player-b-label {
      text-align: right;
      grid-template-columns: auto minmax(0, 1fr);
    }

    .replay-player-name {
      color: var(--text-primary);
      font-size: .88rem;
      font-weight: 700;
      letter-spacing: 0;
      overflow-wrap: anywhere;
    }

    .replay-player-bot,
    .replay-player-pieces {
      color: var(--text-faint);
      font-size: .68rem;
      font-weight: 500;
      letter-spacing: 0;
    }

    .replay-player-score {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      align-self: center;
      min-width: 42px;
      height: 42px;
      margin-left: 8px;
      padding: 0 9px;
      border: 1px solid #cce4d4;
      border-radius: 12px;
      background: #edf8f1;
      color: #176b50;
      font-size: 1.35rem;
      font-weight: 850;
      line-height: 1;
      font-variant-numeric: tabular-nums;
      grid-column: 2;
      grid-row: 1 / span 3;
    }

    .replay-player-b-label .replay-player-score {
      grid-column: 1;
      order: -1;
      margin-right: 8px;
      margin-left: 0;
    }

    .replay-player-identity.is-leading .replay-player-score {
      border-color: #74bd91;
      background: #dff3e6;
      box-shadow: 0 0 0 4px rgba(51, 157, 98, .1);
    }

    .replay-versus {
      align-self: center;
      color: var(--text-faint);
      font-size: .72rem;
      font-weight: 600;
    }

    .replay-piece.replay-player-a {
      background: var(--color-player-a);
    }

    .replay-piece.replay-player-b {
      background: var(--color-player-b);
    }

    .bottom-nav {
      display: none;
    }

    @media (max-width: 900px) {
      body[data-role="competitor"] .bottom-nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 1200;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 7px max(10px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
        border-top: 1px solid var(--border-light);
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 -8px 24px rgba(23, 35, 29, .07);
      }

      body[data-role="competitor"] .bottom-nav button {
        min-height: 44px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--text-secondary);
        font: 600 .72rem 'Be Vietnam Pro', system-ui, sans-serif;
      }

      body[data-role="competitor"] .bottom-nav button.active {
        background: #edf7f0;
        color: var(--color-brand);
      }

      body[data-role="competitor"] .page {
        padding-bottom: 88px;
      }

      body[data-role="competitor"] #mobile-menu-toggle {
        display: none;
      }
    }
  /* Tournament management page: spacious SaaS card grid. */
    #tournaments.tournaments-page {
      width: calc(100% - 232px);
      max-width: none;
      margin-left: 232px;
      margin-right: 0;
    }

    #tournaments #open-tournament-modal {
      width: auto;
      min-width: 0;
      min-height: 40px;
      max-width: max-content;
      flex: 0 0 auto;
      padding: 9px 14px;
      white-space: nowrap;
    }

    #tournaments #open-tournament-modal .ui-icon {
      width: 18px;
      height: 18px;
    }

    #topbar-breadcrumb {
      font-size: 1.12rem;
    }

    .tournament-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      margin: 24px 0 16px;
    }

    .tournament-toolbar-controls {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .tournament-toolbar .bot-search {
      width: min(340px, 34vw);
      max-width: none;
      flex: 0 1 340px;
    }

    .tournament-filter {
      position: relative;
      display: inline-flex;
      align-items: center;
      flex: 0 0 auto;
    }

    .tournament-filter > .ui-icon {
      position: absolute;
      left: 11px;
      width: 16px;
      height: 16px;
      color: var(--text-faint);
      pointer-events: none;
    }

    .tournament-filter select {
      min-height: 42px;
      min-width: 190px;
      padding: 9px 12px 9px 34px;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      background: #fff;
      color: var(--text-primary);
    }

    .tournament-toolbar .bots-count {
      flex: 0 0 auto;
      color: var(--text-secondary);
      font-size: .78rem;
      white-space: nowrap;
    }

    .tournaments-page .tournament-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      align-items: stretch;
      justify-content: stretch;
      gap: 16px;
      min-height: 0;
    }

    .tournaments-page .tournament-card {
      grid-template-rows: auto 1fr auto;
      gap: 16px;
      min-height: 196px;
      padding: 20px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      box-shadow: 0 3px 12px rgba(23, 35, 29, .025);
      transition: border-color .18s ease, box-shadow .18s ease;
    }

    .tournaments-page .tournament-card:hover {
      border-color: #a9cdb5;
      box-shadow: 0 7px 18px rgba(23, 35, 29, .06);
    }

    .tournaments-page .tournament-card > div:first-child {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }

    .tournaments-page .tournament-card h3 {
      min-width: 0;
      margin: 0;
      color: var(--text-primary);
      font-size: 1rem;
      font-weight: 650;
      line-height: 1.35;
      overflow-wrap: anywhere;
    }

    .tournaments-page .tournament-card .status-badge {
      flex: 0 0 auto;
    }

    .tournaments-page .status-badge {
      border: 1px solid transparent;
      border-radius: 999px;
      font-size: .68rem;
      font-weight: 650;
      line-height: 1;
    }

    .tournaments-page .status-registration_open {
      background: #e7f0ff;
      border-color: #c8dcff;
      color: #285ea8;
    }

    .tournaments-page .status-running {
      background: #e6f5eb;
      border-color: #c4e3cd;
      color: #176b3b;
    }

    .tournaments-page .status-registration_closed {
      background: #fff5df;
      border-color: #f0d9a5;
      color: #87611b;
    }

    .tournaments-page .status-completed {
      background: #eef1ef;
      border-color: #d9dfdb;
      color: #5a6860;
    }

    .tournaments-page .status-cancelled {
      background: #fff0ef;
      border-color: #efc9c5;
      color: #a0463e;
    }

    .tournaments-page .tournament-card-meta {
      display: grid;
      align-content: start;
      gap: 10px;
      color: var(--text-secondary);
      font-size: .8rem;
    }

    .tournament-meta-item {
      display: inline-flex;
      align-items: center;
      gap: 9px;
    }

    .tournament-meta-icon {
      width: 25px;
      height: 25px;
      flex: 0 0 auto;
      color: #789084;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .tournaments-page .tournament-card-footer {
      justify-content: flex-end;
      padding-top: 14px;
      border-top: 1px solid #e7ece8;
    }

    .tournaments-page .tournament-card-id {
      display: none;
    }

    .tournament-view-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 38px;
      padding: 8px 12px;
    }

    .tournament-action-icon {
      width: 16px;
      height: 16px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .tournament-grid .ui-message {
      grid-column: 1 / -1;
      width: 100%;
      max-width: none;
      min-height: 220px;
      box-sizing: border-box;
      margin: 0;
      padding: 36px 24px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
      text-align: center;
    }

    .tournament-empty-icon {
      display: block;
      width: 30px;
      height: 30px;
      margin: 0 auto 12px;
      color: #719481;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.7;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    @media (max-width: 1199px) {
      .tournaments-page .tournament-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    @media (max-width: 900px) {
      #tournaments.tournaments-page {
        width: 100%;
        margin-left: 0;
      }
    }

    @media (max-width: 767px) {
      .tournament-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
      }

      .tournament-toolbar-controls {
        align-items: stretch;
        flex-direction: column;
      }

      .tournament-toolbar .bot-search,
      .tournament-filter,
      .tournament-filter select {
        width: 100%;
        max-width: none;
      }

      .tournament-toolbar .bots-count {
        align-self: flex-start;
      }

      .tournaments-page .tournament-grid {
        grid-template-columns: 1fr;
      }
    }

    /* Create tournament modal refinement. */
    #add-tourney-modal {
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: rgba(16, 36, 29, .42);
    }

    #add-tourney-modal .modal-box {
      width: min(100%, 480px);
      max-height: min(720px, calc(100dvh - 48px));
      padding: 28px;
      border: 1px solid #dfe7e1;
      border-radius: 14px;
      background: #fff;
      box-shadow: 0 18px 46px rgba(16, 36, 29, .16);
      overflow-y: auto;
    }

    #add-tourney-modal .modal-head {
      margin-bottom: 10px;
    }

    #add-tourney-modal .modal-head h4 {
      font-size: 1.3rem;
      line-height: 1.25;
      letter-spacing: -.025em;
    }

    #add-tourney-modal .modal-close {
      width: 36px;
      height: 36px;
      border: 1px solid #dfe7e1;
      border-radius: 9px;
      background: #fff;
      color: #60736b;
    }

    #add-tourney-modal .modal-close:hover,
    #add-tourney-modal .modal-close:focus-visible {
      border-color: #a9cdb5;
      background: #f1f8f3;
      color: #176b4d;
    }

    #add-tourney-modal .modal-close-icon {
      width: 18px;
      height: 18px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    #add-tourney-modal .dialog-copy {
      margin: 0 0 24px;
      color: #60736b;
      font-size: .88rem;
      line-height: 1.55;
    }

    #add-tourney-modal .form-group {
      display: grid;
      gap: 8px;
      margin-bottom: 20px;
    }

    #add-tourney-modal .form-group label {
      color: #10241d;
      font-size: .82rem;
      font-weight: 700;
    }

    #add-tourney-modal .input-shell {
      min-height: 44px;
      padding: 10px 12px;
      border: 1px solid #c9d8cd;
      border-radius: 8px;
      background: #fff;
      color: #10241d;
      font: inherit;
      outline: none;
      transition: border-color .18s ease, box-shadow .18s ease;
    }

    #add-tourney-modal .input-shell:hover {
      border-color: #a9bfb0;
    }

    #add-tourney-modal .input-shell:focus {
      border-color: #176b4d;
      box-shadow: 0 0 0 3px rgba(23, 107, 77, .14);
    }

    #add-tourney-modal .input-shell[aria-invalid="true"] {
      border-color: #c65c55;
      box-shadow: 0 0 0 3px rgba(198, 92, 85, .1);
    }

    #add-tourney-modal .field-help {
      margin: 0;
      color: #718078;
      font-size: .76rem;
      line-height: 1.45;
    }

    #add-tourney-modal .form-error {
      margin: 0 0 16px;
    }

    #add-tourney-modal .dialog-actions {
      padding-top: 18px;
      border-top: 1px solid #e7ece8;
      gap: 10px;
    }

    #add-tourney-modal .dialog-actions .secondary-btn,
    #add-tourney-modal .dialog-actions .primary-btn {
      width: auto;
      min-width: 104px;
      min-height: 42px;
      padding: 9px 15px;
      border-radius: 8px;
    }

    #add-tourney-modal .tournament-submit-loading {
      display: inline-block;
    }

    #add-tourney-modal .primary-btn.is-loading {
      cursor: wait;
      opacity: .78;
    }

    @media (max-width: 640px) {
      #add-tourney-modal {
        align-items: flex-end;
        padding: 12px;
      }

      #add-tourney-modal .modal-box {
        max-height: calc(100dvh - 24px);
        padding: 24px 20px;
        border-radius: 12px;
      }

      #add-tourney-modal .dialog-actions {
        flex-direction: column-reverse;
      }

      #add-tourney-modal .dialog-actions .secondary-btn,
      #add-tourney-modal .dialog-actions .primary-btn {
        width: 100%;
      }
    }



    /* Login screen: calm, full-viewport, product-like treatment. */
    .ui-icon {
      width: 25px;
      height: 25px;
      flex: 0 0 auto;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .nav-link .ui-icon,
    .logout-button .ui-icon,
    .workspace-primary-action .ui-icon {
      width: 25px;
      height: 25px;
    }

    .nav-link {
      display: flex;
      align-items: center;
      gap: 10px !important;
      white-space: nowrap;
    }

    .logout-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      white-space: nowrap;
    }

    .workspace-primary-action {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }

    .bot-search {
      position: relative;
      display: block;
    }

    .bot-search .search-icon {
      position: absolute;
      top: 50%;
      left: 13px;
      width: 25px;
      height: 25px;
      transform: translateY(-50%);
      color: var(--text-faint);
      pointer-events: none;
    }

    .bot-search input {
      box-sizing: border-box;
      padding-left: 40px;
    }

    /* Dashboard uses all available workspace width instead of a centered max-width. */
    #dashboard.dashboard-page {
      width: calc(100% - 232px);
      max-width: none;
      margin-left: 232px;
      margin-right: 0;
    }

    #dashboard.dashboard-page .dashboard-welcome {
      display: flex;
      justify-content: space-between;
      gap: 24px;
    }

    #dashboard.dashboard-page .summary-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px;
      margin-top: 24px;
    }

    #dashboard.dashboard-page .summary-icon {
      width: 24px;
      height: 24px;
      color: #176B50;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    #dashboard.dashboard-page .summary-card {
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-height: 132px;
      gap: 16px;
      padding: 18px 20px;
      border: 1px solid #dce8e0;
      border-top-width: 1px;
      border-radius: 14px;
      box-shadow: 0 10px 28px rgba(30, 77, 55, .055);
      transition: transform .22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .22s ease, border-color .22s ease;
    }

    
    #dashboard.dashboard-page .dashboard-empty-actions {
      display: flex;
      justify-content: center;
      gap: 12px;
      margin-top: 16px;
    }

    #dashboard.dashboard-page .dashboard-empty-actions button {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-height: 40px;
      padding: 9px 20px;
      font-size: .88rem;
      border-radius: 10px;
      font-weight: 600;
      transition: all .18s ease;
    }

    #dashboard.dashboard-page .dashboard-empty-actions button:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 18px rgba(23, 107, 80, .14);
    }

    .record-win-bar {
      display: flex;
      height: 4px;
      width: 100%;
      min-width: 120px;
      border-radius: 999px;
      overflow: hidden;
      background: #fcecd2;
      margin-top: 6px;
    }

    .record-win-bar-fill {
      background: #e49a00;
      border-radius: 999px;
      height: 100%;
      transition: width .4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .dashboard-bot-identicon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 38px;
      height: 38px;
      flex: 0 0 38px;
      border-radius: 10px;
      font-size: .82rem;
      font-weight: 800;
      color: #fff;
      box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    }

    #dashboard.dashboard-page .summary-card:hover {
      transform: translateY(-3px);
      box-shadow: 0 14px 34px rgba(30, 77, 55, .095);
      border-color: #b8dac6;
    }

    #dashboard.dashboard-page .summary-card-main {
      display: flex;
      align-items: center;
      min-width: 0;
      gap: 17px;
    }

    #dashboard.dashboard-page .summary-card-main .stat-card__header {
      display: block;
      min-width: 0;
    }

    #dashboard.dashboard-page .summary-card-visual {
      display: inline-flex;
      width: 64px;
      height: 64px;
      flex: 0 0 64px;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      background: #dcf3e5;
      color: #08764f;
    }

    #dashboard.dashboard-page .summary-card-visual .summary-icon {
      width: 31px;
      height: 31px;
      color: inherit;
      stroke-width: 2.1;
    }

    #dashboard.dashboard-page .summary-card-chip {
      display: inline-flex;
      width: 40px;
      height: 40px;
      flex: 0 0 40px;
      align-items: center;
      justify-content: center;
      border: 1px solid #dce8e0;
      border-radius: 10px;
      background: #fff;
      color: #08764f;
    }

    #dashboard.dashboard-page .summary-card-chip .summary-icon {
      width: 21px;
      height: 21px;
      color: inherit;
    }

    #dashboard.dashboard-page #dash-record-card .summary-card-visual {
      background: #fff0cf;
      color: #e49a00;
    }

    #dashboard.dashboard-page #dash-record-card .summary-card-chip { color: #ca8700; }

    #dashboard.dashboard-page #dash-tourney-card .summary-card-visual {
      background: #e3edff;
      color: #2563df;
    }

    #dashboard.dashboard-page #dash-tourney-card .summary-card-chip { color: #176b4d; }

    #dashboard.dashboard-page .summary-card p {
      margin: 0 0 7px;
      color: #435249;
      font-size: .82rem;
      font-weight: 700;
    }

    #dashboard.dashboard-page .summary-card strong {
      margin: 0;
      color: #0d1913;
      font-size: 1.85rem;
      line-height: 1;
    }

    #dashboard.dashboard-page .summary-card-detail {
      display: inline-flex;
      align-items: center;
      margin-top: 8px;
      padding: 3px 8px;
      border-radius: 6px;
      background: #f1f6f3;
      color: #55685d;
      font-size: .75rem;
      font-weight: 600;
      line-height: 1.35;
    }

    #dashboard.dashboard-page #dash-record-card .summary-card-detail {
      background: #fff6e5;
      color: #9c6800;
    }

    #dashboard.dashboard-page #dash-tourney-card .summary-card-detail {
      background: #eef4ff;
      color: #1a5ac4;
    }

    #dashboard.dashboard-page .dashboard-section {
      margin-top: 32px;
    }

    #dashboard.dashboard-page .dashboard-section-title {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    #dashboard.dashboard-page .dashboard-section-title > .ui-icon {
      width: 23px;
      height: 23px;
      color: #08764f;
    }

    #dashboard.dashboard-page .dashboard-section-title h3 {
      margin: 0;
      font-size: 1.18rem;
    }

    #dashboard.dashboard-page .section-header {
      align-items: flex-start;
    }

    #dashboard.dashboard-page .section-description {
      margin: 4px 0 0;
      color: #718078;
      font-size: .82rem;
    }

    .dashboard-section-link {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      flex: 0 0 auto;
      padding: 5px 0;
      color: #176b4d;
      font-size: .8rem;
      font-weight: 650;
    }

    .dashboard-section-link .ui-icon {
      width: 25px;
      height: 25px;
    }

    .dashboard-bot-list {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 14px;
    }

    .dashboard-bots-section .section-header { margin-bottom: 10px; }

    .dashboard-bot-item {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
      min-height: 74px;
      padding: 12px 16px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
      color: #17231d;
      text-align: left;
      cursor: pointer;
      transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
    }

    .dashboard-bot-item:hover,
    .dashboard-bot-item:focus-visible {
      border-color: #88c29e;
      background: #fbfefc;
      transform: translateY(-2px);
      box-shadow: 0 8px 22px rgba(23, 107, 80, .08);
    }

    .dashboard-bot-item:hover .dashboard-bot-arrow {
      transform: translateX(3px);
      color: #176b4d;
    }

    .dashboard-bot-item.dashboard-bot-item-add {
      border: 1.5px dashed #c0d5c8;
      background: #fcfdfc;
      color: #176b4d;
      transition: all .2s ease;
    }

    .dashboard-bot-item.dashboard-bot-item-add:hover {
      border-color: #176b4d;
      background: #f1f8f4;
      color: #0b553b;
    }

    .dashboard-bot-badge {
      display: inline-flex;
      align-items: center;
      padding: 1px 6px;
      border-radius: 4px;
      font-size: .67rem;
      font-weight: 700;
      margin-left: 6px;
      vertical-align: middle;
      line-height: 1.4;
    }

    .dashboard-bot-badge.badge-cpp {
      background: #eaf1fd;
      color: #185abc;
      border: 1px solid #c9dcfa;
    }

    .dashboard-bot-badge.badge-python {
      background: #fef7e6;
      color: #b06000;
      border: 1px solid #fde1a6;
    }

    .nav-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 20px;
      height: 20px;
      padding: 0 6px;
      margin-left: auto;
      border-radius: 999px;
      font-size: .72rem;
      font-weight: 700;
      background: #e6f4ea;
      color: #137333;
      line-height: 1;
      transition: background-color .15s ease, color .15s ease;
    }

    .nav-link.active .nav-badge {
      background: #176b4d;
      color: #fff;
    }

    .replay-shortcuts-hint {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
      gap: 16px;
      margin-top: 14px;
      padding: 6px 12px;
      border-radius: 8px;
      background: #f8faf9;
      color: #64756b;
      font-size: .74rem;
    }

    .replay-shortcuts-hint kbd {
      font-size: .7rem;
      padding: 2px 5px;
    }

    .dashboard-bot-item-icon,
    .dashboard-bot-icon {
      width: 19px;
      height: 19px;
      flex: 0 0 auto;
      color: #176b4d;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
    }

    .dashboard-bot-item > .dashboard-bot-item-icon {
      box-sizing: content-box;
      padding: 8px;
      border-radius: 9px;
      background: #e5f5eb;
    }

    .dashboard-bot-copy {
      display: grid;
      min-width: 0;
      gap: 1px;
    }

    .dashboard-bot-copy strong,
    .dashboard-bot-copy small {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .dashboard-bot-copy strong { font-size: .78rem; }
    .dashboard-bot-copy small { color: #718078; font-size: .7rem; }
    .dashboard-bot-arrow { width: 13px; height: 13px; margin-left: auto; color: #718078; }

    @media (max-width: 1200px) {
      .dashboard-bot-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }

    .dashboard-bot-empty {
      display: grid;
      justify-items: center;
      gap: 6px;
      padding: 24px;
      border: 1px dashed #cbd8cf;
      border-radius: 10px;
      background: #fff;
      color: #718078;
      text-align: center;
    }

    .dashboard-bot-empty strong { color: #17231d; font-size: .88rem; }
    .dashboard-bot-empty span { font-size: .78rem; }

    @media (max-width: 900px) {
      #dashboard.dashboard-page {
        width: 100%;
        margin-left: 0;
      }

      #dashboard.dashboard-page .dashboard-welcome { align-items: flex-start; flex-direction: column; }
      #dashboard.dashboard-page .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .dashboard-bot-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

    @media (max-width: 560px) {
      #dashboard.dashboard-page .summary-grid,
      .dashboard-bot-list { grid-template-columns: 1fr; }

      #dashboard.dashboard-page .summary-card-visual {
        width: 54px;
        height: 54px;
        flex-basis: 54px;
      }
    }

    /* Tournament detail redesign */
    .tournament-detail-redesign { width: calc(100% - 248px); max-width: none !important; margin-left: 248px; margin-right: 0; padding: 34px 40px 64px; color: #17251d; }
    .tournament-detail-redesign .tournament-detail-hero { display:flex; align-items:flex-end; justify-content:space-between; gap:28px; padding:0 0 26px; border-bottom:1px solid #dfe8e1; }
    .tournament-heading-copy { min-width:0; }
    .tournament-breadcrumb { border:0; background:none; color:#66756c; padding:0; display:inline-flex; align-items:center; gap:7px; font-size:.79rem; font-weight:600; margin-bottom:18px; }
    .tournament-breadcrumb:hover { color:#176b50; }
    .tournament-breadcrumb .td-icon { width:16px; height:16px; }
    .tournament-breadcrumb .breadcrumb-separator { color:#b0bbb3; margin:0 1px; }
    .tournament-breadcrumb #td-breadcrumb-name { color:#25382c; font-weight:700; max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .tournament-detail-redesign .tournament-detail-title { display:block; }
    .tournament-detail-redesign .tournament-detail-title h2 { margin:0; }
    .tournament-detail-redesign .tournament-status-row { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-top:7px; }
    .tournament-detail-redesign .tournament-detail-title h2 { font-size:clamp(1.75rem, 3vw, 2.35rem); line-height:1.12; letter-spacing:-.035em; color:#15251c; }
    .tournament-detail-redesign .dialog-copy { color:#718078; margin-top:10px; font-size:.92rem; }
    .tournament-detail-redesign .tournament-actions { display:flex; align-items:center; justify-content:flex-end; gap:10px; flex-wrap:wrap; max-width:420px; }
    .tournament-detail-redesign .tournament-actions .tournament-action { width:auto; min-width:148px; padding:11px 16px; border-radius:9px; box-shadow:none; }
    .tournament-detail-redesign .tournament-actions { flex-wrap:nowrap; max-width:none; }
    .tournament-detail-redesign .tournament-actions .tournament-action { flex:0 0 auto; }
    .tournament-detail-redesign .tournament-actions .tournament-action-danger { color:#a23d3d; background:#fff; border:1px solid #e7caca; }
    .tournament-detail-redesign .tournament-actions .tournament-action-danger { min-width:0; padding:8px 10px; font-size:.72rem; }
    .tournament-detail-redesign .tournament-actions .tournament-refresh-action { min-width:0; color:#176b50; background:#f3faf5; border:1px solid #cfe4d4; }
    .tournament-detail-redesign .tournament-actions .tournament-refresh-action:hover { background:#e4f3e9; border-color:#b7d8c1; }
    .tournament-detail-redesign .tournament-action.is-loading { cursor:wait; opacity:.7; }
    .tournament-detail-redesign .execution-status { display:inline-flex; align-items:center; gap:5px; padding:5px 9px; border-radius:999px; font-size:.7rem; font-weight:700; }
    .tournament-detail-redesign .execution-status-ready { color:#5d6c63; background:#f1f5f2; }
    .tournament-detail-redesign .execution-status-running { color:#176b50; background:#e4f1eb; }
    .tournament-detail-redesign .execution-status-progress { color:#87611b; background:#fff5df; }
    .tournament-detail-redesign .execution-status-complete { color:#176b50; background:#e4f1eb; }
    .tournament-detail-redesign .execution-status-error { color:#a0463e; background:#fff0ef; }
    .tournament-detail-redesign .tournament-lifecycle { margin:26px 0 20px; padding:0; display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); list-style:none; position:relative; gap:0; }
    .tournament-detail-redesign .tournament-lifecycle::before, .tournament-detail-redesign .tournament-lifecycle::after { content:""; position:absolute; top:16px; left:7%; height:2px; border-radius:99px; z-index:0; }
    .tournament-detail-redesign .tournament-lifecycle::before { right:7%; background:#dce5de; }
    .tournament-detail-redesign .tournament-lifecycle::after { width:calc(var(--progress, 0) * .86%); background:#176b50; transition:width .25s ease; }
    .tournament-detail-redesign .tournament-lifecycle[data-cancelled="true"]::before, .tournament-detail-redesign .tournament-lifecycle[data-cancelled="true"]::after { display:none; }
    .tournament-detail-redesign .tournament-lifecycle li { min-width:0; display:flex; flex-direction:column; align-items:center; gap:9px; color:#98a49d; font-size:.72rem; line-height:1.25; text-align:center; position:relative; z-index:1; background:transparent; }
    .tournament-detail-redesign .lifecycle-marker { display:grid; place-items:center; width:34px; height:34px; border-radius:50%; border:1px solid #d8e2da; background:#f7f9f8; color:#8e9b92; font-size:.73rem; font-weight:700; box-shadow:0 0 0 5px #f7f9f8; }
    .tournament-detail-redesign .tournament-lifecycle li.is-complete { color:#176b50; }
    .tournament-detail-redesign .tournament-lifecycle li.is-complete .lifecycle-marker { background:#176b50; border-color:#176b50; color:#fff; }
    .tournament-detail-redesign .tournament-lifecycle li.is-current { color:#17251d; font-weight:700; }
    .tournament-detail-redesign .tournament-lifecycle li.is-current .lifecycle-marker { width:38px; height:38px; margin-top:-2px; background:#e4f1eb; border:2px solid #176b50; color:#176b50; box-shadow:0 0 0 5px #f7f9f8, 0 0 0 8px #d9eee2; }
    .tournament-detail-redesign .tournament-lifecycle li.is-cancelled { grid-column:1 / -1; flex-direction:row; justify-content:flex-start; color:#a24c3d; font-weight:700; }
    .tournament-detail-redesign .tournament-lifecycle li.is-cancelled .lifecycle-marker { background:#f9e3dc; border-color:#d99a8c; color:#a24c3d; }
    .lifecycle-mobile-count { display:none; }
    .tournament-detail-redesign .tournament-next-step { min-height:86px; display:flex; align-items:center; gap:16px; margin-bottom:28px; padding:17px 20px; background:#edf7f1; border:1px solid #cde6d7; border-radius:11px; }
    .next-step-icon { width:42px; height:42px; display:grid; place-items:center; flex:0 0 42px; border-radius:50%; color:#176b50; background:#d4eddf; }
    .next-step-icon svg { width:21px; height:21px; }
    .next-step-content { display:grid; gap:2px; }
    .next-step-content .panel-kicker { color:#176b50; }
    .next-step-content strong { color:#173b2a; font-size:1rem; }
    .next-step-content p { color:#66776d; font-size:.82rem; }
    .tournament-detail-redesign .tournament-overview { display:grid; grid-template-columns:minmax(0, .9fr) minmax(0, 1.1fr); gap:18px; }
    .tournament-detail-redesign .tournament-panel, .tournament-detail-redesign .tournament-schedule { background:#fff; border:1px solid #dfe8e1; border-radius:11px; box-shadow:0 2px 7px rgba(21,49,34,.035); }
    .tournament-detail-redesign .tournament-panel { padding:22px; }
    .tournament-detail-redesign .tournament-panel-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:18px; }
    .tournament-detail-redesign .tournament-panel-head h3, .tournament-detail-redesign .schedule-heading h3 { display:flex; align-items:center; gap:8px; color:#203329; font-size:1.03rem; }
    .panel-kicker { color: #203329; font-size:.84rem; letter-spacing:.1em; font-weight:700; margin-bottom:5px; }
    .panel-count { display:grid; place-items:center; min-width:30px; height:26px; padding:0 8px; border-radius:999px; background:#edf5ef; color:#176b50; font-size:.76rem; font-weight:700; }
    .panel-heading-icon { width:17px; height:17px; color:#176b50; }
    .tournament-detail-redesign .participant-list { display:grid; gap:8px; }
    .tournament-detail-redesign #td-participants { max-height:360px; overflow-y:auto; padding-right:4px; }
    .tournament-detail-redesign #td-participants:not(:has(.participant-empty)) { grid-template-columns:repeat(2,minmax(0,1fr)); align-content:start; }
    .tournament-detail-redesign .participant-list li:not(.participant-empty) { display:flex; align-items:center; justify-content:space-between; padding:11px 12px; border:1px solid #edf1ed; border-radius:8px; background:#fbfcfb; }
    .tournament-detail-redesign .participant-copy { display:grid; gap:3px; min-width:0; }
    .tournament-detail-redesign .participant-copy strong { color:#203329; font-size:.84rem; }
    .tournament-detail-redesign .participant-bot-line { display:flex; align-items:center; gap:7px; min-width:0; }
    .tournament-detail-redesign .participant-bot-id { flex:0 1 auto; min-width:0; color:#7b8980; font-size:.74rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .tournament-detail-redesign .participant-meta { flex:1 1 auto; min-width:0; color:#9aa69e; font-size:.68rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .tournament-detail-redesign .participant-empty, .tournament-detail-redesign .detail-empty, .tournament-detail-redesign .requests-empty { min-height:104px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; color:#8a978e; text-align:center; list-style:none; }
    .tournament-detail-redesign .participant-empty svg, .tournament-detail-redesign .detail-empty svg { width:29px; height:29px; color:#94a49a; margin-bottom:3px; }
    .tournament-detail-redesign .participant-empty strong, .tournament-detail-redesign .detail-empty strong { color:#57685d; font-size:.88rem; }
    .tournament-detail-redesign .participant-empty span, .tournament-detail-redesign .detail-empty span { font-size:.76rem; }
    .tournament-detail-redesign .requests-empty .td-icon { color:#94a49a; margin-bottom:2px; }
    .tournament-detail-redesign .requests-empty strong { color:#57685d; font-size:.84rem; }
    .tournament-detail-redesign .requests-empty span { color:#8a978e; font-size:.75rem; }
    .tournament-detail-redesign .request-section-title { display:flex; align-items:center; gap:9px; }
    .tournament-detail-redesign .request-section-title .td-icon { color:#176b50; }
    .tournament-detail-redesign .request-pending-count { padding:5px 9px; border-radius:999px; background:#fff4d6; color:#946200; font-size:.7rem; font-weight:700; white-space:nowrap; }
    .tournament-detail-redesign #td-request-list { display:grid; gap:9px; }
    .tournament-detail-redesign #td-request-list { max-height:360px; overflow-y:auto; padding-right:4px; }
    .tournament-detail-redesign #td-participants .is-viewer-participant {
      position:relative; border-color:#6c8cff; background:#f3f6ff; box-shadow:0 0 0 2px rgba(108,140,255,.14);
    }
    .tournament-detail-redesign .viewer-marker {
      position:absolute; top:10px; right:10px; border-radius:999px; padding:3px 8px;
      background:#3857c8; color:#fff; font-size:11px; font-weight:800; letter-spacing:.02em;
    }
    .tournament-detail-redesign #td-standings tbody tr.is-viewer-standing,
    .tournament-detail-redesign .schedule-match-row.is-viewer-match {
      background:#f3f6ff; box-shadow:inset 3px 0 0 #3857c8;
    }
    .tournament-detail-redesign .schedule-match-card.is-viewer-match {
      border-color:#6c8cff; background:#f3f6ff; box-shadow:0 0 0 2px rgba(108,140,255,.14);
    }
    .tournament-detail-redesign .participant-request-row { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:15px 16px; border:1px solid #dfe7e1; border-radius:10px; background:#fff; }
    .tournament-detail-redesign .request-identity { display:flex; align-items:center; gap:12px; min-width:0; }
    .tournament-detail-redesign .request-bot-icon { display:grid; place-items:center; flex:0 0 40px; width:40px; height:40px; border-radius:9px; background:#edf7f1; color:#176b50; }
    .tournament-detail-redesign .request-copy { display:grid; gap:5px; min-width:0; }
    .tournament-detail-redesign .request-copy strong { color:#203329; font-size:.9rem; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .tournament-detail-redesign .request-meta-row { display:flex; align-items:center; gap:7px; min-width:0; }
    .tournament-detail-redesign .request-meta { color:#68786e; font-size:.78rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .tournament-detail-redesign .request-copy-id { display:inline-flex; align-items:center; justify-content:center; flex:0 0 28px; width:28px; height:28px; padding:0; border:1px solid #dfe7e1; border-radius:7px; background:#fff; color:#68786e; }
    .tournament-detail-redesign .request-copy-id:hover { color:#176b50; border-color:#176b50; background:#f3faf5; }
    .tournament-detail-redesign .request-controls { display:flex; align-items:center; justify-content:flex-end; gap:10px; flex:0 0 auto; }
    .tournament-detail-redesign .request-status { display:inline-flex; align-items:center; gap:5px; padding:6px 8px; border-radius:999px; font-size:.7rem; font-weight:700; white-space:nowrap; }
    .tournament-detail-redesign .request-status-pending { color:#946200; background:#fff4d6; }
    .tournament-detail-redesign .request-status-approved { color:#176b50; background:#e8f5ed; }
    .tournament-detail-redesign .request-status-rejected { color:#a24c3d; background:#fbeceb; }
    .tournament-detail-redesign .request-action { width:auto; min-width:92px; height:38px; padding:0 12px; border-radius:8px; box-shadow:none; font-size:.82rem; display:inline-flex; align-items:center; justify-content:center; gap:8px; white-space:nowrap; }
    .tournament-detail-redesign .request-action-primary { color:#fff; background:#176b50; border:1px solid #176b50; }
    .tournament-detail-redesign .request-action-primary:hover { background:#12553f; border-color:#12553f; }
    .tournament-detail-redesign .request-action-danger { color:#dc2626; background:#fff; border:1px solid #efb7b7; }
    .tournament-detail-redesign .request-action-danger:hover { background:#fff5f5; border-color:#dc2626; }
    .tournament-detail-redesign .request-action .td-icon { pointer-events:none; }
    .tournament-detail-redesign .standings-table-scroll { max-height:300px; overflow:auto; }
    .tournament-detail-redesign .data-table th { color:#88958c; font-size:.66rem; text-transform:uppercase; letter-spacing:.04em; background:#fbfcfb; }
    .tournament-detail-redesign .data-table td { color:#415148; font-size:.88rem; }
    .tournament-detail-redesign .standings-heading { display:flex; align-items:center; gap:8px; }
    .tournament-detail-redesign .standings-heading .td-icon { color:#176b50; }
    .tournament-detail-redesign .standings-panel .standings-table-scroll { margin:0 -6px; padding:0 6px 4px; }
    .tournament-detail-redesign #td-standings tbody tr { transition:background .18s ease, box-shadow .18s ease; }
    .tournament-detail-redesign #td-standings tbody tr:hover { background:#f7fbf8; }
    .tournament-detail-redesign #td-standings tbody tr.standing-top-1,
    .tournament-detail-redesign #td-standings tbody tr.standing-top-2,
    .tournament-detail-redesign #td-standings tbody tr.standing-top-3 { font-weight:650; }
    .tournament-detail-redesign #td-standings tbody tr.standing-top-1 { background:linear-gradient(90deg, #fff9e8, #fffdf7); box-shadow:inset 4px 0 0 #e6ad24; }
    .tournament-detail-redesign #td-standings tbody tr.standing-top-2 { background:linear-gradient(90deg, #f3f6f7, #fbfcfc); box-shadow:inset 4px 0 0 #9daab0; }
    .tournament-detail-redesign #td-standings tbody tr.standing-top-3 { background:linear-gradient(90deg, #fff2e9, #fffaf7); box-shadow:inset 4px 0 0 #c87945; }
    .tournament-detail-redesign #td-standings tbody tr.standing-top-1 td:nth-child(2),
    .tournament-detail-redesign #td-standings tbody tr.standing-top-2 td:nth-child(2),
    .tournament-detail-redesign #td-standings tbody tr.standing-top-3 td:nth-child(2) { color:#1e3026; font-weight:800; }
    .tournament-detail-redesign .standing-rank-cell { width:58px; }
    .tournament-detail-redesign .standing-rank-badge { display:inline-flex; width:30px; height:30px; align-items:center; justify-content:center; border-radius:50%; font-size:.78rem; font-weight:850; }
    .tournament-detail-redesign .standing-top-1 .standing-rank-badge { background:#f6d875; color:#765306; box-shadow:0 0 0 4px rgba(230,173,36,.14); }
    .tournament-detail-redesign .standing-top-2 .standing-rank-badge { background:#dce3e7; color:#52616a; box-shadow:0 0 0 4px rgba(157,170,176,.14); }
    .tournament-detail-redesign .standing-top-3 .standing-rank-badge { background:#e7b28d; color:#75401f; box-shadow:0 0 0 4px rgba(200,121,69,.14); }
    .tournament-detail-redesign #td-standings tbody tr.is-viewer-standing { outline:2px solid #3857c8; outline-offset:-2px; }
    .tournament-detail-redesign .tournament-schedule { margin-top:18px; padding:22px; }
    .schedule-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:18px; }
    .schedule-caption { color:#89968e; font-size:.76rem; }
    .schedule-empty { min-height:168px; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:8px; border:1px dashed #d7e3da; border-radius:9px; color:#87958c; text-align:center; }
    .schedule-empty svg { width:30px; height:30px; color:#8fa095; }
    .schedule-empty strong { color:#55675b; font-size:.9rem; }
    .schedule-empty p { color:#89968e; font-size:.78rem; }
    .tournament-detail-redesign .schedule-round { margin-top:16px; }
    .tournament-detail-redesign .schedule-round h4 { color:#3b4d41; font-size:.83rem; margin-bottom:9px; }
    .tournament-detail-redesign .detail-register { width:auto; margin-top:16px; }
    .tournament-detail-redesign .td-icon { display:inline-block; flex-shrink:0; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; vertical-align:middle; }
    .tournament-detail-redesign .td-icon--sm { width:25px; height:25px; }
    .tournament-detail-redesign .td-icon--md { width:25px; height:25px; }
    .tournament-detail-redesign .td-icon--lg { width:32px; height:32px; }
    .tournament-detail-redesign .tournament-breadcrumb .td-icon { color:#66756c; }
    .tournament-detail-redesign .tournament-actions .td-icon { color:currentColor; }
    .tournament-detail-redesign .tournament-action-danger .td-icon { color:#dc2626; }
    .tournament-detail-redesign .lifecycle-marker .td-icon { width:16px; height:16px; }
    .tournament-detail-redesign .schedule-round h4 { display:flex; align-items:center; gap:7px; }
    .tournament-detail-redesign .schedule-heading-icon { color:#66756c; }
    .tournament-detail-redesign .schedule-table th:nth-child(5),
    .tournament-detail-redesign .schedule-table td:nth-child(5) { width:92px; min-width:92px; padding-left:8px; padding-right:8px; text-align:center !important; vertical-align:middle; }
    .tournament-detail-redesign .schedule-table { width:100%; min-width:958px; table-layout:fixed; }
    .tournament-detail-redesign .schedule-table th:nth-child(1),
    .tournament-detail-redesign .schedule-table td:nth-child(1) { width:76px; }
    .tournament-detail-redesign .schedule-table th:nth-child(2),
    .tournament-detail-redesign .schedule-table td:nth-child(2),
    .tournament-detail-redesign .schedule-table th:nth-child(3),
    .tournament-detail-redesign .schedule-table td:nth-child(3) { width:150px; }
    .tournament-detail-redesign .schedule-table th:nth-child(4),
    .tournament-detail-redesign .schedule-table td:nth-child(4) { width:118px; }
    .tournament-detail-redesign .schedule-table th:nth-child(6),
    .tournament-detail-redesign .schedule-table td:nth-child(6) { width:142px; }
    .tournament-detail-redesign .schedule-table th:nth-child(7),
    .tournament-detail-redesign .schedule-table td:nth-child(7) { width:230px; min-width:230px; }
    .tournament-detail-redesign .schedule-action-cell { min-width:230px; width:230px; vertical-align:middle; }
    .tournament-detail-redesign .schedule-action-cell .action-content { flex-wrap:nowrap; gap:6px; }
    .tournament-detail-redesign .schedule-action-empty { display:block; width:100%; color:#a3afa7; text-align:center; font-weight:700; }
    .tournament-detail-redesign .next-step-icon .td-icon { color:#176b50; }
    .tournament-detail-redesign .tournament-next-step-cancelled .next-step-icon .td-icon { color:#a24c3d; }
    .tournament-detail-redesign .tournament-next-step-cancelled { background:#fff7f5; border-color:#f0d7d0; }
    .tournament-detail-redesign .tournament-next-step-cancelled .next-step-icon { background:#f9e3dc; color:#a24c3d; }
    .tournament-detail-redesign .tournament-podium-panel { margin:0 0 20px; padding:22px; background:linear-gradient(135deg,#fffdf7 0%,#fff 48%,#f4fbf7 100%); border:1px solid #e4e0c8; border-radius:14px; box-shadow:0 5px 18px rgba(21,49,34,.06); }
    .tournament-detail-redesign .podium-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:18px; }
    .tournament-detail-redesign .podium-heading-copy { display:grid; gap:4px; }
    .tournament-detail-redesign .podium-heading-title { display:flex; align-items:center; gap:9px; color:#203329; font-size:1.08rem; font-weight:800; }
    .tournament-detail-redesign .podium-heading-title .td-icon { color:#b27a0b; }
    .tournament-detail-redesign .podium-heading-copy p { color:#718078; font-size:.78rem; }
    .tournament-detail-redesign .podium-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; align-items:end; }
    .tournament-detail-redesign .podium-card { position:relative; min-height:126px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; padding:18px 14px 15px; text-align:center; border:1px solid #e4ebe5; border-radius:11px; background:rgba(255,255,255,.86); }
    .tournament-detail-redesign .podium-card:first-child { min-height:148px; border-color:#ead28a; background:linear-gradient(180deg,#fff8dc,#fff); box-shadow:0 7px 18px rgba(178,122,11,.12); }
    .tournament-detail-redesign .podium-medal { display:grid; place-items:center; width:36px; height:36px; border-radius:50%; font-size:.82rem; font-weight:850; }
    .tournament-detail-redesign .podium-card:first-child .podium-medal { width:44px; height:44px; background:#f6d875; color:#765306; box-shadow:0 0 0 5px rgba(230,173,36,.14); }
    .tournament-detail-redesign .podium-card:nth-child(2) .podium-medal { background:#dce3e7; color:#52616a; }
    .tournament-detail-redesign .podium-card:nth-child(3) .podium-medal { background:#e7b28d; color:#75401f; }
    .tournament-detail-redesign .podium-place { color:#718078; font-size:.68rem; font-weight:750; text-transform:uppercase; letter-spacing:.04em; }
    .tournament-detail-redesign .podium-name { max-width:100%; overflow:hidden; color:#203329; font-size:.98rem; font-weight:850; text-overflow:ellipsis; white-space:nowrap; }
    .tournament-detail-redesign .podium-meta { color:#819087; font-size:.7rem; }
    @media (max-width: 820px) {
      .tournament-detail-redesign { width:100%; max-width:none !important; margin-left:0; padding:22px 16px 30px; }
      .tournament-detail-redesign .tournament-detail-hero { align-items:stretch; flex-direction:column; gap:18px; }
      .tournament-detail-redesign .tournament-actions { justify-content:flex-start; max-width:none; flex-wrap:wrap; }
      .tournament-detail-redesign .tournament-actions .tournament-action { flex:1 1 145px; }
      .tournament-detail-redesign .tournament-lifecycle { display:flex; overflow:visible; margin:20px 0 30px; padding:0 2px 3px; min-height:61px; }
      .tournament-detail-redesign .tournament-lifecycle::before, .tournament-detail-redesign .tournament-lifecycle::after { left:16px; right:16px; top:15px; width:auto; }
      .tournament-detail-redesign .tournament-lifecycle::after { right:auto; width:calc((100% - 32px) * var(--progress, 0) / 100); }
      .tournament-detail-redesign .tournament-lifecycle li { display:none; }
      .tournament-detail-redesign .tournament-lifecycle li.is-current, .tournament-detail-redesign .tournament-lifecycle li.is-complete:last-of-type { display:flex; flex:1; }
      .tournament-detail-redesign .tournament-lifecycle::after { content:""; }
      .tournament-detail-redesign .tournament-lifecycle[data-cancelled="true"]::after { display:none; }
      .tournament-detail-redesign .tournament-lifecycle[data-cancelled="false"]::before { right:16px; }
      .tournament-detail-redesign .tournament-lifecycle[data-cancelled="false"]::after { display:block; }
      .tournament-detail-redesign .lifecycle-mobile-count { display:block; margin:-24px 0 16px; color:#8a998f; font-size:.68rem; text-align:right; }
      .tournament-detail-redesign .tournament-lifecycle[data-cancelled="true"] + .lifecycle-mobile-count { color:#a24c3d; }
      .tournament-detail-redesign .tournament-lifecycle[data-cancelled="false"] + .tournament-next-step::before { content:"Bước " attr(data-current) "/ 7"; }
      .tournament-detail-redesign .tournament-overview { grid-template-columns:1fr; }
      .tournament-detail-redesign .podium-list { grid-template-columns:1fr; }
      .tournament-detail-redesign .podium-card, .tournament-detail-redesign .podium-card:first-child { min-height:108px; }
      .tournament-detail-redesign .participant-request-row { align-items:stretch; flex-direction:column; gap:13px; }
      .tournament-detail-redesign #td-participants:not(:has(.participant-empty)) { grid-template-columns:1fr; }
      .tournament-detail-redesign .request-controls { justify-content:flex-start; flex-wrap:wrap; }
      .tournament-detail-redesign .request-status { margin-right:auto; }
      .tournament-detail-redesign .request-meta { white-space:normal; overflow-wrap:anywhere; }
      .tournament-detail-redesign .request-action { min-height:40px; }
      .schedule-heading { align-items:flex-start; flex-direction:column; }
      .tournament-detail-redesign .schedule-table-scroll { overflow-x:auto; }
    }
    /* Final My Bots refinements */
    .bots-page { max-width: none !important; }
    .bots-page .bot-grid { width: 100%; }
    .bots-page .bot-grid .ui-message {
      width: min(100%, 500px);
      min-height: 0;
      box-sizing: border-box;
      margin: 24px auto 0;
      padding: 42px 38px 38px;
      border: 1px solid #dfe9e1;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 8px 24px rgba(30, 43, 34, .045);
      text-align: center;
    }
    .bot-empty-icon {
      display: inline-flex;
      width: 54px;
      height: 54px;
      align-items: center;
      justify-content: center;
      margin-bottom: 18px;
      border-radius: 15px;
      background: #e8f4ed;
      color: #176b50;
    }
    .bot-empty-icon svg {
      width: 28px;
      height: 28px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .bots-page .bot-empty-title { display: block; font-size: 1.2rem; line-height: 1.3; }
    .bots-page .bot-empty-copy { max-width: none; margin: 10px auto 0; color: var(--text-secondary); font-size: .92rem; line-height: 1.6; }
    .bot-empty-hint { display: block; margin-top: 10px; color: var(--text-faint); font-size: .75rem; }
    .bots-page .bot-empty-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; margin-top: 22px; padding: 10px 17px; }
    .bots-page .bot-empty-action .ui-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .bots-page .bot-grid .ui-message {
      display: grid;
      width: 100%;
      max-width: none;
      grid-column: 1 / -1;
      justify-self: stretch;
      min-height: 174px;
      box-sizing: border-box;
      align-content: center;
      justify-items: center;
      gap: 8px;
      margin: 0;
      padding: 32px 28px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
      box-shadow: none;
    }
    .bots-page .bot-empty-icon {
      width: 24px;
      height: 24px;
      margin-bottom: 4px;
      border-radius: 0;
      background: transparent;
      color: #176b4d;
    }
    .bots-page .bot-empty-icon svg { width: 24px; height: 24px; }
    .bots-page .bot-empty-title { margin: 0; font-size: 1.08rem; line-height: 1.35; }
    .bots-page .bot-empty-copy { max-width: 480px; margin: 0; font-size: .88rem; line-height: 1.55; }
    .bots-page .bot-empty-hint { margin: 0; font-size: .75rem; }
    .bots-page .bot-empty-action { margin-top: 14px; }
    .bots-workspace-header { align-items: center; gap: 20px; }
    .bots-workspace-header .workspace-primary-action { flex: 0 0 auto; width: auto; white-space: nowrap; }
    .bot-search { position: relative; width: min(100%, 340px); max-width: 340px; }
    .bot-search .search-icon { position: absolute; top: 50%; left: 13px; width: 25px; height: 25px; color: var(--text-faint); pointer-events: none; transform: translateY(-50%); }
    .bot-search input { padding-left: 40px; }
    .bot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
    .bot-card { display: flex; min-height: 216px; flex-direction: column; padding: 20px; border-radius: 14px; }
    .bot-card-identity { display: flex; min-width: 0; align-items: flex-start; gap: 11px; }
    .bot-card-icon { display: inline-flex; width: 36px; height: 36px; flex: 0 0 auto; align-items: center; justify-content: center; border-radius: 10px; background: #e8f4ed; color: #176b50; }
    .bot-card-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .bot-card-badges { display: flex; max-width: 46%; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
    .bot-card-badge { padding: 4px 7px; border: 1px solid #cce6d7; border-radius: 999px; background: #f1faf4; color: #176b50; font-size: .68rem; font-weight: 750; line-height: 1; white-space: nowrap; }
    .bot-card-badge-muted { border-color: #e0e8e2; background: #f7faf8; color: #66736b; }
    .bot-card-body { flex: 1; padding: 22px 0 18px; }
    .bot-revision-row { display: flex; align-items: center; gap: 10px; }
    .bot-revision-icon { width: 18px; height: 18px; flex: 0 0 auto; color: #176b50; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .bot-revision-copy { display: grid; min-width: 0; gap: 4px; }
    .bot-revision-label { color: var(--text-faint); font-size: .68rem; font-weight: 750; }
    .bot-revision-copy code { overflow: hidden; color: var(--text-secondary); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
    .bot-card-footer { min-height: 40px; padding-top: 14px; }
    .bot-actions { flex-wrap: nowrap; justify-content: flex-end; }
    .bot-action { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; white-space: nowrap; }
    .bot-action .ui-icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    @media (max-width: 1080px) { .bot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
    @media (max-width: 640px) {
      .bots-workspace-header { align-items: stretch; }
      .bots-workspace-header .workspace-primary-action { width: fit-content; }
      .bot-grid { grid-template-columns: 1fr; }
      .bot-card-footer { align-items: center; }
      .bot-actions { width: auto; }
      .bot-action { flex: 0 0 auto; }
      .bots-page .bot-grid .ui-message { width: 100%; margin-top: 18px; padding: 32px 22px 30px; }
    }

    /* Player Dashboard layout consistency */
    .tournaments-page .tournament-grid.tournament-grid-empty {
      width: 100%;
    }
    .tournaments-page .tournament-grid.tournament-grid-empty .ui-message {
      width: 100%;
      max-width: none;
      margin-right: 0;
      margin-left: 0;
    }
    #dashboard.player-dashboard .dashboard-empty,
    #dashboard.player-dashboard .dashboard-bot-empty {
      display: grid;
      width: 100%;
      min-height: 174px;
      box-sizing: border-box;
      align-content: center;
      justify-items: center;
      gap: 8px;
      margin: 0;
      padding: 32px 28px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
      color: #718078;
      text-align: center;
    }
    #dashboard.player-dashboard .dashboard-empty .section-kicker { display: none; }
    #dashboard.player-dashboard .dashboard-empty-icon,
    #dashboard.player-dashboard .dashboard-bot-icon {
      width: 24px;
      height: 24px;
      margin-bottom: 4px;
      color: #176b4d;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    #dashboard.player-dashboard {
      min-height: calc(100vh - 68px);
      background:
        radial-gradient(circle at 24% 8%, rgba(222, 244, 231, .58), transparent 28%),
        radial-gradient(circle at 84% 28%, rgba(231, 246, 237, .5), transparent 32%);
    }
    #dashboard.player-dashboard .dashboard-empty-icon {
      box-sizing: content-box;
      width: 34px;
      height: 34px;
      padding: 17px;
      border-radius: 50%;
      background: #e5f5eb;
    }
    #dashboard.player-dashboard .dashboard-empty h3,
    #dashboard.player-dashboard .dashboard-bot-empty strong {
      margin: 0;
      color: #17231d;
      font-size: 1.08rem;
      line-height: 1.35;
    }
    #dashboard.player-dashboard .dashboard-empty p:not(.section-kicker),
    #dashboard.player-dashboard .dashboard-bot-empty span {
      max-width: 480px;
      margin: 0;
      color: #66736b;
      font-size: .88rem;
      line-height: 1.55;
    }
    #dashboard.player-dashboard .dashboard-bot-list.is-empty .dashboard-bot-empty { min-height: 174px; }
    #dashboard.dashboard-page:not(.player-dashboard) .dashboard-empty {
      min-height: 220px;
      padding: 36px 24px;
      border: 1px solid #dfe7e1;
      border-radius: 12px;
      background: #fff;
    }
    #dashboard.dashboard-page:not(.player-dashboard) .dashboard-empty-icon {
      display: block;
      width: 30px;
      height: 30px;
      margin: 0 auto 12px;
      color: #719481;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.7;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    #dashboard.dashboard-page:not(.player-dashboard) .dashboard-empty h3 { font-size: 1.12rem; }
    #dashboard.dashboard-page:not(.player-dashboard) .dashboard-empty p:not(.section-kicker) { font-size: .9rem; }
    #dashboard.player-dashboard .summary-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      width: 100%;
    }
    #dashboard.player-dashboard #dash-queue-card { display: none; }
    #dashboard.dashboard-page .dashboard-section { width: 100%; }
    #dashboard.dashboard-page .dashboard-empty {
      width: 100%;
      max-width: none;
      box-sizing: border-box;
      margin: 0;
      padding: 34px 28px;
    }
    #dashboard.dashboard-page .dashboard-bot-list.is-empty { grid-template-columns: 1fr; }
    #dashboard.dashboard-page .dashboard-bot-list.is-empty .dashboard-bot-empty {
      width: 100%;
      box-sizing: border-box;
      min-height: 166px;
      justify-content: center;
      padding: 32px 28px;
      border-style: solid;
      border-color: #dfe7e1;
    }
    @media (max-width: 560px) {
      #dashboard.player-dashboard .summary-grid { grid-template-columns: 1fr; }
    }
    @media (min-width: 561px) and (max-width: 900px) {
      #dashboard.player-dashboard .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    /* Full-width Bot Source Workspace */
    .bot-workspace-page {
      width: calc(100% - 232px);
      min-width: 0;
      max-width: none;
      box-sizing: border-box;
      margin: 0 0 0 232px;
      padding: 24px 32px 40px;
    }
    .bot-workspace-page .bot-source-workspace {
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
      margin: 0;
      min-height: calc(100dvh - 132px);
      padding: 24px;
      border-radius: 12px;
    }
    .bot-workspace-breadcrumb { margin-bottom: 20px; }
    .bot-workspace-breadcrumb .breadcrumb-back { display: inline-flex; align-items: center; gap: 7px; }
    .workspace-inline-icon,
    .workspace-file-icon,
    .workspace-revision-icon {
      width: 18px;
      height: 18px;
      flex: 0 0 auto;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .bot-source-header {
      align-items: flex-start;
      flex-wrap: nowrap;
      padding-bottom: 4px;
    }
    .bot-workspace-heading { flex: 1 1 auto; min-width: 0; }
    .bot-workspace-heading h2 { white-space: nowrap; }
    .bot-source-header .workspace-save-action {
      display: inline-flex;
      width: auto;
      min-width: max-content;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 40px;
      padding: 10px 16px;
    }
    .bot-source-header .workspace-save-action .ui-icon {
      width: 16px;
      height: 16px;
      padding: 0;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .bot-source-actions { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
    .bot-source-actions button { width: auto; min-width: max-content; }
    .workspace-guide-action { white-space: nowrap; }
    .bot-guide-modal { width: min(640px, calc(100vw - 32px)); max-height: min(760px, calc(100dvh - 32px)); margin: auto; overflow-y: auto; border: 1px solid #dfe7e1; border-radius: 14px; background: #fff; box-shadow: 0 18px 46px rgba(16, 36, 29, .16); }
    #bot-guide-modal { align-items: center; }
    .bot-guide-modal .modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
    .bot-guide-modal .modal-head h2 { margin: 0; color: #17231d; font-size: 1.45rem; line-height: 1.2; }
    .bot-guide-modal .modal-close { flex: 0 0 auto; }
    .bot-guide-modal .modal-footer { display: flex; justify-content: flex-end; margin-top: 20px; }
    .bot-guide-content { display: grid; gap: 18px; }
    .bot-guide-section { display: grid; gap: 8px; }
    .bot-guide-section h3 { margin: 0; color: #17231d; font-size: 1rem; }
    .bot-guide-section p { margin: 0; color: var(--text-secondary); line-height: 1.55; }
    .bot-guide-section code { padding: 1px 4px; border-radius: 4px; background: var(--surface-soft); color: #176b4d; font: .92em ui-monospace, SFMono-Regular, Consolas, monospace; }
    .bot-guide-runtime { display: grid; gap: 6px; }
    .bot-guide-runtime strong { color: var(--text-primary); font-size: .86rem; }
    .bot-guide-table-wrap { overflow-x: auto; border: 1px solid var(--border-light); border-radius: 8px; }
    .bot-guide-table { width: 100%; border-collapse: collapse; color: var(--text-secondary); font-size: .84rem; }
    .bot-guide-table th, .bot-guide-table td { padding: 9px 11px; border-bottom: 1px solid var(--border-light); text-align: left; white-space: nowrap; }
    .bot-guide-table th { background: var(--surface-soft); color: var(--text-primary); font-weight: 700; }
    .bot-guide-table tr:last-child td { border-bottom: 0; }
    .bot-guide-help { font-size: .88rem; }
    .bot-guide-list { display: grid; gap: 6px; margin: 0; padding-left: 19px; color: var(--text-secondary); line-height: 1.5; }
    .bot-guide-intro { margin: 0; color: var(--text-secondary); line-height: 1.6; }
    .bot-guide-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: guide-step; }
    .bot-guide-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; }
    .bot-guide-step::before { counter-increment: guide-step; content: counter(guide-step); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-soft); color: var(--color-primary); font-weight: 700; }
    .bot-guide-step strong { display: block; margin-bottom: 3px; color: var(--text-primary); }
    .bot-guide-step span { color: var(--text-secondary); line-height: 1.5; }
    .bot-guide-code { margin: 0; padding: 14px 16px; overflow-x: auto; border: 1px solid var(--border-light); border-radius: 8px; background: var(--surface-soft); color: var(--text-primary); font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
    .bot-guide-note { margin: 0; padding: 12px 14px; border-left: 3px solid var(--color-primary); background: var(--surface-soft); color: var(--text-secondary); line-height: 1.5; }
    @media (max-width: 640px) { #bot-guide-modal { align-items: flex-end; } .bot-guide-modal { width: min(100%, 640px); max-height: calc(100dvh - 24px); } }
    .workspace-practice-action { min-height: 40px; padding: 10px 14px; white-space: nowrap; }
    .practice-opponent { display: grid; gap: 3px; flex: 1; min-width: 0; }
    .practice-opponent .field-label { color: var(--text-faint); font-size: .72rem; }
    .practice-opponent strong { color: var(--text-primary); font-size: .9rem; }
    .practice-opponent span:last-child { color: var(--text-faint); font-size: .75rem; }
    .bot-workspace-info-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 180px;
      align-items: start;
      gap: 8px 16px;
      margin-top: 24px;
      padding-top: 20px;
    }
    .workspace-name-field,
    .bot-workspace-info-row .source-runtime-picker { min-width: 0; }
    .bot-workspace-info-row .source-runtime-picker { grid-column: 2; grid-row: 1; flex-basis: auto; width: auto; }
    #bot-sdk-description { grid-column: 2; grid-row: 2; margin: 0; }
    .bot-source-grid {
      grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
      gap: 16px;
      width: 100%;
      min-width: 0;
      margin-top: 24px;
    }
    .bot-editor-panel,
    .bot-revision-panel { min-width: 0; }
    .bot-editor-panel .editor-panel-head { justify-content: flex-start; gap: 8px; }
    .bot-editor-panel .editor-panel-head label { margin-right: auto; }
    .workspace-file-icon { color: #8fb29a; }
    .bot-workspace-page .source-editor {
      width: 100%;
      height: calc(100dvh - 330px);
      min-height: 420px;
      max-height: none;
      box-sizing: border-box;
    }
    .bot-workspace-page .bot-revision-panel {
      min-width: 0;
      padding-left: 16px;
    }
    .bot-revision-heading { justify-content: flex-start; gap: 8px; }
    .bot-revision-heading h3 { margin-right: auto; }
    .workspace-revision-icon { color: #176b4d; }
    .bot-workspace-page .bot-revision-list {
      max-height: calc(100dvh - 360px);
      overflow-y: auto;
    }
    /* Create/edit Bot workspace: compact layout aligned with the source editor reference. */
    .bot-workspace-page .bot-source-workspace { position:relative; padding:52px 16px 16px; border-radius:10px; }
    .bot-workspace-page .bot-workspace-breadcrumb { position:absolute; top:16px; left:16px; right:16px; z-index:2; justify-content:space-between; margin:0; }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back { display:inline-flex; align-items:center; gap:5px; padding:5px 8px; border:1px solid #dfe7e1; border-radius:6px; background:#fff; color:#526259; font-size:.7rem; }
    .bot-workspace-page .bot-workspace-breadcrumb > span:not(.source-workspace-status) { display:none; }
    .bot-workspace-page .source-workspace-status { margin:0; padding:5px 9px; border-radius:999px; background:#f0f2f1; color:#425148; font-size:.67rem; font-weight:700; }
    .bot-workspace-page .bot-source-header { display:flex; flex-direction:column; align-items:stretch; gap:10px; padding:0; }
    .bot-workspace-page .bot-workspace-heading h2 { margin:0; font-size:clamp(1.35rem, 2.2vw, 1.75rem); line-height:1.15; letter-spacing:-.025em; }
    .bot-workspace-page #bot-source-description { margin:6px 0 0; color:#65736a; font-size:.86rem; line-height:1.35; }
    .bot-workspace-page #bot-sdk-description { display:none; }
    .bot-workspace-page .bot-source-actions { order:2; align-self:flex-end; justify-content:flex-end; align-items:stretch; gap:6px; }
    .bot-workspace-page .bot-source-actions button { width:auto; min-width:96px; height:34px; min-height:34px; padding:0 11px; border-radius:6px; font-size:.72rem; }
    .bot-workspace-page .bot-workspace-info-row { grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; margin-top:12px; padding:0; border:0; }
    .bot-workspace-page .workspace-name-field,
    .bot-workspace-page .bot-workspace-info-row .source-runtime-picker { width:auto; min-width:0; }
    .bot-workspace-page .bot-workspace-info-row .source-runtime-picker { grid-column:2; grid-row:1; }
    .bot-workspace-page .bot-source-grid { grid-template-columns:minmax(0,3fr) minmax(150px,1fr); gap:8px; margin-top:12px; padding-top:8px; border-top:1px solid #e4e8e5; }
    .bot-workspace-page .bot-editor-panel { min-width:0; padding:0; }
    .bot-workspace-page .bot-editor-panel .editor-panel-head { min-height:28px; margin:0; padding:8px 8px; border:1px solid #e1e7e2; border-bottom:0; border-radius:7px 7px 0 0; background:#fff; }
    .bot-workspace-page .bot-editor-panel .editor-panel-head label { font-size:.75rem; }
    .bot-workspace-page .bot-editor-panel .editor-filename { order:-1; color:#1b6f4f; font-size:.68rem; }
    .bot-workspace-page .source-tools { display:flex; align-items:center; gap:5px; margin:6px 0; flex-wrap:wrap; }
    .bot-workspace-page .source-tool-button { height:27px; padding:0 8px; border:1px solid #d7e1da; border-radius:5px; background:#fff; color:#526259; font-size:.64rem; cursor:pointer; }
    .bot-workspace-page .source-tool-button:hover { border-color:#176f4f; color:#176f4f; background:#f3faf5; }
    .bot-workspace-page .source-code-layer { position:relative; z-index:0; isolation:isolate; height:calc(100dvh - 365px); min-height:340px; overflow:hidden; background:#111c16; }
    .bot-workspace-page .source-highlight { position:absolute; inset:0; z-index:1; box-sizing:border-box; width:max-content; min-width:100%; margin:0; padding:10px; overflow:visible; white-space:pre; color:#dceee1; background:#111c16; font: .72rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing:normal; tab-size:2; pointer-events:none; }
    .bot-workspace-page .bot-revision-panel { padding:0 0 0 10px; border-left:1px solid #e1e7e2; }
    .bot-workspace-page .bot-revision-heading { min-height:28px; margin:0; padding:0 8px; border:1px solid #e1e7e2; border-bottom:0; border-radius:7px 7px 0 0; }
    .bot-workspace-page .bot-revision-heading h3 { font-size:.75rem; }
    .bot-workspace-page .bot-revision-heading .bots-count { font-size:.67rem; }
    .bot-workspace-page #bot-sdk-reference { display:none; }
    .bot-workspace-page .bot-revision-list { min-height:340px; max-height:calc(100dvh - 365px); align-content:start; margin:0; padding:0 8px 8px; border:1px solid #e1e7e2; border-top:0; border-radius:0 0 7px 7px; }
    .bot-workspace-page .bot-revision-empty { display:flex; min-height:300px; flex-direction:column; align-items:center; justify-content:center; gap:7px; color:#87938b; text-align:center; }
    .bot-workspace-page .bot-revision-empty-icon { width:25px; height:25px; color:#9aa69e; fill:none; stroke:currentColor; stroke-width:1.7; }
    .bot-workspace-page .bot-revision-empty strong { color:#394a40; font-size:.78rem; }
    .bot-workspace-page .bot-revision-empty span { max-width:130px; color:#8b968f; font-size:.68rem; line-height:1.4; }
    .bot-workspace-page .bot-revision-item { align-self:start; gap:4px; padding:7px 8px; border-radius:7px; }
    .bot-workspace-page .bot-revision-meta { gap:5px; font-size:.67rem; line-height:1.25; }
    .bot-workspace-page .bot-revision-meta strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .bot-workspace-page .bot-revision-meta span { flex:0 0 auto; color:#87938b; font-size:.6rem; white-space:nowrap; }
    .bot-workspace-page .bot-revision-technical { font-size:.62rem; line-height:1.3; }
    .bot-workspace-page .bot-revision-technical summary { font-size:.64rem; }
    .bot-workspace-page .bot-revision-technical[open] summary { margin-bottom:3px; }
    .bot-workspace-page .bot-revision-digest { font-size:.58rem; }
    .bot-workspace-page .bot-revision-actions { align-items:center; gap:4px; }
    .bot-workspace-page .bot-revision-actions .bot-action { min-height:26px; padding:4px 7px; border-radius:5px; font-size:.62rem; }
    @media (max-width:680px) {
      .bot-workspace-page .bot-source-grid { grid-template-columns:1fr; }
      .bot-workspace-page .bot-revision-panel { padding:12px 0 0; border-top:1px solid #e1e7e2; border-left:0; }
      .bot-workspace-page .bot-revision-list { max-height:420px; }
      .bot-workspace-page .source-editor { height:420px; }
    }
    @media (max-width: 900px) {
      .bot-workspace-page {
        width: 100%;
        margin-left: 0;
        padding: 20px 24px 32px;
      }
      .bot-workspace-page .bot-source-workspace { min-height: auto; padding: 20px; }
      .bot-source-header { flex-direction: column; align-items: stretch; }
      .bot-workspace-heading h2 { white-space: normal; }
      .bot-source-header .workspace-save-action { width: fit-content; }
      .bot-source-actions { width: fit-content; flex-wrap: wrap; }
      .bot-workspace-info-row { grid-template-columns: 1fr; }
      .bot-workspace-info-row .source-runtime-picker,
      #bot-sdk-description { grid-column: 1; grid-row: auto; }
      .bot-source-grid { grid-template-columns: 1fr; }
      .bot-workspace-page .bot-revision-panel { padding-top: 20px; padding-left: 0; border-top: 1px solid var(--border-light); border-left: 0; }
      .bot-workspace-page .bot-revision-list { max-height: 420px; }
      .bot-workspace-page .source-editor { height: 420px; }
    }
    @media (max-width: 560px) {
      .bot-workspace-page { padding: 16px 16px 24px; }
      .bot-workspace-page .bot-source-workspace { padding: 52px 16px 18px; }
      .bot-source-header .workspace-save-action { width: 100%; }
      .bot-source-actions { width: 100%; align-self:stretch; flex-direction: column-reverse; align-items: stretch; }
      .bot-workspace-page .bot-source-actions button { width: 100%; }
      .bot-workspace-page .source-editor { min-height: 360px; height: 420px; }
    }
    @media (min-width: 561px) and (max-width: 900px) {
      .bot-workspace-page .bot-source-workspace { padding:52px 20px 20px; }
      .bot-workspace-page .bot-workspace-info-row { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
      .bot-workspace-page .bot-workspace-info-row .source-runtime-picker { grid-column:2; grid-row:1; }
      .bot-workspace-page .bot-source-grid { grid-template-columns:minmax(0,3fr) minmax(150px,1fr); }
      .bot-workspace-page .bot-revision-panel { padding:0 0 0 10px; border-top:0; border-left:1px solid #e1e7e2; }
      .bot-workspace-page .bot-revision-list { max-height:calc(100dvh - 365px); }
      .bot-workspace-page .source-editor { height:calc(100dvh - 365px); }
    }
    /* Test Run Modal: scoped layout corrections. */
    .practice-dialog {
      width: min(620px, calc(100vw - 32px));
      max-width: none;
      box-sizing: border-box;
      padding: 24px;
      border: 1px solid #dbe9df;
      border-radius: 18px;
      background: linear-gradient(145deg, #ffffff 0%, #f5faf7 100%);
      box-shadow: 0 24px 70px rgba(25, 65, 43, .18);
      max-height: calc(100dvh - 32px);
      overflow-x: hidden;
      overflow-y: auto;
    }
    .practice-dialog .modal-head {
      align-items: flex-start;
      margin-bottom: 4px;
    }
    .practice-dialog .modal-head h4 {
      margin: 0;
      font-size: 1.35rem;
      letter-spacing: -.02em;
    }
    .practice-dialog #practice-description {
      max-width: 500px;
      margin: 0 0 16px;
      color: #718179;
      font-size: .84rem;
      line-height: 1.55;
    }
    .practice-dialog .practice-revision-meta {
      display: block;
      margin: 0;
      padding: 13px 15px;
      border: 1px solid #cfe5d6;
      border-radius: 12px;
      background: #edf8f1;
      color: #176b50;
      font-size: .78rem;
      font-weight: 700;
      line-height: 1.5;
      overflow-wrap: anywhere;
    }
    .practice-dialog .practice-revision-meta::before {
      content: 'PHIÊN BẢN ĐANG KIỂM TRA';
      display: block;
      margin-bottom: 3px;
      color: #6d8d7a;
      font-size: .63rem;
      font-weight: 850;
      letter-spacing: .1em;
    }
    .practice-dialog .practice-toolbar {
      display: block;
      width: 100%;
      min-width: 0;
      margin: 12px 0 14px;
      padding: 16px;
      box-sizing: border-box;
      border: 1px solid #e0e9e3;
      border-radius: 14px;
      background: rgba(255, 255, 255, .78);
    }
    .practice-dialog .practice-opponent {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      width: 100%;
      min-width: 0;
    }
    .practice-dialog .practice-opponent-icon {
      width: 22px;
      height: 22px;
      flex: 0 0 22px;
      margin-top: 1px;
      color: #176b4d;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .practice-dialog .practice-opponent-copy {
      display: grid;
      gap: 3px;
      min-width: 0;
      flex: 1 1 auto;
    }
    .practice-dialog .practice-opponent-copy .field-label {
      color: var(--text-faint);
      font-size: .7rem;
      font-weight: 800;
      letter-spacing: .08em;
    }
    .practice-dialog .practice-opponent-copy strong {
      display: block;
      color: var(--text-primary);
      font-size: .92rem;
      line-height: 1.35;
      overflow-wrap: break-word;
    }
    .practice-dialog .practice-opponent-copy span:last-child {
      color: var(--text-faint);
      font-size: .76rem;
      line-height: 1.45;
      overflow-wrap: anywhere;
    }
    .practice-dialog .practice-opponent::after {
      content: 'SANDBOX';
      align-self: flex-start;
      padding: 5px 8px;
      border-radius: 999px;
      background: #e8f4ec;
      color: #176b50;
      font-size: .6rem;
      font-weight: 850;
      letter-spacing: .08em;
    }
    .practice-dialog .practice-status {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 22px;
      margin: 12px 2px 0;
      color: #5f7067;
      font-size: .8rem;
      font-weight: 650;
    }
    .practice-dialog .practice-status::before {
      content: '';
      width: 8px;
      height: 8px;
      flex: 0 0 8px;
      border-radius: 50%;
      background: #e3a62b;
      box-shadow: 0 0 0 4px rgba(227, 166, 43, .14);
    }
    .practice-dialog .practice-actions {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      gap: 10px;
      margin-top: 20px;
      padding-top: 16px;
      border-top: 1px solid var(--border-light);
    }
    .practice-dialog .practice-actions button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      width: auto;
      min-width: 96px;
      flex: 0 0 auto;
    }
    .practice-dialog .practice-actions .ui-icon {
      width: 25px;
      height: 25px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .practice-dialog .practice-replay-toolbar {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px 12px;
      margin: 14px 0 16px;
    }
    .practice-dialog .practice-replay-controls {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      min-width: 0;
    }
    .practice-dialog .practice-replay-controls button {
      width: 34px;
      height: 34px;
      min-width: 34px;
      padding: 0;
      flex: 0 0 34px;
    }
    .practice-dialog .practice-replay-controls .replay-play {
      width: 76px;
      flex-basis: 76px;
      gap: 5px;
    }
    .practice-dialog .practice-replay-controls .replay-step { margin-left: auto; white-space: nowrap; }
    .practice-dialog .practice-replay-toolbar > input { grid-column: 1 / -1; width: 100%; min-width: 0; }
    .practice-dialog .practice-replay-speed { justify-self: end; color: var(--text-faint); font-size: .74rem; }
    .practice-dialog .practice-replay-speed select { margin-left: 6px; padding: 5px 8px; border: 1px solid var(--border-light); border-radius: 7px; background: #fff; color: var(--text-primary); }
    .practice-dialog .practice-move-history { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }
    .practice-dialog .practice-move-history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
    .practice-dialog .practice-move-history-head h6 { margin: 0; color: var(--text-primary); font-size: .8rem; }
    .practice-dialog .practice-move-history-head span { color: var(--text-faint); font-size: .72rem; }
    .practice-dialog .practice-move-history-list { display: grid; gap: 5px; max-height: 180px; margin-top: 9px; overflow-y: auto; }
    .practice-dialog .practice-move-history-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid transparent; border-radius: 7px; background: #f7faf8; color: var(--text-secondary); font-size: .72rem; text-align: left; }
    .practice-dialog button.practice-move-history-item { cursor: pointer; }
    .practice-dialog .practice-move-history-item.active { border-color: #a9d4b9; background: #eaf6ed; color: #125d39; }
    .practice-dialog .practice-move-history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .practice-dialog .practice-move-history-empty { margin: 0; color: var(--text-faint); font-size: .75rem; }
    @media (max-width: 560px) {
      .practice-dialog {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
        padding: 22px 18px;
      }
      .practice-dialog .practice-actions {
        flex-direction: column-reverse;
        align-items: stretch;
      }
      .practice-dialog .practice-actions button { width: 100%; }
      .practice-dialog .practice-replay-toolbar { grid-template-columns: 1fr; }
      .practice-dialog .practice-replay-controls { justify-content: center; }
      .practice-dialog .practice-replay-speed { justify-self: start; }
    }

    /* Replay workspace: compact match summary with balanced board/history panels. */
    #replay-view:not(.live-match-view) {
      padding-top: 26px;
      background: radial-gradient(circle at 28% 4%, rgba(226, 244, 233, .48), transparent 30%);
    }
    #replay-view .replay-match-header {
      display: block;
      padding: 18px 20px;
      border: 1px solid #dce6df;
      border-radius: 13px;
      background: #fff;
      box-shadow: 0 8px 24px rgba(23, 35, 29, .035);
    }
    #replay-view .replay-heading-row,
    #replay-view .replay-header-subline {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      min-width: 0;
      gap: 16px;
    }
    #replay-view .replay-heading-row > div {
      display: block;
      min-width: 0;
    }
    #replay-view .replay-heading-row .section-kicker {
      margin: 0 0 7px;
      color: #7a8880;
      font-size: .66rem;
      font-weight: 750;
      letter-spacing: .08em;
    }
    #replay-view .replay-heading-row h2 {
      margin: 0;
      font-size: 1.32rem;
      letter-spacing: -.025em;
    }
    #replay-view .replay-status-badge {
      display: inline-flex;
      min-height: 25px;
      align-items: center;
      padding: 5px 10px;
      border-radius: 999px;
      background: #def4e6;
      color: #137348;
      font-size: .69rem;
      font-weight: 750;
      white-space: nowrap;
    }
    #replay-view .replay-header-subline {
      margin-top: 14px;
      color: #6c7971;
      font-size: .73rem;
    }
    #replay-view .replay-back-link {
      display: inline-flex;
      width: auto;
      min-height: 0;
      align-items: center;
      gap: 6px;
      margin: 0;
      padding: 0;
      border: 0;
      background: transparent;
      color: #526159;
      font: inherit;
      cursor: pointer;
    }
    #replay-view .replay-back-link:hover { color: #176b4d; }
    #replay-view .replay-back-link .ui-icon { width: 25px; height: 25px; }

    /* Shared back navigation: keep workspace, tournament and replay exits
       visually consistent while leaving modal close buttons untouched. */
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back,
    #bot-workspace-back,
    #back-to-tournaments,
    #replay-view .replay-back-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 34px;
      width: auto;
      margin: 0;
      padding: 7px 11px;
      border: 1px solid #d7e4da;
      border-radius: 9px;
      background: #fff;
      color: #526159;
      font: inherit;
      font-size: .76rem;
      font-weight: 700;
      line-height: 1.2;
      text-decoration: none;
      cursor: pointer;
      transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
    }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back:hover,
    #bot-workspace-back:hover,
    #back-to-tournaments:hover,
    #replay-view .replay-back-link:hover {
      border-color: #9fc7ab;
      background: #f1faf4;
      color: #176b50;
      box-shadow: 0 3px 10px rgba(23, 107, 80, .08);
    }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back:focus-visible,
    #bot-workspace-back:focus-visible,
    #back-to-tournaments:focus-visible,
    #replay-view .replay-back-link:focus-visible {
      outline: 3px solid rgba(22, 128, 60, .18);
      outline-offset: 2px;
    }
    .bot-workspace-page .bot-workspace-breadcrumb .breadcrumb-back .workspace-inline-icon,
    #bot-workspace-back .workspace-inline-icon,
    #back-to-tournaments .td-icon,
    #replay-view .replay-back-link .ui-icon {
      width: 25px;
      height: 25px;
      flex: 0 0 17px;
    }
    #back-to-tournaments .breadcrumb-separator,
    #back-to-tournaments #td-breadcrumb-name {
      display: none;
    }

    /* Keep the source workspace breadcrumb in normal flow so the back button
       can never cover the workspace heading. */
    .bot-workspace-page .bot-source-workspace {
      padding: 16px;
    }
    .bot-workspace-page .bot-workspace-breadcrumb {
      position: static;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
      margin: 0 0 18px;
    }
    .bot-workspace-page .bot-workspace-breadcrumb > span:not(.source-workspace-status) {
      display: inline;
      color: #a0ada5;
      font-size: .78rem;
    }
    .bot-workspace-page .bot-workspace-breadcrumb .source-workspace-status {
      margin-left: auto;
    }
    #replay-view .replay-series-card {
      margin-top: 14px;
      padding: 14px 18px 12px;
      border: 1px solid #dce6df;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 7px 20px rgba(23, 35, 29, .03);
    }
    #replay-view .replay-series-card .replay-players {
      display: flex;
      width: min(100%, 560px);
      align-items: center;
      justify-content: center;
      gap: 12px;
      margin: 0 auto;
      padding: 0;
      border: 0;
    }
    #replay-view .replay-series-card .replay-player-identity {
      display: grid;
      flex: 1 1 0;
      min-width: 0;
      padding: 6px 10px;
      border: 0;
      background: transparent;
      box-shadow: none;
    }
    #replay-view .replay-series-card .replay-player-a-label {
      border: 2px solid #dce6df;
      border-left-width: 4px;
      border-radius: 10px;
      background: #fbfdfb;
    }
    #replay-view .replay-series-card .replay-player-b-label {
      border: 2px solid #dce6df;
      border-right-width: 4px;
      border-radius: 10px;
      background: #fbfdfb;
    }
    #replay-view .replay-series-card .replay-player-identity.is-current-side-a {
      border-color: var(--color-player-a);
      background: rgba(29, 78, 216, .045);
    }
    #replay-view .replay-series-card .replay-player-identity.is-current-side-b {
      border-color: var(--color-player-b);
      background: rgba(194, 65, 12, .045);
    }
    #replay-view .replay-series-card .replay-player-name {
      font-size: .9rem;
      font-weight: 750;
    }
    #replay-view .replay-series-card .replay-player-score {
      min-width: 38px;
      height: 38px;
      border: 0;
      border-radius: 9px;
      background: #f2f6f3;
      box-shadow: none;
      font-size: 1.18rem;
    }
    #replay-view .replay-series-card .replay-versus {
      color: #25342c;
      font-size: 1rem;
      font-weight: 800;
    }
    #replay-series-slot:empty { display: none; }
    #replay-series-slot #replay-series-controls {
      justify-content: center;
      width: fit-content;
      max-width: 100%;
      margin: 10px auto 0;
      padding: 0;
      border: 0;
      background: transparent;
    }
    #replay-series-slot #replay-series-controls::before { display: none; }
    #replay-series-slot #replay-series-controls .secondary-btn {
      min-width: 62px;
      padding: 8px 12px;
      text-align: center;
    }
    #replay-view .replay-layout {
      grid-template-columns: minmax(0, 1.55fr) minmax(280px, .65fr);
      gap: 16px;
      margin-top: 14px;
      align-items: stretch;
    }
    #replay-view .replay-board-panel,
    #replay-view .replay-timeline-panel {
      padding: 16px;
      border: 1px solid #dce6df;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 7px 20px rgba(23, 35, 29, .03);
    }
    #replay-view .replay-panel-heading {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }
    #replay-view .replay-panel-heading h3 {
      margin: 0;
      color: #1b2921;
      font-size: .95rem;
      letter-spacing: -.01em;
    }
    #replay-view .replay-panel-count {
      display: inline-flex;
      min-height: 24px;
      align-items: center;
      padding: 4px 9px;
      border-radius: 999px;
      background: #f0f3f1;
      color: #3f4d45;
      font-size: .68rem;
      font-weight: 700;
      white-space: nowrap;
    }
    #replay-view .replay-board-wrap {
      width: min(100%, 520px);
      max-width: 520px;
      margin: 0 auto 10px;
    }
    #replay-view .replay-current-move {
      min-height: 0;
      margin: 8px 0 4px;
      padding: 7px 10px;
      border-left: 3px solid #b8c8bc;
      border-radius: 5px;
      background: #f7faf8;
      color: #68766e;
      font-size: .72rem;
    }
    #replay-view .replay-current-move-a {
      border-left-color: #7eaef0;
      background: #f1f6ff;
      color: #245fae;
    }
    #replay-view .replay-current-move-b {
      border-left-color: #ed9a75;
      background: #fff5ef;
      color: #a7431c;
    }
    #replay-view .replay-scrubber-label { margin-top: 8px; }
    #replay-view .replay-controls {
      position: relative;
      justify-content: center;
      padding-top: 12px;
    }
    #replay-view .replay-play {
      flex-basis: 40px;
      min-width: 40px;
    }
    #replay-view .replay-play .replay-control-label { display: none; }
    #replay-view .replay-speed-label {
      position: absolute;
      right: 0;
      margin-left: 0;
    }
    #replay-view .replay-timeline-panel h3::after { display: none; content: none; }
    #replay-view:not(.live-match-view) .replay-selected-move { display: none; }
    #replay-view .replay-timeline {
      max-height: 430px;
      margin-top: 0;
      gap: 9px;
    }
    #replay-view .replay-move {
      display: grid;
      grid-template-columns: auto auto minmax(0, 1fr);
      align-items: center;
      gap: 8px;
      min-height: 48px;
      padding: 12px;
      border: 1px solid #dfe6e1;
      border-radius: 8px;
      background: #fff;
    }
    #replay-view .replay-move::before { display: none; }
    #replay-view .replay-move-number {
      color: #7d8982;
      font-size: .68rem;
      font-variant-numeric: tabular-nums;
    }
    #replay-view .replay-move-player {
      max-width: 132px;
      overflow: hidden;
      padding: 4px 8px;
      border-radius: 999px;
      font-size: .68rem;
      font-weight: 750;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #replay-view .replay-move-player-a {
      background: #e5f0ff;
      color: #2563c7;
    }
    #replay-view .replay-move-player-b {
      background: #ffebe2;
      color: #c34b1b;
    }
    #replay-view .replay-move-path {
      min-width: 0;
      overflow: hidden;
      color: #27362e;
      font-size: .76rem;
      font-variant-numeric: tabular-nums;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #replay-view .replay-move-side-a { border-left: 3px solid #7eaef0; }
    #replay-view .replay-move-side-b { border-left: 3px solid #ed9a75; }
    #replay-view .replay-details {
      grid-template-columns: 1fr;
      gap: 2px;
      margin-top: 16px;
      padding-top: 14px;
      border-top: 1px solid #e4ebe6;
    }
    #replay-view .replay-detail {
      display: grid;
      grid-template-columns: 88px minmax(0, 1fr);
      align-items: center;
      gap: 12px;
      padding: 8px 0;
      border: 0;
      background: transparent;
    }
    #replay-view .replay-detail small {
      margin: 0;
      text-transform: none;
      letter-spacing: 0;
    }
    @media (max-width: 900px) {
      #replay-view .replay-layout { grid-template-columns: 1fr; }
      #replay-view .replay-board-wrap { width: min(100%, 580px); max-width: 580px; }
    }
    @media (max-width: 600px) {
      #replay-view .replay-heading-row,
      #replay-view .replay-header-subline { align-items: flex-start; }
      #replay-view .replay-series-card .replay-players { gap: 4px; }
      #replay-view .replay-series-card .replay-player-identity { padding: 5px; }
      #replay-view .replay-series-card .replay-player-bot,
      #replay-view .replay-series-card .replay-player-pieces { display: none; }
      #replay-view .replay-speed-label {
        position: static;
        width: 100%;
        margin: 4px 0 0;
      }
    }

    /* Replay player cards: equal geometry and side-specific colors. */
    #replay-view .replay-series-card .replay-player-a-label,
    #replay-view .replay-series-card .replay-player-b-label {
      align-self: stretch;
      flex: 1 1 0;
      min-width: 0;
      min-height: 86px;
      box-sizing: border-box;
    }
    #replay-view .replay-series-card .replay-player-a-label {
      border-color: var(--color-player-a);
      background: rgba(29, 78, 216, .045);
    }
    #replay-view .replay-series-card .replay-player-b-label {
      border-color: var(--color-player-b);
      background: rgba(194, 65, 12, .045);
    }
    #replay-view .replay-piece.replay-player-a,
    #replay-view .replay-series-card .replay-player-a-label .replay-count-icon {
      background: var(--color-player-a);
    }
    #replay-view .replay-piece.replay-player-b,
    #replay-view .replay-series-card .replay-player-b-label .replay-count-icon {
      background: var(--color-player-b);
    }
    #replay-view .replay-series-card .replay-player-a-label.is-current-side-a .replay-count-icon {
      background: var(--color-player-a);
    }
    #replay-view .replay-series-card .replay-player-a-label.is-current-side-b .replay-count-icon {
      background: var(--color-player-b);
    }
    #replay-view .replay-series-card .replay-player-b-label.is-current-side-a .replay-count-icon {
      background: var(--color-player-a);
    }
    #replay-view .replay-series-card .replay-player-b-label.is-current-side-b .replay-count-icon {
      background: var(--color-player-b);
    }

    #replay-view .replay-board-wrap {
      --replay-coordinate-width: 26px;
    }
    #replay-view .coord-header {
      box-sizing: border-box;
      width: calc(100% - var(--replay-coordinate-width) - 2px);
      margin-left: calc(var(--replay-coordinate-width) + 2px);
      padding-inline: 0;
    }
    #replay-view .coord-header .coord {
      width: auto;
      min-width: 0;
      box-sizing: border-box;
    }
    #replay-view .replay-board-row {
      grid-template-columns: var(--replay-coordinate-width) minmax(0, 1fr);
    }
    #replay-view .coord-side {
      box-sizing: border-box;
      padding-block: 2px;
    }
    #replay-view .coord-side .coord {
      width: auto;
      min-width: 0;
      box-sizing: border-box;
    }
  
