
:root {
  --uniform-stage-width: 520px;
  --uniform-stage-height: 800px;
}

/* Uniform builder layout */
.uniform-builder {
  display: grid;
  grid-template-columns: minmax(520px, 560px) 320px;
  gap: 1.1rem;
  align-items: start;
  justify-content: center;
  max-width: 980px;
  margin: 0 auto;
}

.uniform-main {
  min-width: 0;
  width: 100%;
}

.uniform-history {
  min-width: 0;
}

.uniform-history .history-panel {
  max-height: 78vh;
  overflow: auto;
  padding-right: 8px;
  position: sticky;
  top: 88px;
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.96) 0%, rgba(10, 10, 10, 0.96) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  padding-top: 0;
}

.uniform-history .history-title {
  position: sticky;
  top: 0;
  z-index: 20;
  display: block;
  margin: 0 !important;
  padding: 0.18rem 1rem 0.5rem;
  background: #111;
  box-shadow: 0 10px 14px rgba(17, 17, 17, 0.96);
  color: var(--orange) !important;
  font-family: 'Tomorrow', sans-serif !important;
  font-size: 2.2rem !important;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.uniform-history .history-title::after {
  content: "";
  display: block;
  width: 52px;
  height: 2px;
  margin-top: 0.34rem;
  background: linear-gradient(90deg, var(--orange), rgba(223, 62, 0, 0));
  opacity: 0.95;
}

#uniformStage {
  width: var(--uniform-stage-width);
  height: var(--uniform-stage-height);
  position: relative;
  margin: 0 auto;
  background: #000000;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.stage-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.background-layer {
  z-index: 0;
}

#helmetLayer { z-index: 1; }
#jerseyLayer { z-index: 2; }
#shirtLayer  { z-index: 3; }
#pantsLayer  { z-index: 4; }
#socksLayer  { z-index: 5; }

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 14px auto 10px;
  max-width: var(--uniform-stage-width);
}

.actions .meta {
  margin-left: 10px;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
}

#controls {
  max-width: var(--uniform-stage-width);
  margin: 10px auto 0;
}

.control-row {
  display: grid;
  grid-template-columns: 150px 40px 44px 222px 44px;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
}

.control-row .control-btn.next-btn { justify-self: end; }

.control-label {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.current-name {
  font-weight: 400;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
}

.control-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color:#fff;
  cursor:pointer;
  font-size: 16px;
}

.thumb-viewport {
  overflow:hidden;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.35);
  height: 78px;
  width: 222px;
  justify-self: start;
}

.thumb-strip {
  display:flex;
  gap: 6px;
  padding: 6px;
  overflow-x:auto;
  scroll-behavior:smooth;
  scrollbar-width: thin;
}

.thumb-strip::-webkit-scrollbar{height:8px;}
.thumb-strip::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.18);border-radius:10px;}

.thumb-frame {
  width: 66px;
  height: 66px;
  background: #333333;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.thumb-frame.active {
  border-color: #ff6a00;
}

.thumb-frame:focus-visible {
  outline: none;
  border-color: #ff6a00;
}


.thumb {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  transform-origin: center;
  pointer-events: none;
}

.lock-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 34px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  align-self: center;
}

.lock-btn.locked {
  border-color: #ff6a00;
  box-shadow: 0 0 0 2px rgba(255,106,0,0.55);
}

/* History tree */
.history-tree,
.history-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 0.8rem;
}

.history-tree {
  position: relative;
  z-index: 1;
  margin-top: 0;
  padding: 0.1rem 1rem 1rem 0.95rem;
}

.history-tree li {
  line-height: 1.2;
  padding-top: 0.14rem;
  padding-bottom: 0.14rem;
}

.history-tree li > span {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.14rem 0.58rem 0.14rem 0.72rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.history-tree > li > span {
  font-size: 0.93rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.93);
}

.history-tree > li > ul > li > span {
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
}

.history-tree a {
  position: relative;
  display: inline-block;
  min-height: 26px;
  padding: 0.14rem 0.58rem 0.14rem 0.72rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #f6f6f6;
  line-height: 1.25;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.history-tree li > span::before,
.history-tree a::before {
  content: "";
  position: absolute;
  left: 0.32rem;
  top: 50%;
  width: 3px;
  height: 0.9rem;
  border-radius: 999px;
  background: transparent;
  transform: translateY(-50%);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.history-tree li.branch > span {
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.history-tree li.branch.open > span::before,
.history-tree a.selected::before {
  background: rgba(255, 71, 0, 0.95);
  box-shadow: 0 0 10px rgba(255, 71, 0, 0.25);
}

.history-tree li.branch > span:hover,
.history-tree li.branch > span:focus,
.history-tree a:hover,
.history-tree a:focus-visible {
  color: #ffffff;
  background: rgba(255, 71, 0, 0.14);
  border-color: rgba(255, 71, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 71, 0, 0.12);
  transform: translateX(1px);
  outline: none;
}

.history-tree li.branch > ul {
  overflow: hidden;
}

.history-tree li.branch.collapsed > ul {
  display: none;
}

.history-tree li.branch > span::after {
  content: "▾";
  margin-left: 0.45rem;
  font-size: 0.78rem;
  opacity: 0.75;
  transition: transform 0.18s ease;
}

.history-tree li.branch.collapsed > span::after {
  transform: rotate(-90deg);
}

@media (max-width: 1100px) {
  .uniform-builder {
    grid-template-columns: 1fr;
    max-width: 560px;
  }

  .uniform-history {
    order: 2;
    width: 100%;
  }

  .uniform-history .history-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px){
  .uniform-builder {
    gap: 0.9rem;
    max-width: 100%;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .actions .meta {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }

  #controls{
    max-width: 100%;
  }

  .control-row{
    grid-template-columns: 118px 34px 38px minmax(0, 1fr) 38px;
    gap: 8px;
  }

  .control-label{
    font-size: 12px;
  }

  .current-name{
    font-size: 11px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .control-btn{
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .lock-btn{
    width: 32px;
    height: 28px;
  }

  .thumb-viewport{
    width: 100%;
    min-width: 0;
    height: 72px;
  }

  .thumb-strip{
    padding: 5px;
  }

  .thumb{
    width: 60px;
    height: 60px;
    border-radius: 9px;
  }

  .uniform-history .history-title {
    font-size: 1.8rem !important;
  }
}

@media (max-width: 560px){
  .page-intro h1 {
    font-size: clamp(1.65rem, 8vw, 2.2rem);
  }

  #uniformStage{
    width: 100%;
    height: auto;
    aspect-ratio: 52 / 80;
    border-radius: 14px;
  }

  .stage-layer{
    width: 100%;
    height: 100%;
  }

  .control-row{
    grid-template-columns: 1fr 32px 34px minmax(0, 1fr) 34px;
    gap: 6px;
    margin: 8px 0;
  }

  .lock-btn{
    width: 30px;
    height: 26px;
    font-size: 13px;
  }

  .control-btn{
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 13px;
  }

  .thumb-viewport{
    height: 64px;
    border-radius: 9px;
  }

  .thumb-strip{
    gap: 5px;
    padding: 4px;
  }

  .thumb{
    width: 54px;
    height: 54px;
    border-radius: 8px;
  }

  .uniform-history .history-title {
    padding: 0.12rem 1rem 0.38rem;
    font-size: 1.6rem !important;
  }

  .uniform-history .history-title::after {
    width: 40px;
    margin-top: 0.26rem;
  }

  .history-tree {
    padding-right: 0.8rem;
  }
}

@media (max-width: 420px){
  .control-row{
    grid-template-columns: 92px 28px 30px minmax(0, 1fr) 30px;
    gap: 5px;
  }

  .control-label{
    font-size: 11px;
  }

  .current-name{
    font-size: 10px;
  }

  .lock-btn{
    width: 26px;
    height: 24px;
    font-size: 11px;
  }

  .control-btn{
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .thumb-viewport{
    height: 58px;
  }

  .thumb{
    width: 48px;
    height: 48px;
  }
}


/* Button polish to match helmet builder */
.actions .button-primary:hover {
  background: #ff5a1a;
}

.actions .button-secondary:hover {
  background: rgba(255, 71, 0, 0.12);
  border-color: var(--orange);
}

/* ===== Uniform builder button match to helmet builder ===== */
.uniform-page .actions button {
  background: #6b0f13;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 8px 12px;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 700;
  min-height: 0;
  box-shadow: none;
}

.uniform-page .actions button:hover {
  filter: brightness(1.06);
}

.uniform-page .actions button.button,
.uniform-page .actions #btnRandom,
.uniform-page .actions #btnReset {
  background: #6b0f13;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 18px;
  padding: 8px 12px;
}

@media (max-width: 560px){
  .uniform-page .actions button {
    padding: 8px 10px;
    border-radius: 16px;
    font-size: 14px;
  }
}

/* Jersey thumbnail adjustment */
.thumb-jersey {
  transform: scale(2);
  transform-origin: 50% 30%;
}


/* Thumbnail focus controls
   These adjust what appears INSIDE each 66x66 box.
   - transform: scale(1.5) = 50% zoom
   - object-position: first value = left/right, second value = up/down
*/
.thumb-helmet {
  transform: scale(6.0) translateX(23%);
  object-position: 50% -70%;
}

.thumb-jersey {
  transform: scale(4.0) translateX(20%);
  object-position: 50% 10%;
}

.thumb-shirt {
  transform: scale(9.0) translateX(-5%);
  object-position: 50% -20%;
}

.thumb-pant {
  transform: scale(6.0) translateX(10%);
  object-position: 50% 35%;
}

.thumb-sock {
  transform: scale(6.0) translateX(18%);
  object-position: 50% 125%;
}

/* History opponent styling */
.opponent {
  color: #a0a0a0;
  font-weight: 400;
}

.uniform-history li > span > a {
  line-height: 1.25;
}


/* Fix stacked layout for score + opponent */
.history-tree a br {
  display: block;
  margin-top: 2px;
}

.opponent {
  display: block;
  color: #a0a0a0;
  font-weight: 400;
}



/* FORCE override for Random / Reset buttons */
.uniform-page .actions button,
.actions button {
  border: 1px solid rgba(255, 71, 0, 0.55) !important;
  background: rgba(255,255,255,0.03) !important;
  color: #ffffff !important;
}

/* Hover */
.uniform-page .actions button:hover,
.actions button:hover {
  border-color: rgba(255, 71, 0, 0.8) !important;
  background: rgba(255, 71, 0, 0.12) !important;
}

/* Active */
.uniform-page .actions button:active,
.actions button:active {
  background: var(--orange) !important;
  color: #000 !important;
  border-color: var(--orange) !important;
}

@media (max-width: 560px){
  .thumb-frame{
    width: 54px;
    height: 54px;
    border-radius: 8px;
  }

  .thumb-viewport{
    height: 62px;
  }

  .thumb-strip{
    align-items: center;
  }
}

@media (max-width: 420px){
  .thumb-frame{
    width: 48px;
    height: 48px;
    border-radius: 7px;
  }

  .thumb-viewport{
    height: 56px;
  }
}