:root {
  --bg: #5d5050;
  --panel: #232323;
  --accent: #ffcf27;
  --link: #71f3ff;
  --text: #ffffff;
  --muted: #c0c0c0;
  --border: #ffffff;
  --hover: #fb8200;
}

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

html,
body {
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

#wrapper {
  min-width: 1000px;
  min-height: 100%;
}

#app-shell {
  width: 1140px;
  margin: 0 auto;
  position: relative;
}

#header {
  height: 115px;
  width: 180px;
  position: relative;
  left: 0;
  top: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}

#header img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
}

#middle {
  position: relative;
}

#container,
#container2 {
  width: 100%;
  float: left;
}

#links {
  margin-left: 220px;
  position: relative;
  top: -107px;
}

.top-nav {
  display: flex;
  background: var(--panel);
}

.top-link {
  width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-left: 0;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.top-link:first-child {
  width: 112px;
  border-left: 1px solid var(--border);
}

.top-link:hover,
.top-link.is-active {
  background: var(--hover);
}

#seasonHolder {
  text-align: center;
  width: 760px;
  position: relative;
  left: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  top: -90px;
}

#title {
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  text-align: center;
}

.round-banner {
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  text-align: center;
}

#sideLeft2,
#sideLeft3 {
  float: left;
  width: 180px;
  position: relative;
  left: 0;
  border: 1px solid var(--border);
  background: var(--panel);
  text-align: center;
  color: var(--muted);
  clear: left;
}

#sideLeft2 {
  top: -58px;
  padding: 10px 8px;
}

#sideLeft3 {
  top: -38px;
  padding: 10px 8px;
}

.side-section {
  display: block;
}

.side-hidden {
  display: none;
}

.sidebar-button {
  width: 100%;
  margin-bottom: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.sidebar-button:hover,
.sidebar-button.primary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar-copy {
  color: var(--muted);
  line-height: 1.5;
}

.status-line {
  margin-bottom: 10px;
  color: var(--muted);
}

.status-line strong {
  color: var(--accent);
}

#content {
  position: absolute;
  left: 250px;
  width: 760px;
  margin-top: -58px;
  padding: 5px;
  color: var(--text);
  text-align: center;
}

#mobile-round-banner-holder {
  display: block;
}



.history-nav {
  position: relative;
  margin: 6px auto 0;
  width: fit-content;
}

.history-toggle {
  width: auto;
  min-width: 160px;
  margin: 0 0 6px;
}

.history-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  background: rgba(35, 35, 35, 0.95);
  z-index: 10;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}


.history-list[hidden] {
  display: none !important;
}

.history-button {
  width: 100%;
  margin: 0;
  padding: 5px 8px;
  text-align: left;
}

.history-button.is-active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.page-panel {
  display: none;
}

.page-panel-visible {
  display: block;
}

.lead-copy,
.empty-copy,
.setup-copy,
.help-copy {
  margin-bottom: 14px;
  line-height: 1.5;
}

.winner-banner {
  margin-bottom: 14px;
  color: var(--accent);
  font-weight: bold;
}

.sponsor-panel,
.inventory-panel {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  background: rgba(35, 35, 35, 0.58);
}

.sponsor-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.sponsor-controls > * {
  min-width: 0;
}

.sponsor-action-field span {
  visibility: hidden;
  user-select: none;
}

.field select {
  width: 100%;
  height: 34px;
  border: 1px solid #8f8f8f;
  background: #3c3434;
  color: var(--text);
  padding: 7px 8px;
}

.sponsor-controls .sponsor-button {
  margin: 0;
  width: 100%;
  height: 34px;
  min-height: 34px;
  line-height: 34px;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 8px;
  padding-right: 8px;
}

.sponsor-feedback {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.inventory-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inventory-card {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.inventory-card.is-fallen {
  opacity: 0.65;
}

.inventory-card-head {
  margin-bottom: 8px;
}

.inventory-card-name {
  margin-bottom: 4px;
}

.inventory-card-meta {
  color: var(--muted);
  font-size: 12px;
}

.inventory-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
}

.inventory-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.inventory-chip-row:last-child {
  margin-bottom: 0;
}

.inventory-chip-label {
  width: 100%;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inventory-chip,
.inventory-empty {
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
}

.inventory-chip {
  color: var(--text);
  cursor: pointer;
}

.inventory-chip:hover {
  border-color: rgba(255, 207, 39, 0.7);
  color: var(--accent);
}

.status-chip {
  border-color: rgba(113, 243, 255, 0.25);
  background: rgba(113, 243, 255, 0.08);
}

.status-chip:hover {
  border-color: rgba(113, 243, 255, 0.6);
  color: var(--link);
}

.inventory-empty {
  color: var(--muted);
}

.subheading {
  margin-bottom: 10px;
  color: var(--accent);
  font-weight: bold;
}

.events-list {
  text-align: center;
}

.event-line {
  margin-bottom: 10px;
  line-height: 1.55;
}

.fallen-holder {
  margin-top: 20px;
}

.fallen-list {
  line-height: 1.6;
}

.bottom-controls {
  margin-top: 26px;
  text-align: center;
}

.bottom-button {
  min-width: 130px;
  margin: 0 6px 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.bottom-button.primary,
.bottom-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.bottom-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 18px;
}

.tribute-table {
  width: 650px;
  margin: 0 auto;
  border-collapse: collapse;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  font-weight: bold;
}

.tribute-table th,
.tribute-table td {
  padding: 6px 4px;
  vertical-align: middle;
}

.tribute-table th {
  color: var(--accent);
}

.tribute-table input {
  width: 100%;
  border: 1px solid #8f8f8f;
  background: #3c3434;
  color: var(--text);
  padding: 4px 5px;
}

.tribute-table input[type="color"] {
  min-width: 56px;
  height: 28px;
  padding: 2px;
}

.district-input {
  width: 48px;
  text-align: center;
}

.tribute-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
}

.avatar-shell {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  flex: 0 0 32px;
}

.avatar-image,
.avatar-fallback {
  width: 100%;
  height: 100%;
}

.avatar-image {
  display: none;
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  font-size: 10px;
}

.preview-name {
  display: block;
  text-align: left;
  min-height: 32px;
  font-size: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.remove-button {
  width: 32px;
  padding: 4px 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  text-align: left;
}

.field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.field input[type="color"] {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border);
  background: transparent;
}

.theme-heading {
  margin-top: 10px;
}

@media (max-width: 1180px) {
  #wrapper {
    min-width: 0;
    padding: 0 12px 20px;
  }

  #app-shell {
    width: 100%;
    max-width: 1140px;
  }

  #header {
    width: 160px;
  }

  #header img {
    width: 100%;
  }

  #links {
    margin-left: 190px;
  }

  #seasonHolder {
    width: calc(100% - 220px);
    left: 220px;
  }

  #content {
    left: 220px;
    width: calc(100% - 220px);
  }
}

@media (max-width: 860px) {
  #wrapper {
    padding: 10px 10px 20px;
  }

  /* Always show the moved banner on mobile */
  #mobile-round-banner-holder {
    display: block;
  }


  #app-shell {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  #header {
    position: static;
    width: 100%;
    height: auto;
    top: 0;
  }

  #header img {
    width: 100%;
    height: auto;
    max-height: 160px;
  }

  #middle,
  #container,
  #container2 {
    position: static;
    float: none;
    width: 100%;
  }

  #links,
  #seasonHolder,
  #sideLeft2,
  #sideLeft3,
  #content {
    position: static;
    top: auto;
    left: auto;
    width: 100%;
    margin: 0;
  }

  #links,
  #seasonHolder {
    margin: 0;
  }

  .top-nav {
    width: 100%;
  }

  .top-link,
  .top-link:first-child {
    width: 50%;
    flex: 1 1 0;
  }

  #seasonHolder {
    text-align: center;
  }

  #sideLeft2,
  #sideLeft3 {
    clear: none;
    top: auto;
  }

  #content {
    margin-top: 0;
    padding: 8px 2px 0;
  }

  .mobile-round-banner-holder {
    display: block;
    margin-top: 0;
    margin-bottom: 8px;
    text-align: center;
    order: -1;
  }


  .mobile-round-banner-holder #round-banner {
    display: inline-block;
    width: fit-content;
  }



  .bottom-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sponsor-controls,
  .inventory-board {
    grid-template-columns: 1fr;
  }

  .bottom-button {
    flex: 1 1 140px;
  }

  .tribute-table {
    margin: 0;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  #wrapper {
    padding: 8px 8px 18px;
  }

  #app-shell {
    gap: 6px;
  }

  #header img {
    max-height: 112px;
  }

  #title {
    width: 100%;
    padding: 7px 10px;
  }

  #sideLeft2,
  #sideLeft3 {
    padding: 8px;
  }

  #sideLeft2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #sideLeft2 .side-section:not(.side-hidden) {
    display: contents;
  }

  #sideLeft2 .side-section[data-panel="sponsorships"]:not(.side-hidden) {
    display: block;
    grid-column: 1 / -1;
    padding: 6px 2px;
  }

  .sidebar-button {
    margin-bottom: 0;
    min-height: 40px;
    padding: 8px 6px;
  }

  #sideLeft3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    text-align: center;
  }

  .status-line {
    margin-bottom: 0;
    padding: 6px 4px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
  }

  .status-line span,
  .status-line strong {
    display: block;
  }

  /* Fix mobile "Rounds" (history) layout */
  .history-nav {
    margin-top: 14px;
    width: 100%;
    grid-column: 1 / -1;
    position: static;
  }

  .history-toggle {
    width: 100%;
    min-width: 0;
  }

  .history-list {
    position: static;
    transform: none;
    left: auto;
    top: auto;
    width: 100%;
    max-height: 340px;
    overflow: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .history-button {
    padding: 5px 7px;
    font-size: 12px;
    margin: 0;
  }

  .history-list {
    gap: 4px;
  }


  .bottom-controls {
    gap: 8px;
    margin-top: 20px;
  }

  .bottom-button {
    min-width: 0;
    margin: 0;
    flex-basis: calc(50% - 4px);
    min-height: 40px;
  }

  .sponsor-panel,
  .inventory-panel {
    padding: 10px;
  }

  .lead-copy,
  .empty-copy,
  .setup-copy,
  .help-copy,
  .winner-banner,
  .subheading,
  .event-line {
    margin-bottom: 12px;
  }

  .events-list,
  .fallen-list {
    font-size: 13px;
    line-height: 1.65;
  }

  .table-wrap {
    margin-left: -2px;
    margin-right: -2px;
    padding-bottom: 4px;
  }

  .tribute-table {
    width: 760px;
  }

  .tribute-table th,
  .tribute-table td {
    padding: 7px 5px;
  }

  .tribute-preview {
    min-width: 170px;
  }

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