/* Koda: car garage (#profile/car) and profile (#profile). Loaded after style.css; uses its :root tokens. */

/* ==================== Garage (#profile/car) ==================== */
#view > .page.garage {
  max-width: 36rem;
  display: grid;
  gap: 10px;
  align-content: start;
}

.garage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 8px;
  min-height: 36px;
}
.garage-head h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4.5vw, 1.7rem);
  font-weight: 900;
  line-height: 1.15;
}
.garage-dirty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 2px solid #FFD199;
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}
.garage-dirty::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FF9600;
  flex: none;
}

.garage-layout {
  display: grid;
  gap: 10px;
  min-width: 0;
}

/* Purposeful flat Koda garage stage: studio wall, overhead light cones, workshop floor, turntable plinth */
.garage-stage {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 2px solid #C6D9F2;
  border-radius: 20px;
  background: #EBF4FF;
  min-width: 0;
}

.stage-lights {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.stage-lights::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(10rem, 40%);
  height: 6px;
  border-radius: 0 0 6px 6px;
  background: #2C3A5E;
}
.stage-lights i {
  position: absolute;
  top: 6px;
  width: 44%;
  height: 72%;
  background: rgba(255, 255, 255, 0.45);
  clip-path: polygon(32% 0, 68% 0, 100% 100%, 0 100%);
}
.stage-lights i:first-child { left: 10%; }
.stage-lights i:last-child { right: 10%; }

.stage-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36%;
  background: #D4E1F2;
  border-top: 3px solid #B7CBE6;
  pointer-events: none;
  z-index: 0;
}
.stage-floor::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -11px;
  height: 8px;
  background: repeating-linear-gradient(90deg, rgba(26, 140, 255, 0.14) 0 12px, transparent 12px 24px);
}

.stage-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 0;
}
.stage-bay-tag {
  padding: 2px 8px;
  border: 2px solid #C6D9F2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: #5674A3;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.stage-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stage-btn {
  min-height: var(--tap);
  padding: 0 12px;
  border: 2px solid #C6D9F2;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 #C6D9F2;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: none;
  letter-spacing: normal;
  gap: 5px;
}
.stage-btn:hover:not(:disabled) { background: #F6FAFF; }
.stage-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.stage-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 3px 0 var(--accent-hover);
}
.stage-btn:disabled {
  background: rgba(255, 255, 255, 0.58);
  border-color: #D2DFEE;
  color: #93A5C0;
  box-shadow: none;
}
.stage-btn .ico { width: 1rem; height: 1rem; }

.stage-arena {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px 14px;
  min-height: 158px;
}
.stage-steer {
  position: relative;
  z-index: 3;
  flex: none;
  width: var(--tap);
  height: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: 2px solid #C6D9F2;
  border-radius: 50%;
  background: #fff;
  color: var(--accent-hover);
  box-shadow: 0 3px 0 #C6D9F2;
  text-transform: none;
  letter-spacing: normal;
}
.stage-steer:hover { background: #F5FAFF; }
.stage-steer:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.stage-steer svg { width: 22px; height: 22px; display: block; }

.stage-bay {
  flex: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.stage-single {
  position: relative;
  display: grid;
  justify-items: center;
  padding-bottom: 8px;
  cursor: grab;
}
.stage-single.is-dragging { cursor: grabbing; }

.stage-car-rig {
  position: relative;
  z-index: 2;
  transform: translateX(var(--steer-x, 0px)) rotate(var(--steer-rot, 0deg));
  transform-origin: 50% 88%;
  transition: transform 0.34s cubic-bezier(.34, 1.56, .64, 1);
}
.stage-single.is-dragging .stage-car-rig { transition: none; }

.stage-car-slot .mascot {
  display: block;
  width: clamp(8.25rem, 32vw, 10rem);
}

.stage-plinth {
  position: relative;
  z-index: 1;
  margin-top: -22px;
  width: clamp(10rem, 45vw, 14rem);
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-line);
  box-shadow: 0 6px 0 #9BB6DB;
  overflow: hidden;
}
.stage-plinth::before {
  content: '';
  position: absolute;
  inset: 4px 12px;
  border-radius: 50%;
  border: 2px dashed #CBE4FF;
}
.plinth-ticks {
  position: absolute;
  left: -28px;
  right: -28px;
  bottom: 2px;
  height: 6px;
  background: repeating-linear-gradient(90deg, #8CCBFF 0 4px, transparent 4px 16px);
  opacity: 0.75;
  transform: translateX(var(--turntable-shift, 0px));
  transition: transform 0.34s cubic-bezier(.34, 1.56, .64, 1);
}
.stage-single.is-dragging .plinth-ticks { transition: none; }

/* Before / After compare mode */
.stage-compare {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  padding: 2px 4px 4px;
}
.compare-side {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
}
.compare-tag {
  padding: 2px 10px;
  border: 2px solid #C6D9F2;
  border-radius: 99px;
  background: #fff;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}
.compare-tag.is-new {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fff;
}
.compare-car { position: relative; z-index: 2; }
.compare-car .mascot {
  display: block;
  width: clamp(6rem, 25vw, 7.5rem);
}
.compare-side.is-before .compare-car { opacity: 0.92; }
.stage-plinth.mini {
  width: clamp(7.25rem, 30vw, 9.25rem);
  height: 22px;
  margin-top: -14px;
  box-shadow: 0 5px 0 #9BB6DB;
}

/* Part-change & steer-wobble animations */
.swap-pop { animation: garage-swap-pop 0.32s cubic-bezier(.34, 1.56, .64, 1); }
.swap-wheels { animation: garage-swap-wheels 0.34s ease-out; }
.swap-top { animation: garage-swap-top 0.32s ease-out; }
.wobble-left { animation: garage-wobble-left 0.38s cubic-bezier(.22, 1, .36, 1); }
.wobble-right { animation: garage-wobble-right 0.38s cubic-bezier(.22, 1, .36, 1); }

@keyframes garage-swap-pop {
  0% { transform: scale(0.92, 1.07); }
  45% { transform: scale(1.06, 0.94) translateY(-6px); }
  100% { transform: scale(1); }
}
@keyframes garage-swap-wheels {
  0% { transform: translateY(0); }
  35% { transform: translateY(-11px) scale(0.98, 1.04); }
  70% { transform: translateY(2px) scale(1.04, 0.95); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes garage-swap-top {
  0% { transform: translateY(-8px) scale(1.04, 0.94); }
  55% { transform: translateY(2px) scale(0.97, 1.04); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes garage-wobble-left {
  0% { transform: translateX(0) rotate(0deg); }
  32% { transform: translateX(-14px) rotate(-7deg); }
  68% { transform: translateX(5px) rotate(2.5deg); }
  100% { transform: translateX(0) rotate(0deg); }
}
@keyframes garage-wobble-right {
  0% { transform: translateX(0) rotate(0deg); }
  32% { transform: translateX(14px) rotate(7deg); }
  68% { transform: translateX(-5px) rotate(-2.5deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* Workbench: category tabs, option tiles, action bar */
.garage-workbench {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.garage-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--sunken);
}
.garage-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tap);
  min-width: 0;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  text-transform: none;
  letter-spacing: normal;
  font-size: clamp(0.68rem, 2.6vw, 0.82rem);
  font-weight: 800;
  line-height: 1.12;
  white-space: normal;
  text-align: center;
}
.garage-tab:hover { background: rgba(255, 255, 255, 0.7); color: var(--ink); }
.garage-tab:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.garage-tab[aria-selected="true"] {
  background: #fff;
  border-color: var(--accent-line);
  color: var(--accent-hover);
  box-shadow: 0 3px 0 var(--accent-line);
}
.tab-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(23, 33, 60, 0.2);
  flex: none;
}
.tab-top-ico {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  color: #F2A900;
}
.tab-top-ico .ico { width: 15px; height: 15px; }
.tab-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FF9600;
  border: 1.5px solid #fff;
}

.garage-panels { min-height: 10.75rem; }
.garage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.garage-grid.grid-top {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.part.garage-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  min-height: 5rem;
  padding: 8px 4px 6px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--line);
  text-transform: none;
  letter-spacing: normal;
  font-size: clamp(0.68rem, 2.6vw, 0.8rem);
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}
.part.garage-tile:hover { background: #F5FAFF; border-color: #C4DCF7; }
.part.garage-tile:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.part.garage-tile[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
  box-shadow: 0 3px 0 var(--accent);
}
.tile-preview {
  display: grid;
  place-items: center;
  pointer-events: none;
}
.tile-preview .mascot {
  width: clamp(3rem, 12vw, 3.75rem);
  pointer-events: none;
  cursor: default;
}
/* Keep mini tile previews calm: only the hero car on stage runs idle motion. */
.tile-preview .mascot * { animation: none !important; }
.tile-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-name .swatch {
  width: 10px;
  height: 10px;
  flex: none;
  border-width: 1.5px;
  border-color: rgba(23, 33, 60, 0.22);
}
.tile-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(.34, 1.56, .64, 1);
  pointer-events: none;
}
.tile-check .ico { width: 11px; height: 11px; }
.part.garage-tile[aria-pressed="true"] .tile-check { opacity: 1; transform: scale(1); }

/* Footer: Back, Save, inline unsaved confirm */
.garage-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding-top: 2px;
}
.garage-back {
  min-height: 3rem;
  padding: 0 18px;
}
.garage-save {
  width: 100%;
  min-height: 3rem;
  font-size: 0.98rem;
}
.garage-save:not(:disabled) {
  background: var(--green-bright);
  border-color: var(--green-bright);
  box-shadow: 0 4px 0 var(--green-deep);
}
.garage-save:hover:not(:disabled) { background: #61D40A; }
.garage-save:active:not(:disabled) { box-shadow: none; }

.garage-confirm {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 2px solid #FFD199;
  border-radius: 16px;
  background: var(--warn-soft);
}
.garage-confirm p {
  margin: 0;
  color: var(--warn);
  font-size: 0.88rem;
  font-weight: 800;
}
.garage-confirm-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.garage-discard {
  color: var(--error);
  border-color: var(--error-bright);
  box-shadow: 0 4px 0 var(--error-bright);
}

/* Narrow desktop (1000-1139px has the 16rem sidebar): keep spacious single column */
@media (min-width: 1000px) and (max-width: 1139px) {
  #view > .page.garage { max-width: 42rem; gap: 16px; }
}

/* Landscape tablet (no sidebar) & wide desktop: two-column racing-game garage */
@media (min-width: 820px) and (max-width: 999px), (min-width: 1140px) {
  #view > .page.garage { max-width: 58rem; gap: 16px; }
  .garage-layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  .stage-arena { min-height: 280px; padding: 16px 12px 24px; }
  .stage-car-slot .mascot { width: clamp(9.5rem, 16vw, 12.5rem); max-width: 100%; }
  .stage-plinth { width: clamp(11.5rem, 20vw, 16rem); max-width: 100%; height: 36px; margin-top: -24px; }
  .compare-car .mascot { width: clamp(6.5rem, 11vw, 8.5rem); }
  .stage-plinth.mini { width: clamp(8rem, 13vw, 10.5rem); height: 24px; margin-top: -16px; }
  .garage-panels { min-height: 12.5rem; }
  .garage-grid.grid-glow, .garage-grid.grid-wheels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .part.garage-tile { min-height: 5.5rem; padding: 10px 4px 8px; }
  .tile-preview .mascot { width: clamp(2.8rem, 4.2vw, 3.75rem); max-width: 100%; }
}

@media (max-width: 400px) {
  .garage-head { gap: 4px 6px; }
  .garage-dirty { padding: 3px 8px; font-size: 0.72rem; }
  .stage-bar { padding: 12px 8px 0; }
  .stage-btn { padding: 0 9px; font-size: 0.76rem; }
  .stage-arena { min-height: 148px; padding: 4px 6px 12px; }
  .garage-grid { gap: 6px; }
  .part.garage-tile { padding: 8px 3px 6px; }
  .tile-name .swatch { display: none; }
}

/* ==================== Profile (#profile) ==================== */
.page.profile {
  display: grid;
  gap: 16px;
  align-content: start;
}

@media (min-width: 720px) {
  #view > .page.profile {
    max-width: 44rem !important;
  }
}

/* Player showcase header */
.profile-head {
  margin-bottom: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid #C6D9F2;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  display: grid;
  justify-items: stretch;
  gap: 0;
  text-align: center;
}
.profile-stage {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 18px 16px 14px;
  background: linear-gradient(180deg, #EBF4FF 0%, #EBF4FF 66%, #D4E1F2 66%, #D4E1F2 100%);
  border-bottom: 2px solid #C6D9F2;
}
.profile-stage .mascot {
  position: relative;
  z-index: 2;
  width: 9.25rem;
}
.profile-stage-plinth {
  position: absolute;
  bottom: 10px;
  width: 11.5rem;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-line);
  box-shadow: 0 5px 0 #9BB6DB;
}
.profile-meta {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px 16px 18px;
}
.profile-meta h1 {
  margin: 0;
  font-size: clamp(1.45rem, 5.5vw, 1.85rem);
  font-weight: 900;
  overflow-wrap: anywhere;
}
.profile-since {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}
.profile-today {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 800;
}
.profile-today .ico { width: 1rem; height: 1rem; }
.profile-today.is-done { background: var(--green-soft); color: var(--green); }
.profile-today.is-pending { background: var(--warn-soft); color: var(--warn); }
.profile-car-btn {
  margin-top: 6px;
  min-height: 3rem;
  padding: 0 20px;
}

@media (min-width: 600px) {
  .profile-head {
    grid-template-columns: 14rem minmax(0, 1fr);
    text-align: left;
  }
  .profile-stage {
    border-bottom: 0;
    border-right: 2px solid #C6D9F2;
    align-content: center;
    padding: 20px 16px;
  }
  .profile-meta {
    justify-items: start;
    align-content: center;
    padding: 20px 22px;
  }
}

/* Quick stats strip */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.profile-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}
.profile-stat-ico {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--sunken);
  display: grid;
  place-items: center;
}
.profile-stat-ico .ico { width: 24px; height: 24px; }
.stat-streak .profile-stat-ico { background: #FFF1DF; }
.stat-streak.is-zero .profile-stat-ico .ico { filter: grayscale(1); opacity: 0.55; }
.stat-xp .profile-stat-ico { background: #FFF7D6; }
.stat-rank .profile-stat-ico { background: var(--accent-soft); }
.stat-gems .profile-stat-ico { background: #E0F4FF; }
.profile-stat-body { min-width: 0; }
.profile-stat .stat {
  margin: 0;
  font-size: clamp(1.15rem, 4.2vw, 1.45rem);
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
}
.profile-stat .label {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.2;
  overflow-wrap: break-word;
}

@media (min-width: 720px) {
  .profile-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Streak freeze shop (direct-child selectors beat style.css `.freeze > div`) */
.profile .panel.freeze {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid #BDE3FF;
  border-radius: 20px;
  background: #F0F9FF;
  box-shadow: 0 3px 0 #CBE7FF;
}
.profile .panel.freeze > .freeze-visual {
  flex: none;
  width: 52px;
  min-width: 0;
  height: 52px;
  border: 2px solid #BDE3FF;
  border-radius: 16px;
  background: #fff;
  display: grid;
  place-items: center;
}
.profile .panel.freeze > .freeze-visual .ico { width: 32px; height: 32px; }
.profile .panel.freeze > .freeze-info { flex: 1 1 11rem; min-width: 0; }
.freeze-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.freeze-slots { display: inline-flex; gap: 4px; }
.freeze-slot {
  width: 24px;
  height: 24px;
  border: 2px dashed #9ACDF2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  display: grid;
  place-items: center;
}
.freeze-slot .ico { width: 15px; height: 15px; opacity: 0.25; filter: grayscale(1); }
.freeze-slot.filled { border-style: solid; border-color: #38BDF8; background: #fff; }
.freeze-slot.filled .ico { opacity: 1; filter: none; }
.profile .panel.freeze > .freeze-cta {
  flex: none;
  min-width: 0;
  display: grid;
  justify-items: end;
  gap: 4px;
  margin-left: auto;
}
.freeze-need { font-size: 0.78rem; font-weight: 800; }

@media (max-width: 480px) {
  .profile .panel.freeze > .freeze-cta { flex: 1 0 100%; width: 100%; justify-items: stretch; margin-left: 0; }
  .profile .panel.freeze > .freeze-cta button { width: 100%; }
  .freeze-need { text-align: center; }
}

/* Profile sections & records */
.profile-section {
  border-top: 0;
  padding-top: 4px;
  margin-top: 0;
  display: grid;
  gap: 12px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.section-head h2 { margin: 0; font-size: 1.2rem; font-weight: 900; }
.section-count {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.78rem;
  font-weight: 800;
}

.profile .records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.profile .panel.record {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--sunken);
}
.record-ico {
  flex: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
}
.record-ico .ico { width: 22px; height: 22px; }
.record-body { min-width: 0; }
.profile .record .stat { margin: 0; font-size: clamp(1.15rem, 4.2vw, 1.4rem); font-weight: 900; line-height: 1.1; }
.profile .record .label {
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.2;
  overflow-wrap: break-word;
}

/* Achievements & level-up highlight */
.levelup-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid #FFC800;
  border-radius: 16px;
  background: #FFF9DB;
  color: #805200;
  font-size: 0.92rem;
  font-weight: 800;
  animation: pop-in 0.35s cubic-bezier(.34, 1.56, .64, 1) both;
}
.levelup-banner .ico { width: 28px; height: 28px; }

.profile .achievements { gap: 12px; }
.profile .achievement {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}
.profile .achievement.locked {
  background: var(--sunken);
  box-shadow: none;
}
.profile .achievement.maxed {
  border-color: #FFD43B;
  background: #FFFDF0;
  box-shadow: 0 3px 0 #F2C94C;
}
.profile .achievement.level-up {
  border-color: #FFC800;
  background: #FFFBE6;
  box-shadow: 0 4px 0 #E5A000;
  animation: ach-level-pop 0.4s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes ach-level-pop {
  0% { transform: scale(0.95); opacity: 0.6; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.profile .achievement-art {
  flex: none;
  width: 4.75rem;
  display: grid;
  justify-items: center;
  gap: 4px;
}
/* Override style.css grayscale on the whole column so level text stays crisp. */
.profile .achievement.locked .achievement-art { filter: none; opacity: 1; }

.ach-medal {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid var(--accent-line);
  border-radius: 16px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
}
.ach-medal > .ico { width: 30px; height: 30px; }
.profile .achievement.locked .ach-medal {
  border-color: var(--line-strong);
  background: #E9EEF6;
}
.profile .achievement.locked .ach-medal > .ico {
  filter: grayscale(1);
  opacity: 0.45;
}
.profile .achievement.maxed .ach-medal,
.profile .achievement.level-up .ach-medal {
  border-color: #FFC800;
  background: #FFF3BF;
}
.ach-lock {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.ach-lock .ico { width: 11px; height: 11px; }

.ach-level { font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.profile .achievement.maxed .ach-level,
.profile .achievement.level-up .ach-level { color: #8A5B00; }

.ach-tiers { display: flex; gap: 3px; }
.ach-tiers i {
  width: 8px;
  height: 5px;
  border-radius: 99px;
  background: var(--line-strong);
}
.ach-tiers i.on { background: var(--accent); }
.profile .achievement.maxed .ach-tiers i.on,
.profile .achievement.level-up .ach-tiers i.on { background: #F5A600; }

.ach-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ach-head strong { font-size: 0.98rem; color: var(--ink); }
.ach-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 800;
}
.ach-pill.is-new { background: #FFC800; color: #5C3A00; }
.ach-pill.is-max { background: #FFF3BF; color: #8A5B00; }
.ach-pill.is-max .ico { width: 12px; height: 12px; color: #F5A600; }
.ach-pill.is-locked { background: var(--line); color: var(--muted); }

.profile .achievement progress { height: 0.65rem; margin: 4px 0 2px; }
.profile .achievement.maxed progress::-webkit-progress-value,
.profile .achievement.level-up progress::-webkit-progress-value { background: #F5A600; }
.profile .achievement.maxed progress::-moz-progress-bar,
.profile .achievement.level-up progress::-moz-progress-bar { background: #F5A600; }

/* Safety callout */
.profile .panel.profile-safety {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--sunken);
}
.profile-safety > .ico { width: 26px; height: 26px; flex: none; margin-top: 2px; }
.profile-safety h2 { margin: 0 0 4px; font-size: 1rem; font-weight: 800; }
.profile-safety p { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* Reduced motion: keep final states visible without motion */
@media (prefers-reduced-motion: reduce) {
  .stage-car-rig,
  .plinth-ticks,
  .tile-check {
    transition: none !important;
  }
  .swap-pop,
  .swap-wheels,
  .swap-top,
  .wobble-left,
  .wobble-right,
  .levelup-banner,
  .profile .achievement.level-up {
    animation: none !important;
  }
}
