/* Reset and Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --bg-hover: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-dark: #101010;
  --text-muted: #666666;
  --accent: #9c5926;
  --accent-hover: #aa5717;
  --accent-secondary: rgb(103, 157, 214);
  --success: #2ecc71;
  --warning: #f39c12;
  --error: #e22315;
  --border: #333333;
  --border-light: #444444;
  --radius: 2px;
  --radius-lg: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background: url('/images/bg.png') repeat center center fixed;
  background-color: #231b1a;
}

/* Container */
.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem;
}

/* Home Page */
.home-container {
  display: flex;
  align-items: start;
  justify-content: center;
  min-height: 100vh;
}

.home-content {
  text-align: center;
  width: 100%;
  max-width: 900px;
}

/* Home Two-Column Layout */
.home-columns {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

@media (min-width: 768px) {
  .home-columns {
    flex-direction: row;
    gap: 3rem;
    align-items: flex-start;
  }
}

.home-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

@media (min-width: 768px) {
  .home-column-left {
    align-items: flex-end;
    padding-top: 1em;
  }
  
  .home-column-right {
    align-items: flex-start;
  }
}

.title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title img {
  width: 90%;
  max-width: 450px;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* My Tournaments Section */
.my-tournaments-section {
  margin-top: 0.5rem;
  width: 100%;
}

.my-tournaments-section .section-title {
  margin-bottom: 0.5rem;
  text-align: left;
  font-weight: normal;
}

.tournaments-table {
  width: 100%;
  border-collapse: collapse;
}

.tournaments-table th,
.tournaments-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tournaments-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dark);
  font-weight: 600;
}

.tournaments-table td {
  font-size: 0.85rem;
  color: var(--text-dark);
}

.tournaments-table .code-cell {
  font-weight: 700;
  font-family: monospace;
  color: var(--accent);
}

.tournaments-table .match-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tournaments-table .btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
}

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

#join-form {
  width:100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-success {
  background: var(--success);
  color: var(--text-primary);
}

.btn-success:hover {
  background: #27ae60;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-icon.danger:hover {
  color: var(--accent);
}

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

/* Forms */
.input-group {
  display: flex;
}

.input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

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

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

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  justify-content: flex-start;
  max-width: 300px;
  margin: 0.5em auto;
}

#modal-player-name {
  width: 100%;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.checkbox-label input:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked + .checkmark::after {
  content: '✓';
  color: white;
  font-size: 12px;
}

/* Error Message */
.error-message {
  color: var(--accent);
  margin: 0 auto;
}

/* Create Page */
.create-container {
  padding-top: 2rem;
}

.page-header {
  text-align: center;
  margin-bottom: 3rem;
}

.modal .page-header {
  margin-bottom: -5.1em;
  margin-top: 1.5em;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-secondary);
}

/* Step Indicator */
.steps {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 3rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

.step.active {
  color: var(--text-primary);
}

.step.completed {
  color: var(--success);
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.step.active .step-number {
  border-color: var(--accent);
  background: var(--accent);
}

.step.completed .step-number {
  border-color: var(--success);
  background: var(--success);
}

/* Size Selection */
.size-selection {
  max-width: 600px;
  margin: 0 auto;
}

.size-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.size-option {
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.size-option:not(.selected) {
  filter: saturate(0.2);
}

.size-option:hover {
  border-color: var(--border-light);
  background: var(--bg-tertiary);
}

.size-option.selected {
  border-color: var(--accent);
  background: rgba(230, 57, 70, 0.1);
}

.size-option .number {
  font-size: 4rem;
  display: block;
  line-height: 2.5rem;
  margin-bottom: 0.25rem;
}

.size-option .label {
  color: var(--text-secondary);
  font-size: 1.5rem;
  padding-top: 1em;
}

/* Player Setup */
.player-setup {
  max-width: 1400px;
  margin: 0 auto;
}

.tournament-code-display {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-image: url("/images/ui/secondary-bg.png");
}

.tournament-code-display .code {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.125rem;
}

/* Progress Bar */
.progress-container {
  margin-bottom: 2rem;
}

.progress-container.secondary-text {
  display: block;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Add Player Form */
.add-player-form {
  margin-bottom: 2rem;
}

/* Player Grid */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.player-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  min-height: 130px;
}

.player-card:hover {
  border-color: var(--border-light);
  background: var(--bg-tertiary);
}

.player-card.empty {
  border-style: dashed;
  cursor: default;
  opacity: 0.5;
}

.player-card.empty:hover {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.player-card.ready {
  border-color: var(--success);
}

.player-name {
  font-weight: 600;
  padding-right: 1em;
  font-size: 1.1em;
  text-wrap-mode: nowrap;
  margin-bottom: 0.5rem;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-loadout {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.player-loadout {
  display: flex;
  gap: 0.5em;
}

.player-loadout>span {
  display: flex;
  width: 60px;
  height: 60px;
  background-color: #0004;
  justify-content: center;
  align-items: center;
  position: relative;
}

.player-loadout img {
  max-width: 80%;
  max-height: 80%;
  text-align: center;
}

.player-loadout .equipped {
  color: var(--success);
}

.player-loadout .not-equipped {
  color: var(--text-muted);
  font-style: italic;
}

.player-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.player-card:hover .player-actions {
  opacity: 1;
}

.player-status {
  position: absolute;
  bottom: 11px;
  right: 7px;
}

.status-badge {
  font-size: 0.625rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.status-badge.ready {
  background: rgba(46, 204, 113, 0.2);
  color: var(--success);
}

.status-badge.pending {
  background: rgba(243, 156, 18, 0.2);
  color: var(--warning);
}

/* Start Button */
.start-section {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.start-requirements {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  transform: scale(0.9);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}

.modal.small-modal {
  max-height: 360px;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  pointer-events: none;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-close.btn-secondary {
  padding: 0.25em 0.75em;
}

.modal-close.btn-secondary:hover {
  background-color: #0007;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex-grow: 1;
  margin-top: 4em;
}

.modal-footer {
  display: flex;
  justify-content: space-evenly;
  gap: 1rem;
  padding: 0.5rem 1rem;
  backdrop-filter: sepia(0.5);
}

/* Loadout Selection */

.loadout-flex {
  display: flex;
  gap: 1em;
  justify-content: space-evenly;
}

.loadout-section {
  margin-bottom: 2rem;
}

.loadout-flex .loadout-section {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.loadout-section h4 {
  color: var(--text-dark);
  font-size: 0.875rem !important;
  padding: 0.25em;
  letter-spacing: 0.05em;
  margin: 0 auto 1em auto;
}

.loadout-flex .loadout-section h4 {
  text-align: center;
  flex-grow: 1;
  display: flex;
}

.loadout-options {
  display: flex;
  flex-direction: column;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.loadout-option {
  padding: 1rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  background-color: #0005;
  filter: saturate(0.5) opacity(0.8);
  aspect-ratio: 1;
  width: 155px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loadout-option:hover {
  border-color: var(--border-light);
}

.loadout-option.selected, .loadout-option:hover {
  filter: saturate(1) opacity(1);
}

.loadout-option.selected {
  background-color: rgba(46, 204, 113, 0.1);
}

.loadout-option .name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.loadout-option .stats {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.loadout-option .type-badge {
  display: inline-block;
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.type-badge.sharp {
  background: rgba(230, 57, 70, 0.2);
  color: var(--accent);
}

.type-badge.blunt {
  background: rgba(74, 144, 217, 0.2);
  color: var(--accent-secondary);
}

.type-badge.light {
  background: rgba(46, 204, 113, 0.2);
  color: var(--success);
}

.type-badge.medium {
  background: rgba(243, 156, 18, 0.2);
  color: var(--warning);
}

.type-badge.heavy {
  background: rgba(230, 57, 70, 0.2);
  color: var(--accent);
}

/* Tournament Page */
.tournament-container {
  padding-top: 1rem;
}

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

.tournament-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.creator-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.spectator-notice {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
}

.tournament-code {
  font-size: 1.5rem !important;
  font-weight: 700;
  color: var(--accent);
}

/* Bracket Display */
.bracket-container {
  /* overflow-x: auto; */
  padding: 0.25em;
  background-color: #0005;
}

.inner-bracket-container {
  max-height: 70vh;
  overflow: auto;
  padding: 3rem 1rem;
}

.bracket {
  display: flex;
  align-items: stretch;
  min-width: max-content;
  max-width: max-content;
  max-height: max-content;
}

.round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  position: relative;
}

.round-title {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
  position: absolute;
  top: -31px;
  right: 0;
  width: 225px;
  left: 18px;
}

.round-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
  padding-top: 2rem;
}

.match-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  padding: 0.5rem 0;
  margin-left: 5px;
}

.match {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 250px;
  position: relative;
  z-index: 1;
  filter: opacity(0.8) saturate(0.2);
}

.match.active {
  filter: opacity(1) saturate(1);
  box-shadow: 0 0 20px rgba(230, 57, 70, 0.2);
}

.match.complete {
  filter: opacity(1) saturate(1);
}

/* Connector lines */
.connector {
  position: relative;
  width: 40px;
}

.connector-in {
  display: none;
  /* We draw input lines from the output connector */
}

/* Horizontal line going out from match */
.connector-h-out {
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--border);
  transform: translateY(-1px);
}

.connector-h-out.winner {
  background: var(--success);
}

/* Vertical line connecting matches */
.connector-v {
  position: absolute;
  left: 20px;
  width: 2px;
  background: var(--border);
  transform: translateX(-1px);
}

.connector-v.winner {
  background: var(--success);
}

/* Horizontal line going into next match */
.connector-h-in {
  position: absolute;
  left: 20px;
  width: 20px;
  height: 2px;
  background: var(--border);
  transform: translateY(-1px);
}

.connector-h-in.winner {
  background: var(--success);
}

.match-player {
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.match-player:last-child {
  border-bottom: none;
}

.match-player.winner {
  background: rgba(46, 204, 113, 0.1);
}

.match-player.winner .match-player-name {
  color: var(--success);
}

.match-player.loser {
  color: var(--text-secondary);
  backdrop-filter: grayscale(1);
}

.match-player-name {
  font-weight: 500;
}

/* Controls */
.tournament-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
}

/* Champion Display */
.champion-display {
  text-align: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, rgba(230, 57, 70, 0.1), rgba(243, 156, 18, 0.1));
  border-radius: var(--radius-lg);
  margin: 1rem 21rem;
}

.champion-title {
  font-size: 2.5rem;
}

.champion-name {
  font-size: 3.5rem;
  background: linear-gradient(0deg, #614739, #1a1918);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color 0.2s;
}

.back-link.inline-backlink {
  margin-bottom: 0;
  color: var(--text-dark);
}

.back-link:hover {
  color: var(--text-primary);
}

.battle-header {
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  text-align: center;
}

.battle-header .modal-title {
  font-size: 1.5rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.battle-body {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-top: 5.5em;
}

/* Fighter Section */
.battle-fighters {
  display: flex;
  align-items: stretch;
  padding: 1.5rem;
  background: #0006;
  backdrop-filter: sepia(0.5);
  flex-shrink: 0;
}

.fighter {
  flex: 1;
  display: flex;
  text-align: center;
  flex-direction: column;
}

.fighter-left {
  padding-right: 1rem;
}

.fighter-right {
  padding-left: 1rem;
}

.fighter-name {
  font-size: 2.5rem;
  line-height: 2rem;
  font-family: 'Jacquard 24';
  font-weight: 400;
  margin-bottom: 0.25rem;
  flex-grow: 1;
}

.fighter-loadout {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5em;
}

.loadout-card {
    aspect-ratio: 1;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loadout-card img {
    max-width: 80%;
    max-height: 80%;
}

.versus {
  display: flex;
  /* font-weight: 400; */
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  font-family: 'Jacquard 24';
  color: var(--accent);
  padding: 0 1rem;
}

/* Health Bar */
.health-bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.health-bar {
  flex: 1;
  height: 24px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #27ae60);
  transition: width 0.15s ease;
}

.health-fill.low {
  background: linear-gradient(90deg, var(--warning), #e67e22);
}

.health-fill.critical {
  background: linear-gradient(90deg, var(--accent), #c0392b);
  animation: pulse-critical 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-critical {
  from {
    opacity: 0.7;
  }

  to {
    opacity: 1;
  }
}

.health-text {
  min-width: 40px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Rounds Container */
.rounds-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 400px;
  max-height: 400px;
  margin-right: 3px;
  background: #0003;
  backdrop-filter: sepia(0.5);
}

/* Round Card - Banner Style */
.round-card {
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.3s ease;
  min-height: 190px;
  height: 190px;
  max-height: 190px;
}

.round-card:not(:first-of-type) {
  margin-top: -1em;
}

.round-card-header {
  padding: 0.0rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.round-number {
  font-size: 1em;
  color: var(--text-primary);
  letter-spacing: 0.1em;
  font-family: 'Jacquard 24';
}

.round-card-content {
  display: flex;
  align-items: center;
}

.round-player {
  flex: 1;
  text-align: center;
  max-width: 268px;
}

.round-player-left {
  padding-right: 1rem;
  text-align: left;
  margin-left: 0.5em;
}

.round-player-right {
  padding-left: 1rem;
  text-align: right;
  margin-right: 0.5em;
}

.round-player-name {
  font-size: 1.4em;
  color: var(--text-dark);
  font-family: 'Jacquard 24';
  line-height: 1em;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  margin-top: 0.15em;
}

.round-damage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.round-damage > span {
  font-family: 'Jacquard 24';
  line-height: 3.2rem;
  font-size: 2.5em;
}

.damage-dealt {
  color: #ecf5a2;
}

.damage-riposte {
  color: #e74c3c;
}

.damage-partial {
  color: #f1c40f;
}

.damage-miss {
  font-size: 1.75em !important;
  text-transform: lowercase;
  color: #000A;
}

.round-damage.crit .damage-dealt {
  color: #f39c12;
  text-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

.damage-type {
  font-size: 0.625rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.crit-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: #f39c12;
  background: rgba(243, 156, 18, 0.2);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  animation: crit-flash 0.3s ease-in-out 2;
}

@keyframes crit-flash {
  50% {
    transform: scale(1.2);
  }
}

.blocked {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--accent-secondary);
  background: rgba(74, 144, 217, 0.2);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.round-health-after {
  font-size: 0.75rem;
  color: var(--text-primary);
  margin-top: 1rem;
}

.round-vs {
  padding: 0rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Battle Result */
.battle-result {
  padding: 1.5rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.1), rgba(39, 174, 96, 0.2));
  flex-shrink: 0;
}

.battle-result.animate-in {
  animation: result-slide-in 0.5s ease-out;
}

@keyframes result-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.winner-announcement {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.winner-label {
  font-size: 2rem;
  line-height: 1rem;
  font-family: 'Jacquard 24';
  text-transform: lowercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.winner-name {
  font-size: 3rem;
  line-height: 4rem;
  font-family: 'Jacquard 24';
  color: var(--success);
  text-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

.battle-footer {
  justify-content: center;
  background: var(--bg-tertiary);
}

.battle-footer .btn {
  min-width: 200px;
}

/* Win indicator in bracket */
.win-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(46, 204, 113, 0.2);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

/* Utility */
.hidden {
  display: none !important;
}

.btn-primary {
  font-family: "Jacquard 24", system-ui;
  font-style: normal;
  color: #FFF;
  border: 30px solid transparent;
  border-image-source: url('/images/ui/button.png');
  border-image-slice: 20 35 20 35 fill;
  border-width: 20px 35px 20px 35px;
  border-image-repeat: stretch;
  line-height: 27px;
  max-width: 325px;
  height: 69px;
  box-sizing: border-box;
  text-align: center;
  filter: saturate(0.8) brightness(0.8);
  cursor: pointer;
  padding: 0;
  margin: 0 auto;
  min-width: 225px;
  background-color: #0000 !important;
  font-size: 28px;
  text-shadow: 0px 0px 5px #000;
}

.btn-primary:hover {
  filter: none;
  transform: translateY(-2px);
}

.input-group {
  position: relative;
  margin: 6px;
}

.input-group input {
  border-right: 2px groove #8c6237 !important;
}

.stylized-border, .stylized-border-slim {
  position: relative;
}

.secondary-text {
  border: 10px solid transparent;
  border-image-source: url('/images/ui/secondary.png');
  border-image-slice: 18 18 18 18 fill;
  display: inline-block;
  padding: 0 1em;
  font-family: "Jacquard 24", system-ui;
  font-style: normal;
  color: var(--text-dark);
  font-size: 1.5em !important;
}

.secondary-text.block {
  display: block;
}

.secondary-text.flex {
  display: flex;
}

.metal-frame {
  border: 14px solid transparent;
  border-image-source: url('/images/ui/frame-metal.png');
  border-image-slice: 15 13 14 13 fill;
  display: inline-block;
  font-family: "Jacquard 24", system-ui;
  font-style: normal;
  color: var(--text-dark);
  font-size: 1.5em;
  padding: 0.15em;
  line-height: 1rem;
}

.metal-frame.block {
  display: block;
}

.metal-frame.flex {
  display: flex;
}

.mf-error {
  color: var(--error);
  padding: 0.1em 1em;
}

.round-frame {
  position:relative;
  border: 12px solid transparent;
  border-image-source: url('/images/ui/round-bg.png');
  border-image-slice: 15 82 2 82 fill;
  border-width: 15px 82px 2px 82px;
  display: inline-block;
  font-family: "Jacquard 24", system-ui;
  font-style: normal;
  color: var(--text-dark);
  font-size: 1.5em;
}


.stylized-border::after {
  content: '';
  border: 12px solid transparent;
  border-image-source: url('/images/ui/frame.png');
  border-image-slice: 45 45 57 45;
  display: block;
  box-sizing: border-box;
  position: absolute;
  top: -8px;
  left: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  pointer-events: none;
}

.stylized-border-slim::after {
  content: '';
  border: 6px solid transparent;
  border-image-source: url('/images/ui/frame-slim.png');
  border-image-slice: 22 18 28 18;
  display: block;
  box-sizing: border-box;
  position: absolute;
  top: -5px;
  left: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  pointer-events: none;
}

.stylized-heading {
  border: 6px solid transparent;
  border-image-source: url('/images/ui/heading-bg.png');
  border-image-slice: 16 144 26 139 fill;
  border-width: 16px 144px 26px 139px;
  display: inline-block;
  box-sizing: border-box;
  pointer-events: none;
  margin: 0 auto;
  font-family: "Jacquard 24", system-ui;
  font-style: normal;
  line-height: 2.5rem;
  font-size: 2.5rem;
  font-weight: normal;
  color: var(--text-primary);
  text-shadow: 0 0 10px #000;
}

.btn-secondary {
  filter: saturate(0.8) brightness(0.8);
  font-family: "Jacquard 24", system-ui;
  font-style: normal;
  font-size: 1.5em;
  pointer-events: all;
}

.stylized-background {
  background-image: url("/images/ui/secondary-bg.png") !important;
}

.btn-secondary:hover {
  filter: none;
}



#loadout-modal > .modal {
  max-width: 750px;
}

#closed-modal > .modal {
  max-width: 600px;
}


/* Battle Modal */
#battle-modal > .modal {
  max-width: 800px;
}

.weapon-divider::after {
  content: ' - ';
  margin: 0px 5px;
}

#pending-code, #tournament-code, .tournament-code {
  text-decoration: none;
}

.champion-display.metal-frame {
  padding: 2rem 1rem !important;
  line-height: initial !important;
}
/* Responsive */
@media (max-width: 768px) {

  .container {
    padding: 0.75em;
  }

  .title {
    font-size: 2rem;
  }

  .size-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .loadout-options {
    grid-template-columns: 1fr;
  }

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

  .tournament-header {
    gap: 5px;
  }

  .tournament-info {
    flex-direction: column;
    gap: 0.5rem;
  }

  .stylized-heading {
    border-width: 8px 77px 13px 70px;
    line-height: 2rem;
    font-size: 2rem;
    margin-bottom: 0.25em;
  }

  .secondary-text {
    border-width: 6px;
    font-size: 1.4em !important;
  }
  .metal-frame {
    font-size:1em;
    padding:0.25em;
    border-width: 6px;
  }
  .tournament-code-display .code {
    font-size: 1rem;
  }

  .loadout-option {
    width: 120px;
    padding: 1em 0.5em 0.5em 0.5em;
  }

  .loadout-option .name {
    font-size: 0.8rem;
  }

  .loadout-option img {
    max-height: 55px;
  }

  .loadout-option .stats {
    display: none;
  }

  .weapon-divider::after {
    content: '';
    display: block;
    margin: 0px;
  }

  .loadout-flex .loadout-section h4 {
    flex-direction: column;
    justify-content: center;
  }
}

/* Custom Tooltip */
.custom-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
  padding: 0.25rem 0.5rem;
  animation: tooltip-fade-in 0.15s ease-out;
}

@keyframes tooltip-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Equipment Tooltip (Rich HTML) */
.equipment-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 0.75rem;
  min-width: 220px;
  max-width: 300px;
  animation: tooltip-fade-in 0.15s ease-out;
}

.equipment-tooltip-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--accent);
}
.equipment-tooltip-icon {
    height: 60px;
    width: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.equipment-tooltip-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: var(--radius);
}

.equipment-tooltip-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.equipment-tooltip-stats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.equipment-tooltip-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.equipment-tooltip-stat .stat-label {
  color: var(--text-dark);
  font-size: 0.85rem;
}

.equipment-tooltip-stat .stat-value {
  color: var(--text-dark);
  font-weight: 600;
  font-size: 0.9rem;
}

.equipment-tooltip-skills {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.equipment-tooltip-skill {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.equipment-tooltip-skill .skill-name {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
}

.equipment-tooltip-skill .skill-description {
  color: var(--text-dark);
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: normal;
}

/* Damage Breakdown Tooltip */
.damage-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 0.75rem;
  min-width: 280px;
  max-width: 380px;
  animation: tooltip-fade-in 0.15s ease-out;
}

.damage-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--accent);
}

.damage-tooltip-result {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
}

.damage-tooltip-result.result-hit {
  background: rgba(253, 252, 198, 0.2);
  color: #ecf5a2;
}

.damage-tooltip-result.result-counter {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

.damage-tooltip-result.result-block {
  background: rgba(99, 102, 102, 0.2);
  color: #555;
}

.damage-tooltip-result.result-partial {
  background: rgba(241, 196, 15, 0.2);
  color: #f1c40f;
}

.damage-tooltip-directions {
  display: flex;
  flex-direction:column;
  justify-content: center;
  font-size: 0.8rem;
  flex-grow: 1;
  border-radius: var(--radius);
}

.damage-tooltip-directions .direction-label {
  color: var(--text-dark);
}

.damage-tooltip-directions .direction-value {
  color: var(--text-primary);
  font-weight: 600;
}

.damage-tooltip-directions .direction-separator {
  color: var(--border);
}

.damage-tooltip-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
  margin-top: 0.5rem;
}

.damage-tooltip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.damage-tooltip-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.damage-tooltip-table td {
  padding: 0.25rem 0.4rem;
}

.damage-tooltip-table .source-cell {
  color: var(--text-dark);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.damage-tooltip-table .operation-cell {
  color: var(--text-primary);
  font-family: monospace;
  text-align: center;
}

.damage-tooltip-table .result-cell {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

.damage-tooltip-table .final-row td {
  border-bottom: none;
}

.damage-tooltip-final {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--accent);
  font-size: 0.85rem;
  color: var(--text-dark);
}

.damage-tooltip-final .final-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.damage-tooltip-skills {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.damage-tooltip-skill {
  padding: 0.4rem;
  border-radius: var(--radius);
}

.damage-tooltip-skill .skill-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

.damage-tooltip-skill .skill-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--accent);
}

.damage-tooltip-skill .skill-role {
  font-size: 0.7rem;
  color: var(--text-dark);
}

.damage-tooltip-skill .skill-desc {
  font-size: 0.7rem;
  color: var(--text-dark);
  line-height: 1.3;
}

/* Make damage numbers hoverable */
.has-damage-tooltip {
  cursor: help;
  transition: opacity 0.15s ease;
}

.has-damage-tooltip:hover {
  opacity: 0.8;
}

.regular-font {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.no-top-margin {
  margin-top: 0 !important;
}
