:root {
  /* Colors are now set dynamically by JavaScript */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--on-surface-color);
  line-height: 1.6;
  padding: 15px;
  transition: background-color 0.5s ease;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3e%3cfilter id='noiseFilter'%3e%3cfeTurbulence type='fractalNoise' baseFrequency='0.65' stitchTiles='stitch'/%3e%3c/filter%3e%3crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.2'/%3e%3c/svg%3e");
}

#root {
  max-width: 1000px;
  margin: 0 auto;
}

main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

h1 {
  font-size: 2.5em;
  text-align: center;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.header-logo {
  height: 1.2em;
}

h2 {
  font-size: 1.8em;
  padding-bottom: 0.5rem;
  margin: 0;
}

h3 {
  font-size: 1.5em;
  margin-bottom: 1rem;
  text-align: center;
}

h4 {
    font-size: 1.2em;
    color: var(--primary-color);
}

.container {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.column {
  flex: 1;
  min-width: 300px;
  background-color: var(--surface-color);
  padding: 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: background-color 0.5s ease;
}

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

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--on-surface-color);
    opacity: 0.7;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, opacity 0.2s, color 0.3s, text-shadow 0.3s;
}

.icon-button:hover:not(:disabled) {
    background-color: var(--border-color);
    opacity: 1;
}

.icon-button:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

.icon-button .pm-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.icon-button.locked {
    color: #ffd700;
    opacity: 1;
    text-shadow: 0 0 4px #ffd700, 0 0 8px #ffd700;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.input-group-wrapper {
    position: relative;
}

input[type="text"], input[type="number"], select {
  padding: 0.6rem;
  font-size: 1rem;
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--on-surface-color);
  transition: background-color 0.5s ease, border-color 0.5s ease;
}

input[type="text"] {
  flex-grow: 1;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 30%, transparent);
}

input:disabled, select:disabled {
  background-color: color-mix(in srgb, var(--background-color) 50%, var(--surface-color));
  cursor: not-allowed;
  opacity: 0.6;
}

button {
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

button:disabled {
    background-color: color-mix(in srgb, var(--surface-color) 50%, #000) !important;
    color: color-mix(in srgb, var(--on-surface-color) 50%, #000) !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
    border-color: transparent !important;
}

.button-primary {
  background-color: var(--primary-color);
  color: var(--on-primary-color);
}

.button-primary:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--primary-color) 85%, #000);
}

.button-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.button-secondary:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
}

ul {
  list-style-type: none;
}

li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem;
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  word-break: break-all;
  transition: background-color 0.5s ease, border-color 0.5s ease;
}

li span {
  margin-right: 1rem;
}

.locked-list {
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.6rem;
  word-break: break-word;
  color: color-mix(in srgb, var(--on-surface-color) 80%, transparent);
  line-height: 1.5;
  font-size: 1.05em;
  font-weight: 500;
}

.player-score {
  color: color-mix(in srgb, var(--on-surface-color) 70%, transparent);
  font-size: 0.9em;
}

.remove-button-small {
  background-color: transparent;
  color: var(--error-color);
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--error-color);
  border-radius: 4px;
}

.remove-button-small:hover:not(:disabled) {
  background-color: var(--error-color);
  color: var(--on-primary-color);
}

.remove-button-small:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background-color: transparent !important;
    border-color: color-mix(in srgb, var(--error-color) 50%, transparent);
    color: color-mix(in srgb, var(--error-color) 50%, transparent);
}

.swap-button-small {
  background-color: transparent;
  color: var(--primary-variant-color);
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--primary-variant-color);
  border-radius: 4px;
}

.swap-button-small:hover:not(:disabled) {
  background-color: var(--primary-variant-color);
  color: var(--on-surface-color);
}

.swap-button-small:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background-color: transparent !important;
    border-color: color-mix(in srgb, var(--primary-variant-color) 50%, transparent);
    color: color-mix(in srgb, var(--primary-variant-color) 50%, transparent);
}

.status-button {
    background-color: transparent;
    color: var(--primary-variant-color);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--primary-variant-color);
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
}

.status-button:hover:not(:disabled) {
    background-color: var(--primary-variant-color);
    color: var(--on-surface-color);
}

.status-button.dq-button {
    color: var(--error-color);
    border-color: var(--error-color);
}

.status-button.dq-button:hover:not(:disabled) {
    background-color: var(--error-color);
    color: var(--on-primary-color);
}

.main-content-area {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.tournament-section {
    background-color: var(--surface-color);
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 300px;
}

.rules-card {
  flex: 1;
}

.rules-card ul {
  padding-left: 1rem;
}

.rules-card li {
  display: block;
  background: none;
  border: none;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  word-break: normal;
}

.rules-card li strong {
  color: var(--primary-color);
}

.rules-card ul ul {
  padding-left: 1.5rem;
  margin-top: 0.25rem;
}

.rules-card ul ul li {
  padding: 0.25rem 0;
  margin-bottom: 0;
}

.controls-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

.controls-group label {
    font-size: 1.1rem;
    font-weight: bold;
    flex-shrink: 0;
}

.controls-group input, .controls-group select {
    flex-grow: 1;
}

.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 1rem;
}

.generate-button {
    background-color: var(--primary-variant-color);
    color: var(--on-surface-color);
    padding: 0.6rem 1.5rem;
    font-size: 1.2rem;
}

.generate-button:hover:not(:disabled) {
    background-color: color-mix(in srgb, var(--primary-variant-color) 85%, #fff);
}

.error-message {
    color: var(--error-color);
    font-weight: bold;
    text-align: center;
}

.disclaimer-note {
    font-size: 0.9em;
    font-style: italic;
    text-align: center;
    color: color-mix(in srgb, var(--on-surface-color) 70%, transparent);
    margin-top: 1rem;
}

.round-display {
    background-color: var(--surface-color);
    padding: 1.25rem;
    border-radius: 8px;
}

.matches-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.match-card {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--primary-color);
    padding: 0.75rem;
    border-radius: 4px;
}

.match-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.match-card-header h4 {
  margin-right: 0.5rem;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-players ul {
    margin-top: 0.5rem;
}

.match-players li {
    background: none;
    border: none;
    padding: 0.5rem 0;
    justify-content: space-between;
}

.match-players li > span:first-of-type {
    flex: 1 1 auto;
    min-width: 0; /* Allow shrinking below content size */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.5rem;
}

.player-name-medium {
    font-size: 0.9em;
}

.player-name-small {
    font-size: 0.8em;
}

select option:disabled {
  color: #555;
}

.rank-radio-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap; /* Prevent wrapping */
    flex-shrink: 0; /* Prevent this container from shrinking */
}

.rank-radio-group label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: background-color 0.2s;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ */
    user-select: none;
}

.rank-radio-group label:hover:not(:has(input:disabled)) {
    background-color: var(--border-color);
}

.rank-radio-group input[type="radio"] {
    accent-color: var(--primary-color);
}

.rank-radio-group input[type="radio"]:disabled,
.rank-radio-group input[type="radio"]:disabled + span {
    cursor: not-allowed;
    opacity: 0.6;
}


.standings {
    align-items: center;
    display: flex;
    flex-direction: column;
}

.standings ul {
    width: 100%;
}

.standings li {
    font-size: 1.2em;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem;
}

.standings li:last-child {
    border-bottom: none;
}

.tie-breaker-title {
    color: var(--error-color);
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

.theme-selector-container {
    margin-top: 2rem;
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.theme-selector-container label {
    font-weight: bold;
}

.theme-selector-container select {
    min-width: 150px;
}

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.suggestion-item {
    padding: 0.6rem;
    cursor: pointer;
    background-color: var(--surface-color);
    border: none;
    border-bottom: 1px solid var(--border-color);
    margin: 0;
    border-radius: 0;
    text-align: left;
    width: 100%;
    display: block;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: color-mix(in srgb, var(--surface-color) 90%, var(--primary-color));
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background-color: var(--surface-color);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  width: 90%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-header h3 {
    margin-bottom: 0;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-body label {
    font-weight: bold;
}

.modal-body input {
    width: 100%;
}

.modal-arena-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 40vh;
    overflow-y: auto;
    padding-top: 0.5rem;
}

.modal-arena-list button {
    width: 100%;
    text-align: left;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.modal-footer button {
    min-width: 100px;
}

.modal-footer .cancel-button {
    background-color: var(--background-color);
    color: var(--on-surface-color);
    border: 1px solid var(--border-color);
}

.modal-footer .button-primary {
    border: 1px solid var(--primary-color);
}

.modal-footer .button-primary:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--primary-color) 85%, #000);
}

.modal-footer .cancel-button:hover {
    background-color: var(--border-color);
}

.page-footer {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem 0;
  color: color-mix(in srgb, var(--on-surface-color) 70%, transparent);
  font-size: 0.9em;
}

.page-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: bold;
  cursor: pointer;
}

.page-footer a:hover {
  text-decoration: underline;
}

.changelog-body {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 1rem;
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

.changelog-version {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.1em;
  color: var(--primary-color);
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 0.25rem;
  font-weight: bold;
}

.changelog-version::before {
    content: '>> ';
    color: var(--primary-variant-color);
}

.changelog-version:first-of-type {
  margin-top: 0;
}

.changelog-body ul {
  list-style-type: none;
  padding-left: 1rem;
}

.changelog-body li {
    background: none;
    border: none;
    padding: 0.1rem 0;
    margin-bottom: 0.2rem;
    display: block;
    align-items: initial;
    justify-content: initial;
    font-size: 1em;
    word-break: normal;
    position: relative;
    padding-left: 1.5rem;
}

.changelog-body li::before {
    content: '* ';
    position: absolute;
    left: 0.5rem;
    color: var(--primary-variant-color);
}

.changelog-body a {
  color: var(--primary-color);
  font-weight: bold;
  text-decoration: none;
}

.changelog-body a:hover {
  text-decoration: underline;
}

/* Prize Wheel Styles */
.prize-wheel-button {
    background-color: transparent;
    border: none;
    color: var(--primary-color);
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.prize-wheel-button:hover:not(:disabled) {
    background-color: var(--border-color);
}
.prize-wheel-button img {
    width: 28px;
    height: 28px;
}

.prize-wheel-modal-content {
    max-width: 800px;
    width: 95%;
}

.prize-wheel-layout {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.prize-wheel-container {
    position: relative;
    width: 400px;
    height: 400px;
    flex-shrink: 0;
}

.prize-wheel-canvas {
    width: 100%;
    height: 100%;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.prize-wheel-canvas:active:not(.spinning) {
    transform: scale(0.98);
}

.prize-wheel-pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid var(--error-color);
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.4));
    z-index: 10;
}

.prize-wheel-sidebar {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-self: stretch;
}

.prize-wheel-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: 8px;
}

.prize-wheel-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.prize-wheel-winners {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prize-wheel-winners h4 {
    margin-bottom: 0.5rem;
}

.prize-wheel-winners ul {
    overflow-y: auto;
    max-height: 250px;
    padding-right: 0.5rem;
}

.prize-wheel-winners li {
    font-size: 1.1em;
    padding: 0.5rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
}

.match-timer {
    font-size: 0.9em;
    color: color-mix(in srgb, var(--on-surface-color) 80%, transparent);
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  .prize-wheel-layout {
    flex-direction: column;
  }
  .prize-wheel-container {
    width: 300px;
    height: 300px;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}