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

:root {
  --bg: #09090b;
  --surface: #131316;
  --surface2: #1a1a1f;
  /* Default (neutral) outlines. Team color outline is handled separately via --team-glow. */
  --border: #34343d;
  --text: #fff;
  --text-dim: #71717a;
  --accent: #3b82f6;
  --green: #22c55e;
  --gold: #facc15;
  --red: #ef4444;
  /* Consistent control sizing (matches header name box) */
  --namebox-w: 160px;
  /* Team theme (set dynamically) */
  --team-accent: transparent;
  --team-glow: rgba(59,130,246,0);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  position: relative;
}

/* Subtle team glow frame */
body.tournament.has-team-color::after{
  content:"";
  position: fixed;
  /* Hug the viewport edges with squared corners */
  inset: 1px;
  border-radius: 0px;
  /* Brighter team-colored outline */
  border: 2px solid var(--team-glow);
  box-shadow: 0 0 28px var(--team-glow);
  pointer-events:none;
  z-index: 998;
  opacity: 0.72;
}

/* Team accent text (only when you're on a team) */
body.tournament.has-team-color .team-accent{ color: var(--team-accent); }
body:not(.tournament) .team-accent{ color: var(--text-dim); }

/* Show team header line only while in Tournament */
body:not(.tournament) .header-team-line{ display:none !important; }

/* Tournament Home should not show the name/logout card (name lives in header + launch screen) */
body.tournament #panel-home #name-card{ display:none !important; }

/* In Tournament mode, the Play tab should not offer Quick Play selection */
body.tournament #play-mode-select{ display:none !important; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== DESKTOP ==================== */
@media (min-width: 769px) {
  /* On desktop we use a sleek top tab bar (not the mobile bottom tabs) */
  .mobile-tabs { display: none; }

  .desktop-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .desktop-tabs .tab {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-dim);
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
  }

  .desktop-tabs .tab:hover {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
  }

  .desktop-tabs .tab.active {
    background: rgba(59,130,246,0.14);
    border-color: rgba(59,130,246,0.35);
    color: var(--text);
  }

  .mobile-header {
    display: none !important;
  }

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

  .logo {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    cursor: pointer;
    user-select: none;
  }

  /* (header-center removed for desktop) */

  .prize-badge {
    background: var(--gold);
    color: #000;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
  }

  .main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg);
  }

  .panel {
    position: absolute;
    inset: 0;
    display: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
  }

  .panel.active {
    display: block;
  }

  .panel-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 28px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;

  }
  /* Info Panel */
  .panel-info {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .panel-info .panel-inner {
    text-align: center;
    justify-content: center;
    align-items: center;
  }

  .panel-info h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
  }

  .subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 24px;
  }

  .spots-display {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 40px;
    margin-bottom: 24px;
  }

  .spots-number {
    font-size: 52px;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
  }

  .spots-label {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 4px;
  }

  .info-stats {
    display: flex;
    gap: 24px;
  }

  .info-stat {
    text-align: center;
  }

  .info-stat .val {
    display: block;
    font-size: 24px;
    font-weight: 600;
  }

  .info-stat .lbl {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  /* Register Panel */
  .panel-register h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
  }

  .reg-form {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 13px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
  }

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

  .input::placeholder {
    color: var(--text-dim);
  }

  .players-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    overflow-y: auto;
  }

  .player-input {
    display: grid;
    grid-template-columns: 28px 1fr 1fr;
    gap: 8px;
    align-items: center;
    background: var(--surface);
    padding: 10px;
    border-radius: 8px;
  }

  .player-num {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
  }

  .player-input .input {
    margin-bottom: 0;
    padding: 10px 12px;
  }

  .btn-submit {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
  }

  .btn-submit:hover {
    opacity: 0.9;
  }

  .btn-submit:disabled {
    background: var(--surface2);
    color: var(--text-dim);
    cursor: not-allowed;
  }

  /* Teams Panel */
  .panel-teams h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
  }

  .panel-teams h2 span {
    color: var(--accent);
  }

  .teams-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .team-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
  }

  .team-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
  }

  .team-card-header h3 {
    font-size: 15px;
    font-weight: 600;
  }

  .team-slot {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
  }

  .team-players {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .player-row {
    display: flex;
    justify-content: space-between;
    background: var(--surface2);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
  }

  .player-row .discord {
    color: var(--text-dim);
  }

  .player-row { align-items: center; gap: 10px; }
  .player-left { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-width: 0; }
  .player-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .icon-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .icon-btn:hover { filter: brightness(1.1); }
  .icon-btn.danger {
    border-color: rgba(239,68,68,0.45);
    background: rgba(239,68,68,0.12);
    color: var(--text);
  }

  .team-name-wrap { display: flex; align-items: center; min-width: 0; }
  .team-name.editable { cursor: text; border-bottom: 1px dashed rgba(255,255,255,0.25); }
  .team-name-input { max-width: 260px; height: 34px; padding: 6px 10px; font-weight: 800; }

  .team-owner-controls { margin-top: 14px; }
  .owner-actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .team-card.my-team {
    position: relative;
    overflow: visible;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 10px 30px rgba(0,0,0,0.25);
  }

  .empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 13px;
  }

  .error-box {
    background: rgba(239,68,68,0.1);
    border: 1px solid var(--red);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
  }

  .error-box ul {
    list-style: none;
    color: #fca5a5;
    font-size: 13px;
  }

  .closed-msg {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    color: var(--text-dim);
  }
}

/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  .app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .desktop-tabs {
    display: none;
  }

  .main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
  }

  .panel {
    position: absolute;
    inset: 0;
    display: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .panel.active {
    display: block;
  }

  .panel-inner {
    padding: 20px;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
    min-height: 100%;
    display: flex;
    flex-direction: column;
  }

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

  .mobile-header .logo {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 2px;
  }

  .mobile-header .prize-badge {
    background: var(--gold);
    color: #000;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
  }

  /* Info Panel Mobile */
  .panel-info .panel-inner {
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  .panel-info h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
  }

  .subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 28px;
  }

  .spots-display {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px 48px;
    margin-bottom: 28px;
  }

  .spots-number {
    font-size: 58px;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
  }

  .spots-label {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 4px;
  }

  .info-stats {
    display: flex;
    gap: 32px;
  }

  .info-stat {
    text-align: center;
  }

  .info-stat .val {
    display: block;
    font-size: 22px;
    font-weight: 600;
  }

  .info-stat .lbl {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  /* Register Panel Mobile */
  .panel-register h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
  }

  .reg-form {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

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

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

  .input::placeholder {
    color: var(--text-dim);
  }

  .players-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .player-input {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--surface);
    padding: 12px;
    border-radius: 10px;
  }

  .player-num {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .player-input .input {
    flex: 1;
    min-width: calc(50% - 24px);
    margin-bottom: 0;
    padding: 12px;
  }

  .btn-submit {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: auto;
  }

  .btn-submit:disabled {
    background: var(--surface2);
    color: var(--text-dim);
  }

  /* Teams Panel Mobile */
  .panel-teams h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
  }

  .panel-teams h2 span {
    color: var(--accent);
  }

  .teams-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .team-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
  }

  .team-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }

  .team-card-header h3 {
    font-size: 16px;
    font-weight: 600;
  }

  .team-slot {
    background: var(--accent);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
  }

  .team-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .player-row {
    display: flex;
    justify-content: space-between;
    background: var(--surface2);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
  }

  .player-row .discord {
    color: var(--text-dim);
  }

  .empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
  }

  .error-box {
    background: rgba(239,68,68,0.1);
    border: 1px solid var(--red);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
  }

  .error-box ul {
    list-style: none;
    color: #fca5a5;
    font-size: 14px;
  }

  .closed-msg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 18px;
  }

  /* Mobile Tabs */
  .mobile-tabs {
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
  }

  .tab svg {
    width: 22px;
    height: 22px;
  }

  .tab span {
    font-size: 11px;
    font-weight: 500;
  }

  .tab.active {
    color: var(--accent);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}


/* ==================== TEAM FLOW UI ==================== */
.stack { display: flex; flex-direction: column; gap: 12px; }

.accordion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  user-select: none;
}

.accordion summary::-webkit-details-marker { display: none; }

.pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 700;
}

.pill.pending {
  color: var(--gold);
  border-color: rgba(250, 204, 21, 0.35);
}

.manage-note {
  padding: 0 14px 12px 14px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
}

.form { padding: 0 14px 14px 14px; }

.form-grid { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }

/* Color picker rows */
.color-picker-row{
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-color-row{
  margin-top: 10px;
  padding: 10px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.team-color-row.readonly{ opacity: 0.85; }
.team-color-row.readonly .team-color-label::after{ content: " (view only)"; font-weight: 600; color: var(--text-dim); }

.team-color-label{
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}

.color-input, .team-color-input{
  appearance: none;
  width: 42px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper, .team-color-input::-webkit-color-swatch-wrapper{
  padding: 0;
  border-radius: 10px;
}

.color-input::-webkit-color-swatch, .team-color-input::-webkit-color-swatch{
  border: none;
  border-radius: 10px;
}

.label { color: var(--text-dim); font-size: 12px; font-weight: 700; letter-spacing: 0.2px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.hint { color: var(--text-dim); font-size: 13px; line-height: 1.3; }
.hint.ok { color: var(--green); }
.hint.error { color: #f87171; }

.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

.btn.primary {
  background: var(--accent);
  border-color: rgba(59, 130, 246, 0.35);
}

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

.btn.small {
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
}

.manage-area { padding: 0 14px 14px 14px; }

.manage-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.manage-title {
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.manage-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }

.req-list { display: flex; flex-direction: column; gap: 10px; }

.req-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.req-name { font-weight: 800; }
.req-discord { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.req-actions { display: flex; gap: 8px; }

/* Team list accordion */
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
}

.team-details summary { list-style: none; }
.team-details summary::-webkit-details-marker { display: none; }

.team-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
}

.team-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.team-rank { color: var(--text-dim); font-weight: 800; }
.team-name { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-right { display: flex; align-items: center; gap: 10px; }
.meta { color: var(--text-dim); font-size: 13px; font-weight: 800; }

.team-body {
  padding: 0 14px 14px 14px;
  border-top: 1px solid var(--border);
}

.team-section-title {
  margin-top: 12px;
  margin-bottom: 8px;
  font-weight: 900;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.team-footnote { margin-top: 10px; color: var(--text-dim); font-size: 13px; }

.subtitle.small { font-size: 13px; margin-top: 6px; }

/* ==================== FIRST-LOAD CHOOSER + STATUS ==================== */
.status-card {
  background: rgba(59,130,246,0.10);
  border: 1px solid rgba(59,130,246,0.28);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-title {
  font-weight: 900;
  font-size: 14px;
}

.status-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

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

.mode-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}

.mode-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.mode-title {
  font-weight: 900;
  font-size: 18px;
  margin-bottom: 6px;
}

.mode-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 14px;
}

.mode-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-skip {
  margin-top: 12px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.mode-skip:hover {
  color: var(--text);
  background: var(--surface2);
}


@media (max-width: 520px) {
  .two-col { grid-template-columns: 1fr; }
  .tab { max-width: none; }
}


/* =========================
   Mode / Role UI
========================= */
/* =========================
   Header Mode Switcher (Top)
========================= */
.header-mode-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
}

.header-mode-switcher .mode-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.header-mode-switcher .mode-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.header-mode-switcher .mode-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

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

.header-mode-switcher .mode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile header mode switcher */
.header-mode-switcher.mobile {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
  padding: 3px 4px 3px 10px;
}

.header-mode-switcher.mobile .mode-label {
  color: rgba(0,0,0,0.6);
  font-size: 11px;
}

.header-mode-switcher.mobile .mode-btn {
  color: rgba(0,0,0,0.5);
  padding: 5px 8px;
  font-size: 11px;
}

.header-mode-switcher.mobile .mode-btn:hover {
  background: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.8);
}

.header-mode-switcher.mobile .mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Creator-only / Joiner-only blocks */
.only-creator{ display:none; }
.only-joiner{ display:none; }
body.mode-creator .only-creator{ display:block; }
body.mode-joiner .only-joiner{ display:block; }

/* Manage area additions */
.manage-card + .manage-card{ margin-top: 12px; }

.member-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  /* Slightly slimmer + more separation for readability */
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.member-row + .member-row { margin-top: 12px; }
.member-meta{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.member-name{ font-weight: 700; }
.member-discord{ font-size: 12px; color: var(--text-dim); }

/* Rename form */
.rename-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.rename-form .field {
  flex: 1;
}
.rename-form .input {
  margin-bottom: 0;
}
.rename-form .btn {
  flex-shrink: 0;
}

/* Request meta */
.req-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Danger zone */
.danger{
  border-color: rgba(239, 68, 68, 0.25) !important;
  background: rgba(239, 68, 68, 0.05) !important;
}
.danger .manage-title{ color: var(--red); }
.danger-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top: 10px;
}
.btn.danger{
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
}
.btn.danger:hover{
  background: rgba(239, 68, 68, 0.15);
}

/* Success button */
.btn.success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--green);
}
.btn.success:hover {
  background: rgba(34, 197, 94, 0.25);
}

.small-note{
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Empty state in manage cards */
.manage-card .empty-state {
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* Members list */
.members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* Pill in title */
.manage-title .pill {
  font-size: 11px;
  padding: 3px 8px;
}

/* ==================== OWNER NAV + MANAGE TABS ==================== */

.manage-tabs {
  display: flex;
  gap: 10px;
  padding: 10px 14px 14px 14px;
}

.manage-tab {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.manage-tab.active {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.35);
}

.tab-badge {
  background: rgba(250,204,21,0.18);
  border: 1px solid rgba(250,204,21,0.35);
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
}

.manage-tab-content { display: none; padding: 0 14px 14px 14px; }
.manage-tab-content.active { display: block; }

.tab-empty {
  padding: 18px;
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  text-align: center;
}

.tab-empty-icon { font-size: 24px; margin-bottom: 6px; }
.tab-empty-text { font-weight: 900; }
.tab-empty-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.tab-warning {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(250,204,21,0.25);
  background: rgba(250,204,21,0.08);
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
}

.req-left { min-width: 0; }
.req-meta { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.settings-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.settings-title {
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.rename-form { display: flex; gap: 10px; align-items: center; }
.rename-form .input { flex: 1; }

.members-list { display: flex; flex-direction: column; gap: 10px; }
.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.member-name { font-weight: 900; }
.member-discord { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.small-note { color: var(--text-dim); font-size: 13px; margin-top: 10px; }

.btn.success {
  background: rgba(34,197,94,0.14);
  border-color: rgba(34,197,94,0.28);
}

.btn.danger,
.btn.small.danger {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.28);
}

.danger-section { border-color: rgba(248,113,113,0.28); }
.danger-title { color: #f87171; }
.danger-desc { color: var(--text-dim); font-size: 13px; margin: 0 0 10px 0; }

/* =========================
   Simplified app additions
========================= */

.header-user{
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  min-width:0;
}

.header-user-stack{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:2px;
  min-width:0;
}

.header-line{
  display:flex;
  justify-content:flex-end;
  gap:0;
  min-width: var(--namebox-w);
  max-width: 220px;
}

.header-k{
  font-size:11px;
  color: var(--text-dim);
}

.header-v{
  font-weight:600;
  user-select:none;
  font-size:12px;
  line-height:1.2;
  text-align:right;
  margin-left:6px;
  min-width:0;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#user-name-display{ cursor:pointer; }

.header-user-input{
  width: var(--namebox-w);
  font-size:12px;
  padding:3px 10px;
  height: 24px;
}

.name-card{
  margin: 18px 0 10px 0;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}

.saved-name{
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
  cursor:pointer;
  user-select:none;
}

.clickable{
  text-align:left;
  width:100%;
  border: none;
  background: transparent;
  padding: 0;
}

/* Modal */
.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 999;
  padding: 14px;
}

.modal-card{
  width: min(520px, 100%);
  background: rgba(20,20,25,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.55);
  overflow:hidden;
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Make all modal close (×) buttons red */
.modal-head .icon-btn{
  border-color: rgba(248,113,113,0.45);
  background: rgba(248,113,113,0.12);
  color: var(--text);
}

.modal-title{
  font-weight: 700;
}

.modal-body{
  padding: 14px 12px;
}

.request-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

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

.request-actions{ display:flex; gap: 8px; }

/* Team chat */
.chat-modal-body{
  display:flex;
  flex-direction: column;
  gap: 12px;
  /* Taller chat like the rest of the UI */
  height: 72vh;
}

/* Chat tab */
.chat-head-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 10px;
}

/* Play tab - Mode Selection */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.mode-card {
  appearance: none;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.mode-card:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.mode-card-icon {
  font-size: 40px;
  line-height: 1;
}

.mode-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.mode-card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

@media (max-width: 520px) {
  .mode-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mode-card {
    padding: 20px 16px;
    flex-direction: row;
    text-align: left;
    gap: 16px;
  }

  .mode-card-icon {
    font-size: 32px;
    flex-shrink: 0;
  }

  .mode-card-content {
    flex: 1;
  }

  .mode-card-title {
    font-size: 16px;
  }

  .mode-card-desc {
    font-size: 12px;
  }
}

/* Lobby Header */
.lobby-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.lobby-header h2 {
  margin: 0;
  font-size: 20px;
}

.back-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  border-radius: 10px;
}

.lobby-name-check {
  margin: 16px 0;
  padding: 16px;
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 12px;
}

/* Quick Play Setup */
.quick-setup {
  margin-top: 20px;
}

.setup-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

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

/* Team Selection */
.team-select-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.team-select-btn {
  appearance: none;
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.team-select-btn:hover {
  transform: translateY(-2px);
}

.team-select-btn.red:hover,
.team-select-btn.red.selected {
  border-color: var(--game-red);
  background: var(--game-red-bg);
}

.team-select-btn.blue:hover,
.team-select-btn.blue.selected {
  border-color: var(--game-blue);
  background: var(--game-blue-bg);
}

.team-select-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.team-select-btn.red .team-select-color {
  background: var(--game-red);
}

.team-select-btn.blue .team-select-color {
  background: var(--game-blue);
}

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

.team-select-vs {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.team-select-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 12px;
}

/* Settings */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.setting-label {
  font-size: 14px;
  font-weight: 500;
}

.setting-select {
  width: auto;
  min-width: 140px;
  margin: 0;
}

/* Room Actions */
.room-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.room-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12px;
}

.room-divider::before,
.room-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-room-row {
  display: flex;
  gap: 10px;
}

.join-room-row .input {
  flex: 1;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  font-weight: 700;
}

@media (max-width: 520px) {
  .team-select-row {
    flex-direction: column;
    gap: 8px;
  }

  .team-select-btn {
    max-width: 100%;
    width: 100%;
    flex-direction: row;
    padding: 14px 16px;
    gap: 12px;
  }

  .team-select-color {
    width: 24px;
    height: 24px;
  }

  .team-select-vs {
    display: none;
  }

  .setting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .setting-select {
    width: 100%;
  }
}

.segmented{
  display:flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.seg-btn{
  appearance:none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-weight: 900;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor:pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.seg-btn:hover{
  background: var(--surface2);
  border-color: rgba(255,255,255,0.10);
  color: var(--text);
}

.seg-btn.active{
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.40);
  color: var(--text);
}

/* Unread badges (iMessage-style) */
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  /* Red again, but less opaque than the classic alert badge. */
  background: rgba(239,68,68,0.48);
  border: 1px solid rgba(239,68,68,0.42);
  color: rgba(255,255,255,0.98);
  font-weight: 900;
  font-size: 9px;
  letter-spacing: -0.2px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.22);
}

/* Team modal: make the join/request button span the same width as member rows */
#team-modal .form-actions{
  flex-direction: column;
  align-items: stretch;
}

#team-modal-join{
  width: 100%;
  justify-content: center;
}

.desktop-tabs .tab,
.mobile-tabs .tab,
.seg-btn{
  position: relative;
}

.tab-badge{
  position:absolute;
  top: 6px;
  right: 10px;
}

.mobile-tabs .tab .tab-badge{
  top: 6px;
  right: 14px;
}

.seg-badge{
  position:absolute;
  top: -6px;
  right: -6px;
}

.chat-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  display:flex;
  flex-direction: column;
  gap: 12px;
  min-height: 68vh;
}

/* Mobile: keep the composer comfortably above bottom tabs */
@media (max-width: 768px){
  .panel-chat .chat-card{
    /* A bit taller so the chat reaches lower on mobile, while keeping the composer visible */
    min-height: 60vh;
    height: 60vh;
  }
}

.chat-card .chat-messages{
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 10px;
}

.chat-messages{
  flex: 1 1 auto;
  max-height: none;
  overflow: auto;
  display:flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 6px;
}

.chat-msg{
  /* Minecraft-style: no bubbles, all left aligned */
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.chat-line{
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-who{
  font-weight: 900;
  color: rgba(255,255,255,0.88);
}

.chat-text{
  color: rgba(255,255,255,0.92);
}

.chat-compose{
  display:flex;
  gap: 10px;
  align-items: center;
}

.chat-input{ flex: 1 1 auto; margin: 0; }
.chat-send{ flex: 0 0 auto; }

/* Prettier invite list (My Team) */
#invites-list{ display:flex; flex-direction: column; gap: 10px; }
.invite-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.08);
}
.invite-left{ min-width: 0; }
.invite-title{ font-weight: 900; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-sub{ color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.invite-actions{ display:flex; gap: 8px; flex: 0 0 auto; }

/* =========================
   Launch screen
========================= */
body.launch .desktop-tabs,
body.launch .mobile-tabs,
body.launch .main-content {
  display: none !important;
}

/* On launch, keep the top band visible and pin it to the top */
body.launch .app-header{
  display: flex !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

/* Quick Play: keep the top band, but hide navigation tabs */
body.quickplay .desktop-tabs,
body.quickplay .mobile-tabs {
  display: none !important;
}
body.quickplay .main-content {
  display: block !important;
}

.launch-screen{
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  /* Stretch so the launch card can take the full available height and
     place the name dock near the bottom consistently. */
  align-items: stretch;
  justify-content: center;
  padding: clamp(22px, 4vw, 64px);
}

.launch-card{
  width: 100%;
  /* Match the reference: content sits directly on the background (no giant outer card) */
  max-width: 980px;
  border-radius: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 18px;
  margin: 0 auto;
  /* Make the card fill the available height so we can anchor the name dock low. */
  min-height: 100%;
  height: 100%;
}

.launch-hero{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

.launch-h1{
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.launch-sub{
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.launch-mode-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 10px;
}

/* Bigger, more spacious mode buttons on the launch screen */
.launch-screen .mode-card{
  /* Reference sizing */
  border-radius: 20px;
  padding: 26px 22px;
  min-height: 180px;
}

.launch-screen .mode-card-icon{
  font-size: 52px;
}

.launch-screen .mode-card-title{
  font-size: 20px;
}

.launch-screen .mode-card-desc{
  font-size: 13px;
}

/* Name dock on launch mirrors the Home name dock */
.launch-name-dock{
  width: 100%;
  max-width: 520px;
  /* Anchor near the bottom of the choose screen */
  margin-left: auto;
  margin-right: auto;
  margin-top: auto !important;
  /* Keep it very low on desktop (previous bottom margin was lifting it up). */
  margin-bottom: clamp(8px, 2vh, 24px);
  align-self: center;
  text-align: center;
}

/* Give the Save button more breathing room from the input (matches reference) */
.launch-name-dock .name-dock-form .form-actions{
  margin-top: 16px !important; /* overrides inline margin:0 in HTML */
  gap: 10px;
}

/* Center the entire name UI on the launch screen (matches Home) */
.launch-name-dock .field{
  align-items: center;
}
.launch-name-dock .label{
  text-align: center;
}
.launch-name-dock .input{
  text-align: center;
}
.launch-name-dock .name-dock-value{
  text-align: center;
}


@media (max-width: 768px){
  .launch-screen{ top: 56px; }
}

@media (max-width: 640px){
  .launch-card{ padding: 0; }
  .launch-mode-row{ grid-template-columns: 1fr; }
  .launch-screen .mode-card{ min-height: 140px; padding: 22px 18px; }
  .launch-screen .mode-card-icon{ font-size: 44px; }
  .launch-h1{ font-size: 28px; }
}

.btn.disabled,
button:disabled{
  opacity: .5;
  cursor: not-allowed;
}

/* ==================== POLISH OVERRIDES ==================== */

.home-hero{ margin-bottom: 14px; }
.home-title{ font-size: 30px; letter-spacing: 0.2px; }

/* Member boxes in modals + My Team: give them room and keep them slim */
.players-list{
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-row{
  padding: 6px 10px;
  border-radius: 6px;
}

/* Team action button should be full width inside the modal */
#team-modal-join{
  width: 100%;
  justify-content: center;
}

/* Name dock: bottom on mobile, unobtrusive card on desktop */
.name-dock{
  width: 100%;
  /* Push the name entry lower + make it sleeker */
  margin-top: 30px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(10px);
}

.name-dock-saved{ display:block; }
.name-saved-stack{
  display:flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.name-dock-label{ color: var(--text-dim); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.name-dock-value{ font-size: 16px; font-weight: 700; cursor:pointer; user-select:none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-dock-form .input{ margin-bottom: 0; }
.name-dock-form .form-actions{ justify-content: flex-end; gap: 10px; }

/* Prettier first-time name entry */
.name-dock-form .label{ font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase; }
.name-dock-form .input{ font-size: 12px; padding: 9px 12px; border-radius: 10px; }
.name-dock-form .form-actions{
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 8px;
}
.name-dock-form .btn.primary{
  width: 100%;
  justify-content: center;
  padding: 9px 14px;
  background: rgba(59,130,246,0.72);
  border-color: rgba(59,130,246,0.28);
}
.name-dock-form .hint{ font-size: 12px; }

/* Logout button sits under the name on Home (matches input width) */
.btn.logout{
  width: 100%;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(239,68,68,0.18);
  border: 1px solid rgba(239,68,68,0.28);
  color: #fff;
  font-weight: 800;
}
.btn.logout:hover{
  background: rgba(239,68,68,0.26);
  border-color: rgba(239,68,68,0.36);
}


@media (max-width: 768px){
  /* Keep name always reachable on Home */
  #panel-home .panel-inner{ padding-bottom: 110px; }
  #panel-home .name-dock{
    position: sticky;
    bottom: 66px; /* above mobile tabs */
  }
}

@media (min-width: 769px){
  /* On desktop, rely on top-right header name; keep dock subtle */
  #panel-home .home-hero{ margin-top: 18px; }
  /* Pull the name card up a bit so it's not hugging the bottom */
  #panel-home .name-dock{ max-width: 520px; margin-top: 22px; margin-bottom: 6px; }
}

/* Nudge the Tournament Home hero area up on desktop (better vertical balance) */
@media (min-width: 769px){
  body.tournament #panel-home .panel-inner{
    transform: translateY(-74px);
  }
}

/* Teams page: sharp clickable list */

/* Team color indicators (visible to everyone) */
.team-color-dot{
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--dot-color, rgba(255,255,255,0.18));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18);
  display: inline-block;
  flex: 0 0 auto;
}
.team-color-dot.sm{ width: 10px; height: 10px; }
.team-color-dot.muted{ background: rgba(255,255,255,0.14); }

.team-list-name{ display:flex; align-items:center; gap: 8px; }
.team-list-name-text{ min-width: 0; overflow:hidden; text-overflow: ellipsis; white-space: nowrap; }

.team-title-inline{ display:inline-flex; align-items:center; gap: 10px; }


.team-list-item{
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.team-list-item:hover{ background: var(--surface2); }

/* Highlight your current team in the list (very subtle) */
.team-list-item.is-mine{
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 0 0 2px var(--team-glow);
}

/* In Tournament, outline your team row using your team's color */
body.tournament.has-team-color .team-list-item.is-mine{
  border-color: var(--team-accent);
  /* Slightly softer glow on the Teams tab */
  box-shadow: 0 0 0 2px var(--team-glow), 0 0 6px var(--team-glow);
}

.team-list-left{ min-width: 0; }
.team-list-name{ font-size: 14px; font-weight: 700; letter-spacing: 0.1px; }
.team-list-members{
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-list-right{ flex: 0 0 auto; }
.team-list-count{
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  opacity: 0.9;
}

/* Teams page cards */
.team-card-expanded{ padding: 14px; }
.team-card-expanded .team-summary{ cursor: default; }
.team-body-compact{ margin-top: 12px; }
.team-actions{ display:flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.team-actions .hint{ min-height: 18px; }

/* My Team footer buttons */
.myteam-footer{
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display:flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.myteam-footer .btn{ width: 100%; justify-content: center; }
.myteam-footer .icon-btn{
  width: 42px;
  height: 42px;
  border-radius: 12px;
}
.myteam-footer .icon-btn svg{ width: 18px; height: 18px; }

/* Floating chat button on My Team card */
.floating-chat{
  position: absolute;
  right: 14px;
  bottom: -22px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: rgba(59,130,246,0.16);
  border-color: rgba(59,130,246,0.28);
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
}
.floating-chat:hover{ filter: brightness(1.08); }
.floating-chat:disabled{ opacity: 0.45; filter: none; }

/* Players directory */

.team-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  flex: 0 0 auto;
}
.team-badge .team-color-dot{ width: 8px; height: 8px; }

.state-pill{
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  flex: 0 0 auto;
}
.state-pill.pending{ border-color: rgba(250,204,21,0.35); color: rgba(250,204,21,0.95); background: rgba(250,204,21,0.08); }
.state-pill.ok{ border-color: rgba(34,197,94,0.35); color: rgba(34,197,94,0.95); background: rgba(34,197,94,0.08); }


.players-directory{ display:flex; flex-direction: column; gap: 10px; }

/* Directory rows: name + team on the left, status/actions on the right */
.player-directory-row{ align-items: center; }
.player-directory-row .player-left{
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  width: auto;
}
.player-directory-row .player-right{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.player-meta{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.player-meta-label{ color: var(--text-dim); }

.player-team{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  flex: 0 0 auto;
}
.player-team-name{ max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-tag{
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
}
.player-tag.ok{ border-color: rgba(34,197,94,0.35); color: rgba(34,197,94,0.95); background: rgba(34,197,94,0.08); }
.player-tag.pending{ border-color: rgba(250,204,21,0.35); color: rgba(250,204,21,0.95); background: rgba(250,204,21,0.08); }

/* Pill-style action buttons (used in Players directory) */
button.player-tag.pill-action{
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.7;
  cursor: pointer;
  user-select: none;
}
button.player-tag.pill-action.invite{
  background: rgba(59,130,246,0.82);
  border-color: rgba(59,130,246,0.55);
  color: rgba(255,255,255,0.98);
}
button.player-tag.pill-action.invite:hover{ filter: brightness(1.05); }
button.player-tag.pill-action.cancel{
  background: rgba(239,68,68,0.82);
  border-color: rgba(239,68,68,0.55);
  color: rgba(255,255,255,0.98);
}
button.player-tag.pill-action.cancel:hover{ filter: brightness(1.05); }
button.player-tag.pill-action:disabled{
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.player-status{
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  flex: 0 0 auto;
}
.player-status.ok{ border-color: rgba(34,197,94,0.35); color: rgba(34,197,94,0.95); background: rgba(34,197,94,0.08); }
.player-status.pending{ border-color: rgba(250,204,21,0.35); color: rgba(250,204,21,0.95); background: rgba(250,204,21,0.08); }
.player-status.busy{ border-color: rgba(255,255,255,0.12); color: var(--text-dim); }

/* ==================== CODENAMES GAME ==================== */

/* Game Colors */
:root {
  --game-red: #dc2626;
  --game-red-bg: rgba(220, 38, 38, 0.15);
  --game-red-border: rgba(220, 38, 38, 0.4);
  --game-blue: #2563eb;
  --game-blue-bg: rgba(37, 99, 235, 0.15);
  --game-blue-border: rgba(37, 99, 235, 0.4);
  --game-neutral: #71717a;
  --game-neutral-bg: rgba(113, 113, 122, 0.15);
  --game-neutral-border: rgba(113, 113, 122, 0.4);
  --game-assassin: #18181b;
  --game-assassin-bg: rgba(24, 24, 27, 0.9);
  --game-assassin-border: rgba(255, 255, 255, 0.2);
}

/* Game Panel */
.panel-game .panel-inner {
  max-width: 900px;
}

/* Game Lobby */
#game-lobby h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.game-team-status {
  margin: 16px 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.game-team-status .team-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-team-status .team-name {
  font-weight: 700;
  font-size: 16px;
}

.game-active-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 12px;
}

.game-banner-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-banner-title {
  font-weight: 700;
  color: var(--green);
}

.game-banner-teams {
  font-size: 13px;
  color: var(--text-dim);
}

.game-section {
  margin-top: 20px;
}

.game-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.challenges-list,
.challenge-teams-list,
.pending-challenges-list,
.active-games-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.challenge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.challenge-row.incoming {
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.06);
}

.challenge-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.challenge-team-name {
  font-weight: 700;
  font-size: 14px;
}

.challenge-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.challenge-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Game Header */
.game-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.game-teams-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.game-team {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
}

.game-team.red {
  background: var(--game-red-bg);
  border: 1px solid var(--game-red-border);
}

.game-team.blue {
  background: var(--game-blue-bg);
  border: 1px solid var(--game-blue-border);
}

.game-team .team-name {
  font-weight: 700;
  font-size: 14px;
}

.game-team .cards-left {
  font-size: 20px;
  font-weight: 800;
}

.game-team.red .cards-left { color: var(--game-red); }
.game-team.blue .cards-left { color: var(--game-blue); }

.game-vs {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.game-turn-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
}

.turn-label {
  color: var(--text-dim);
}

.turn-team {
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
}

.turn-team.red {
  background: var(--game-red-bg);
  color: var(--game-red);
}

.turn-team.blue {
  background: var(--game-blue-bg);
  color: var(--game-blue);
}

.turn-role {
  color: var(--text-dim);
  font-size: 13px;
}

/* Role Selection */
.role-selection {
  padding: 20px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
}

.role-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.role-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.role-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 24px;
  min-width: 140px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.role-btn:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.role-btn.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
}

.role-btn.taken {
  opacity: 0.5;
  cursor: not-allowed;
}

.role-icon {
  font-size: 28px;
}

.role-name {
  font-weight: 700;
  font-size: 15px;
}

.role-desc {
  font-size: 11px;
  color: var(--text-dim);
}

.role-status {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

/* Game Board */
.game-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.game-card {
  aspect-ratio: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.game-card:hover:not(.revealed):not(.disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.game-card.disabled {
  cursor: default;
}

.game-card .card-word {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  word-break: break-word;
  line-height: 1.2;
}

/* Spymaster View - Color overlay */
.game-card.spymaster-view.card-red {
  background: var(--game-red-bg);
  border-color: var(--game-red-border);
}

.game-card.spymaster-view.card-blue {
  background: var(--game-blue-bg);
  border-color: var(--game-blue-border);
}

.game-card.spymaster-view.card-neutral {
  background: var(--game-neutral-bg);
  border-color: var(--game-neutral-border);
}

.game-card.spymaster-view.card-assassin {
  background: var(--game-assassin-bg);
  border-color: var(--game-assassin-border);
}

.game-card.spymaster-view.card-assassin .card-word {
  color: #ef4444;
}

/* Revealed Cards */
.game-card.revealed {
  cursor: default;
}

.game-card.revealed.card-red {
  background: var(--game-red);
  border-color: var(--game-red);
}

.game-card.revealed.card-blue {
  background: var(--game-blue);
  border-color: var(--game-blue);
}

.game-card.revealed.card-neutral {
  background: var(--game-neutral);
  border-color: var(--game-neutral);
}

.game-card.revealed.card-assassin {
  background: #000;
  border-color: #ef4444;
}

.game-card.revealed .card-word {
  color: #fff;
}

/* Clue Area */
.clue-area {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}

.current-clue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
}

.clue-label {
  color: var(--text-dim);
}

.clue-word {
  font-weight: 800;
  font-size: 20px;
  text-transform: uppercase;
}

.clue-number {
  background: var(--accent);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.guesses-left {
  color: var(--text-dim);
  font-size: 13px;
  margin-left: 8px;
}

.clue-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.clue-input {
  flex: 1;
  min-width: 120px;
  margin: 0;
}

.clue-num-input {
  width: 60px;
  margin: 0;
  text-align: center;
}

.operative-actions {
  display: flex;
  justify-content: center;
}

.waiting-message {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px 0;
}

/* Game Log */
.game-log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  max-height: 200px;
  overflow-y: auto;
}

.game-log-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.game-log-entries {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry {
  font-size: 13px;
  line-height: 1.4;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry .log-team {
  font-weight: 700;
}

.log-entry .log-team.red { color: var(--game-red); }
.log-entry .log-team.blue { color: var(--game-blue); }

.log-entry .log-clue {
  font-weight: 600;
  text-transform: uppercase;
}

.log-entry .log-result {
  color: var(--text-dim);
}

/* Game Actions */
.game-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Game End Modal */
.game-end-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.game-end-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.game-end-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.game-end-title.win { color: var(--green); }
.game-end-title.lose { color: var(--red); }

.game-end-subtitle {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.game-end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .game-board {
    gap: 6px;
  }

  .game-card {
    border-radius: 8px;
  }

  .game-card .card-word {
    font-size: 10px;
  }

  .game-teams-display {
    flex-wrap: wrap;
  }

  .game-team {
    padding: 6px 10px;
  }

  .game-team .team-name {
    font-size: 12px;
  }

  .game-team .cards-left {
    font-size: 16px;
  }

  .role-buttons {
    flex-direction: column;
  }

  .role-btn {
    min-width: 100%;
  }

  .clue-form {
    flex-direction: column;
  }

  .clue-input,
  .clue-num-input {
    width: 100%;
  }
}

/* Invites (My Team) */
#invites-list{ display:flex; flex-direction: column; gap: 10px; }
.invite-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
}
.invite-left{ min-width: 0; }
.invite-title{ font-weight: 900; font-size: 14px; letter-spacing: 0.2px; }
.invite-sub{ color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.invite-actions{ display:flex; gap: 8px; flex: 0 0 auto; }

