:root {
  --cream: #fffbe0;
  --cream-2: #f7f2bf;
  --aqua: #71e7e4;
  --aqua-dark: #38cbd0;
  --navy: #172345;
  --navy-2: #263255;
  --purple: #8062f5;
  --purple-2: #9a5bff;
  --yellow: #ffd84c;
  --orange: #f59c34;
  --pink: #f05b9a;
  --green: #85d553;
  --blue: #65bdf7;
  --line: rgba(20, 29, 67, .22);
  --white: #ffffff;
  --shadow: 0 12px 0 rgba(21, 25, 53, .18), 0 18px 36px rgba(42, 35, 93, .20);
  --radius: 28px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--navy);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(45deg, rgba(128, 226, 224, .75) 25%, transparent 25%) 0 0/72px 72px,
    linear-gradient(45deg, transparent 75%, rgba(128, 226, 224, .75) 75%) 0 0/72px 72px,
    linear-gradient(45deg, transparent 75%, rgba(209, 226, 199, .95) 75%) 36px 36px/72px 72px,
    linear-gradient(45deg, rgba(209, 226, 199, .95) 25%, transparent 25%) 36px 36px/72px 72px,
    #fff8d2;
  background-attachment: fixed;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
a { color: inherit; }
h1, h2, h3, h4, p { margin-top: 0; }
strong { font-weight: 950; }

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(86px + env(safe-area-inset-bottom));
}

.loading-card,
.game-card {
  background: linear-gradient(180deg, var(--cream), #fff6bf);
  border: 5px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.loading-card {
  margin: 18vh auto 0;
  max-width: 540px;
  padding: 26px;
  text-align: center;
  font-weight: 950;
}

.auth-screen {
  display: grid;
  place-items: start center;
  min-height: calc(100vh - 120px);
  padding-top: 20px;
}

.auth-card {
  width: min(760px, 100%);
  padding: 20px;
  overflow: hidden;
}

.auth-hero {
  position: relative;
  text-align: center;
  padding: 16px 10px 20px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 255, 255, .8), transparent 90px),
    linear-gradient(180deg, #e7fbff 0%, #bdefff 55%, #eaffe9 100%);
  border: 4px solid rgba(23, 35, 69, .2);
}

.round-logo {
  display: inline-grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background: radial-gradient(circle at 32% 30%, #fff 0 20%, var(--yellow) 22% 36%, var(--orange) 40% 100%);
  border: 7px solid #f4a541;
  box-shadow: 0 7px 0 rgba(13, 21, 51, .18), inset 0 0 0 5px rgba(255, 255, 255, .3);
  color: var(--navy);
  font-weight: 950;
  text-shadow: 0 2px white;
}

.round-logo.avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
}

.round-logo.mini {
  width: 54px;
  height: 54px;
  border-width: 5px;
  font-size: .9rem;
}

.mini-title {
  margin: 8px 0 4px;
  color: #ffffff;
  font-weight: 950;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #0b1332, 2px 0 0 #0b1332, -2px 0 0 #0b1332;
}

.auth-hero h1,
.journey-title-left h1 {
  margin: 0;
  color: var(--yellow);
  font-size: clamp(2.7rem, 13vw, 5.6rem);
  line-height: .82;
  letter-spacing: -.06em;
  text-shadow: 0 6px 0 #0a1029, 4px 0 0 #0a1029, -4px 0 0 #0a1029, 0 -4px 0 #0a1029;
}

.lead {
  margin: 12px auto 0;
  max-width: 580px;
  line-height: 1.5;
  font-weight: 800;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0 12px;
  padding: 6px;
  background: var(--navy);
  border-radius: 20px;
}

.auth-tab,
.nav-tab {
  min-height: 46px;
  border-radius: 15px;
  background: transparent;
  color: white;
  font-weight: 950;
  text-shadow: 0 2px 0 #0b1332;
}

.auth-tab.active,
.nav-tab.active {
  color: var(--navy);
  background: linear-gradient(180deg, #fff788, var(--yellow));
  text-shadow: 0 2px 0 rgba(255,255,255,.55);
  box-shadow: inset 0 -5px 0 rgba(221, 134, 22, .32);
}

.form-card {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-weight: 950;
}

label span,
label small,
p {
  color: #435070;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 4px solid var(--navy);
  border-radius: 16px;
  min-height: 50px;
  padding: 11px 14px;
  color: var(--navy);
  background: white;
  outline: none;
  box-shadow: inset 0 -4px 0 rgba(23, 35, 69, .08);
}

textarea {
  min-height: 430px;
  resize: vertical;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92rem;
}

input:focus,
textarea:focus {
  border-color: var(--aqua-dark);
  box-shadow: 0 0 0 4px rgba(78, 220, 225, .25), inset 0 -4px 0 rgba(23, 35, 69, .08);
}

input:disabled {
  opacity: .75;
  background: #edf0f8;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.switch-line input {
  width: 22px;
  height: 22px;
  min-height: auto;
  accent-color: var(--purple);
}

.primary-btn,
.soft-btn,
.danger-btn,
.primary-link,
.soft-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 17px;
  font-weight: 950;
  text-decoration: none;
  border: 4px solid var(--navy);
  box-shadow: 0 6px 0 rgba(23, 35, 69, .24);
}

.primary-btn,
.primary-link {
  color: var(--navy);
  background: linear-gradient(180deg, #91f9ff, var(--aqua-dark));
}

.primary-btn.compact { min-height: 44px; }

.soft-btn,
.soft-link {
  color: var(--navy);
  background: linear-gradient(180deg, #fff, #e5f8ff);
}

.danger-btn {
  color: white;
  background: linear-gradient(180deg, #ff86a7, #ef4e74);
  text-shadow: 0 2px 0 #8f193b;
}

button:disabled { opacity: .65; cursor: default; }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 4px 0 rgba(23, 35, 69, .22); }

.message {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 18px;
  border: 4px solid var(--navy);
  font-weight: 950;
  box-shadow: 0 6px 0 rgba(23, 35, 69, .15);
}
.message.error { background: #ffd5dd; }
.message.success { background: #d8ffe1; }
.message.warning { background: #fff2a8; }

.demo-box {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 22px;
  background: rgba(128, 98, 245, .12);
  border: 4px dashed rgba(23, 35, 69, .25);
}
.demo-box p { margin-bottom: 0; }
.demo-accounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.demo-account {
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 10px;
  border-radius: 16px;
  color: var(--navy);
  background: white;
  border: 3px solid var(--navy);
}
.demo-account span { font-size: .82rem; color: #51607e; font-weight: 900; }

.journey-header {
  position: relative;
  overflow: hidden;
  margin: 4px auto 14px;
  padding: 18px;
  background:
    radial-gradient(circle at 9% 82%, rgba(255, 255, 255, .8), transparent 95px),
    linear-gradient(180deg, #e9fbff 0%, #b9ecff 38%, #d9f7c9 72%, #fff2b7 100%);
  border: 6px solid var(--navy);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.journey-header::after {
  content: '';
  position: absolute;
  inset: auto -16px -24px -16px;
  height: 70px;
  background: rgba(128, 98, 245, .78);
  clip-path: polygon(0 35%, 5% 72%, 10% 35%, 15% 72%, 20% 35%, 25% 72%, 30% 35%, 35% 72%, 40% 35%, 45% 72%, 50% 35%, 55% 72%, 60% 35%, 65% 72%, 70% 35%, 75% 72%, 80% 35%, 85% 72%, 90% 35%, 95% 72%, 100% 35%, 100% 100%, 0 100%);
  opacity: .95;
}

.journey-header > * { position: relative; z-index: 1; }
.bulbs {
  position: absolute;
  top: 14px;
  left: 28px;
  right: 28px;
  height: 28px;
  background: radial-gradient(circle, #fff 0 24%, #ffd247 25% 52%, transparent 53%) 0 0/110px 28px;
  opacity: .9;
}

.journey-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}

.journey-title-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.time-pill,
.mode-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: white;
  background: var(--navy);
  border: 3px solid white;
  font-weight: 950;
  text-shadow: 0 2px 0 black;
}

.player-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 12px;
}
.player-info { display: grid; gap: 2px; }
.player-info .mini-title { margin: 0; }
.player-info strong { font-size: 1.2rem; }
.player-info span { color: #405278; font-weight: 950; }

.main-progress {
  position: relative;
  display: grid;
  place-items: center;
  height: 58px;
  overflow: hidden;
  border-radius: 18px;
  background: #1f2949;
  border: 5px solid #0d1530;
  box-shadow: inset 0 5px 0 rgba(255,255,255,.08), 0 5px 0 rgba(255,255,255,.45);
}
.main-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 18px, transparent 18px 36px),
    linear-gradient(180deg, #68f4f0, #21cbd0);
}
.main-progress strong {
  position: relative;
  z-index: 1;
  color: white;
  font-size: 1.55rem;
  text-shadow: 0 3px 0 #071026, 2px 0 0 #071026, -2px 0 0 #071026;
}

.header-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.header-chips span {
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 6px;
  border-radius: 16px;
  color: var(--navy);
  background: rgba(255,255,255,.82);
  border: 4px solid rgba(23,35,69,.23);
  font-weight: 950;
  text-align: center;
}
.header-chips b { font-size: 1.25rem; }

.bottom-tabs {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 14px;
  padding: 6px;
  border-radius: 22px;
  background: var(--navy);
  box-shadow: 0 8px 0 rgba(23, 35, 69, .18);
}
.nav-tab {
  min-height: 42px;
  font-size: .92rem;
}

.content-area { display: grid; gap: 14px; }

.sets-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 12px;
}

.set-tile {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 6px 10px;
  color: var(--navy);
  background: transparent;
  text-align: center;
}
.set-tile h2 {
  margin: -4px 0 0;
  color: white;
  font-size: clamp(.9rem, 3.7vw, 1.2rem);
  line-height: 1;
  text-shadow: 0 3px 0 #071026, 2px 0 0 #071026, -2px 0 0 #071026;
}

.set-medal {
  display: grid;
  place-items: center;
  width: min(28vw, 190px);
  aspect-ratio: 1;
  border-radius: 999px;
  border: 6px solid #f6a13b;
  background: #f9b14c;
  box-shadow: inset 0 0 0 8px rgba(255,255,255,.18), 0 7px 0 rgba(21,25,53,.18);
  overflow: hidden;
}
.set-medal img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
}
.accent-green .set-medal { border-color: #70c947; background: #8ee365; }
.accent-blue .set-medal { border-color: #66b7f0; background: #93d5ff; }
.accent-purple .set-medal { border-color: #7856db; background: #9b7cff; }
.accent-pink .set-medal { border-color: #ea4d90; background: #ff7fb1; }
.accent-yellow .set-medal { border-color: #f2be28; background: #ffdc55; }
.accent-orange .set-medal { border-color: #eb9230; background: #ffa748; }

.set-progress {
  position: relative;
  width: min(27vw, 172px);
  height: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: #1e2949;
  border: 4px solid #132040;
}
.set-progress.detail { width: min(58vw, 280px); }
.set-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.15) 0 14px, transparent 14px 28px),
    linear-gradient(180deg, #67f5ef, #1fc9d0);
}
.set-progress strong {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 100%;
  color: white;
  font-size: .95rem;
  text-shadow: 0 2px 0 #06102a;
}

.set-detail {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: 30px;
  background: var(--purple);
  border: 6px solid var(--navy);
  box-shadow: var(--shadow);
}
.set-detail-header {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 24px;
  background: var(--cream);
  border: 4px solid rgba(23,35,69,.2);
}
.set-detail-header img {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  object-fit: cover;
  border: 5px solid #f0a23f;
}
.set-detail-header h2 {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: clamp(1.9rem, 8vw, 3.3rem);
  line-height: .9;
  text-shadow: 0 4px 0 #071026, 3px 0 0 #071026, -3px 0 0 #071026;
}
.back-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: white;
  background: var(--navy);
  font-size: 2.1rem;
  font-weight: 950;
  line-height: 1;
}
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-actions .soft-btn,
.quick-actions .primary-btn { flex: 1 1 130px; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 10px;
  align-items: start;
}
.card-tile {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.card-image-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 15px;
  background: transparent;
  box-shadow: none;
}
.card-image-btn img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 13px;
  filter: saturate(1.04);
}
.card-tile.missing .card-image-btn img { opacity: .48; filter: saturate(.7); }
.missing-cover {
  position: absolute;
  inset: 10% 8% 16%;
  display: grid;
  place-items: end center;
  padding-bottom: 16%;
  border-radius: 18px;
  color: #70def0;
  background:
    linear-gradient(rgba(23, 167, 191, .80), rgba(31, 136, 172, .88)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.10) 0 12px, transparent 12px 24px);
  border: 4px solid rgba(7, 49, 84, .6);
  box-shadow: inset 0 -18px 0 rgba(10, 54, 83, .36);
  font-size: clamp(.72rem, 3vw, 1rem);
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.missing-cover.gold-cover {
  color: #ffd38a;
  background:
    linear-gradient(rgba(241, 153, 58, .80), rgba(206, 102, 41, .90)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 12px, transparent 12px 24px);
  border-color: rgba(152, 76, 24, .7);
}
.owned-badge,
.trade-badge,
.gold-badge {
  position: absolute;
  z-index: 3;
  border: 3px solid #101833;
  border-radius: 12px;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.owned-badge {
  right: 8%;
  top: 50%;
  min-width: 54px;
  padding: 4px 7px;
  color: white;
  background: #151d34;
}
.trade-badge {
  right: 6%;
  bottom: 18%;
  padding: 3px 7px;
  color: var(--navy);
  background: #fff;
  font-size: .72rem;
  text-shadow: none;
}
.gold-badge {
  left: 7%;
  top: 13%;
  padding: 3px 8px;
  color: #6a3700;
  background: linear-gradient(180deg, #fff3a4, #ffc759);
  text-shadow: none;
  font-size: .78rem;
}
.card-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  width: 88%;
  margin: -8px auto 0;
  padding: 5px;
  border-radius: 999px;
  background: var(--cream);
  border: 4px solid var(--navy);
  box-shadow: 0 5px 0 rgba(23,35,69,.20);
}
.card-controls button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: white;
  background: var(--purple);
  font-size: 1.2rem;
  font-weight: 950;
}
.card-controls strong { min-width: 22px; text-align: center; }

.floating-save {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  min-width: min(460px, calc(100% - 32px));
  min-height: 58px;
  border-radius: 22px;
  border: 5px solid var(--navy);
  color: var(--navy);
  background: linear-gradient(180deg, #93fff9, #23ccd0);
  font-weight: 950;
  box-shadow: 0 8px 0 rgba(23,35,69,.28);
}

.matchmaking-head,
.public-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.matchmaking-head h2 { margin: 0; color: white; text-shadow: 0 3px 0 #071026, 2px 0 0 #071026, -2px 0 0 #071026; }
.matches-list { display: grid; gap: 14px; }
.match-card,
.export-card,
.empty-state,
.profile-layout .game-card {
  padding: 16px;
}
.match-card {
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, var(--cream), #fff6bf);
  border: 5px solid var(--navy);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.match-player {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.match-player h3 { margin: 0; font-size: 1.3rem; }
.match-player p { margin: 2px 0 0; }
.copy-id {
  padding: 2px 7px;
  border-radius: 9px;
  color: var(--navy);
  background: #dcfbff;
  border: 2px solid var(--navy);
  font-weight: 950;
}
.match-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.match-counts span {
  padding: 7px 10px;
  border-radius: 999px;
  color: white;
  background: var(--purple);
  border: 3px solid var(--navy);
  font-weight: 950;
}
.trade-section h4 { margin-bottom: 8px; }
.trade-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.trade-card {
  display: grid;
  gap: 2px;
  min-height: 78px;
  padding: 10px;
  border-radius: 18px;
  border: 4px solid var(--navy);
  background: white;
}
.trade-card span { color: #54617e; font-size: .78rem; font-weight: 950; text-transform: uppercase; }
.trade-card small { color: #53617c; font-weight: 850; }
.trade-card.receive { background: #dcfff2; }
.trade-card.give { background: #e7f7ff; }
.trade-arrow { font-size: 1.4rem; font-weight: 950; }
.empty-state { text-align: center; }

.export-card { display: grid; gap: 12px; }
.profile-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.public-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

@media (max-width: 700px) {
  .app-shell { padding-left: 8px; padding-right: 8px; }
  .form-grid,
  .profile-layout,
  .public-link { grid-template-columns: 1fr; }
  .journey-title-row { display: grid; gap: 12px; }
  .journey-title-left { flex-direction: column; align-items: flex-start; gap: 6px; }
  .journey-title-left h1 { font-size: clamp(3.2rem, 15vw, 5rem); }
  .time-pill { justify-self: start; }
  .header-chips { grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
  .header-chips span { font-size: .78rem; min-height: 42px; padding: 4px 3px; }
  .player-strip { align-items: flex-start; }
  .sets-grid { gap: 13px 4px; }
  .set-medal { border-width: 5px; }
  .set-progress { height: 24px; border-width: 3px; }
  .set-detail { padding: 8px; }
  .set-detail-header { grid-template-columns: auto 58px 1fr; gap: 8px; padding: 8px; }
  .set-detail-header img { width: 58px; height: 58px; border-width: 4px; }
  .back-btn { width: 42px; height: 42px; }
  .cards-grid { gap: 12px 4px; }
  .card-controls { width: 96%; border-width: 3px; }
  .card-controls button { width: 28px; height: 28px; }
  .owned-badge { min-width: 44px; font-size: .82rem; }
  .trade-badge { display: none; }
  .gold-badge { font-size: .68rem; }
  .bottom-tabs { top: 4px; }
  .nav-tab { font-size: .8rem; padding: 4px 2px; }
  .demo-accounts { grid-template-columns: 1fr; }
  .match-player { grid-template-columns: auto 1fr; }
  .match-player .mode-badge { grid-column: 1 / -1; justify-self: start; }
  .trade-pair { grid-template-columns: 1fr; }
  .trade-arrow { text-align: center; }
}

@media (max-width: 420px) {
  .journey-header { padding: 12px; border-width: 5px; }
  .auth-hero h1,
  .journey-title-left h1 { letter-spacing: -.08em; }
  .round-logo.avatar { width: 58px; height: 58px; }
  .player-info strong { font-size: 1rem; }
  .sets-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .set-tile h2 { font-size: .78rem; }
  .set-medal { width: 29vw; }
  .set-progress { width: 29vw; }
  .cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-controls { gap: 1px; padding: 3px; }
  .card-controls button { width: 24px; height: 24px; font-size: 1rem; }
  .missing-cover { border-width: 3px; font-size: .65rem; }
}

/* V3 refinements: compact set screen, full star crops, auto-save, avatars. */
.round-logo { overflow: hidden; }
.round-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.content-area.set-only {
  width: min(760px, 100%);
  margin: 0 auto;
}

.set-only .set-detail {
  gap: clamp(6px, 1.2vh, 12px);
  padding: clamp(7px, 1.4vh, 12px);
}

.set-only .set-detail-header {
  grid-template-columns: auto clamp(46px, 8vh, 68px) 1fr;
  gap: clamp(6px, 1.2vw, 12px);
  padding: clamp(7px, 1.2vh, 10px);
}

.set-only .set-detail-header img {
  width: clamp(46px, 8vh, 68px);
  height: clamp(46px, 8vh, 68px);
}

.set-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.set-title-line h2,
.set-only .set-detail-header h2 {
  margin: 0 0 4px;
  font-size: clamp(1.45rem, 5vh, 2.55rem);
  line-height: .9;
}

.autosave-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 3px solid var(--navy);
  color: var(--navy);
  background: rgba(255, 255, 255, .9);
  font-size: .72rem;
  font-weight: 950;
  box-shadow: 0 3px 0 rgba(23,35,69,.18);
}
.autosave-pill.saving,
.autosave-pill.pending { background: #fff1a8; }
.autosave-pill.saved { background: #d9ffe5; }

.set-only .set-progress.detail {
  width: min(48vw, 260px);
  height: clamp(22px, 3.4vh, 28px);
}

.set-only .back-btn {
  width: clamp(36px, 6.5vh, 46px);
  height: clamp(36px, 6.5vh, 46px);
}

.cards-grid {
  grid-template-columns: repeat(3, minmax(0, min(27vw, 16.3vh, 140px)));
  justify-content: center;
  gap: clamp(5px, 1.25vh, 12px) clamp(7px, 2vw, 18px);
}

.card-tile {
  gap: 0;
  position: relative;
}

.card-image-btn img {
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.card-controls {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 2.5%;
  transform: translateX(-50%);
  width: 78%;
  min-height: 24px;
  margin: 0;
  padding: 2px 4px;
  border-width: 3px;
  box-shadow: 0 3px 0 rgba(23,35,69,.22);
}

.card-controls button {
  width: clamp(19px, 3.6vh, 26px);
  height: clamp(19px, 3.6vh, 26px);
  font-size: clamp(.85rem, 2.8vh, 1.05rem);
}

.card-controls strong {
  min-width: 18px;
  font-size: clamp(.75rem, 2.5vh, .95rem);
}

.owned-badge {
  top: 52%;
  right: 7%;
  min-width: 40px;
  padding: 2px 6px;
  font-size: clamp(.68rem, 2vh, .86rem);
}

.gold-badge {
  top: 10%;
  font-size: clamp(.58rem, 1.7vh, .74rem);
}

.missing-cover {
  inset: 13% 7% 11%;
  padding-bottom: 17%;
}

.avatar-settings {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 8px 0 12px;
  padding: 12px;
  border-radius: 22px;
  background: rgba(255,255,255,.68);
  border: 4px dashed rgba(23,35,69,.22);
}

.round-logo.profile-large {
  width: 104px;
  height: 104px;
  flex: 0 0 auto;
}

.avatar-actions {
  display: grid;
  gap: 8px;
}

.avatar-upload input {
  margin-top: 6px;
  padding: 8px;
  min-height: 44px;
}

.save-hint {
  margin: -4px 0 0;
  font-size: .86rem;
}

.matchmaking-head p {
  margin: 4px 0 0;
  color: white;
  font-size: .9rem;
  text-shadow: 0 2px 0 #071026;
}

@media (max-width: 700px) {
  .content-area.set-only { width: 100%; }
  .set-only .set-detail { border-width: 5px; border-radius: 24px; }
  .set-only .set-detail-header { border-width: 3px; border-radius: 19px; }
  .set-title-line h2,
  .set-only .set-detail-header h2 { font-size: clamp(1.15rem, 4.7vh, 1.95rem); }
  .set-only .set-progress.detail { width: min(54vw, 230px); }
  .cards-grid {
    grid-template-columns: repeat(3, minmax(0, min(29vw, 15.8vh, 126px)));
    gap: clamp(4px, 1vh, 9px) clamp(4px, 1.5vw, 10px);
  }
  .card-controls { width: 82%; padding: 2px 3px; }
  .trade-badge { display: none; }
  .avatar-settings { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .round-logo.profile-large { width: 92px; height: 92px; }
  .matchmaking-head { align-items: flex-start; }
}

@media (max-width: 420px) {
  .cards-grid {
    grid-template-columns: repeat(3, minmax(0, min(30vw, 15.4vh, 116px)));
  }
  .card-controls { width: 86%; }
  .autosave-pill { font-size: .64rem; min-height: 22px; padding: 3px 7px; border-width: 2px; }
  .set-title-line { gap: 3px 6px; }
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 6px;
  padding: 2px 8px;
  border: 3px solid #172345;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe36a, #ffb735);
  color: #172345;
  box-shadow: 0 3px 0 rgba(23,35,69,.25);
  font-size: .72rem;
  font-weight: 900;
  text-shadow: none;
  vertical-align: middle;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.admin-head p {
  margin: 4px 0 0;
}

.admin-list {
  display: grid;
  gap: 12px;
}

.admin-player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-player-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.admin-player-main h3 {
  margin: 0 0 4px;
}

.admin-player-main p,
.admin-player-main small {
  display: block;
  margin: 2px 0;
}

.admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.soft-btn.compact,
.danger-btn.compact {
  min-height: 38px;
  padding: 6px 10px;
  font-size: .82rem;
}

button:disabled,
button[disabled] {
  cursor: not-allowed;
  filter: grayscale(.45);
  opacity: .55;
}

@media (max-width: 700px) {
  .admin-head,
  .admin-player-card {
    align-items: stretch;
    flex-direction: column;
  }
  .admin-actions {
    justify-content: stretch;
  }
  .admin-actions > button {
    flex: 1 1 145px;
  }
}

/* V5.1 production stats, trader matchmaking and trade instructions */
.bottom-tabs {
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
}

.site-stats-strip {
  display: flex;
  gap: 6px;
}
.site-stats-strip span {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 13px;
  color: var(--navy);
  background: rgba(255, 255, 255, .62);
  border: 3px solid rgba(23, 35, 69, .18);
  font-size: .74rem;
  font-weight: 950;
  text-align: center;
}
.site-stats-strip b {
  font-size: 1rem;
}

.discord-link {
  color: #5865f2;
  font-weight: 950;
  text-decoration: none;
}
.discord-link:hover { text-decoration: underline; }

.trader-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 10px;
}
.trader-tile {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
  width: 100%;
  min-height: 235px;
  padding: 12px 8px;
  color: var(--navy);
  text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(226,250,255,.92));
  border: 5px solid var(--navy);
  border-radius: 26px;
  box-shadow: 0 8px 0 rgba(23, 35, 69, .18);
}
.trader-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 0 rgba(23, 35, 69, .18), 0 16px 28px rgba(42, 35, 93, .18);
}
.round-logo.trader-avatar {
  width: min(22vw, 128px);
  height: min(22vw, 128px);
  border-width: 6px;
}
.trader-tile h3 {
  margin: 0;
  width: 100%;
  color: white;
  font-size: clamp(.92rem, 3.6vw, 1.15rem);
  line-height: 1;
  text-shadow: 0 3px 0 #071026, 2px 0 0 #071026, -2px 0 0 #071026;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trader-progress {
  width: min(25vw, 150px);
  height: 25px;
}
.trader-counts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  width: 100%;
}
.trader-counts span {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  padding: 4px 7px;
  border-radius: 999px;
  border: 3px solid var(--navy);
  color: white;
  font-size: .78rem;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(0,0,0,.28);
}
.same-count { background: var(--purple); }
.flex-count { background: linear-gradient(180deg, #61e7a3, #28ba78); }
.flex-count.disabled {
  background: #a7adbf;
  color: #f7f9ff;
  opacity: .82;
}
.trader-tile small {
  width: 100%;
  color: #51607e;
  font-size: .76rem;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 15, 37, .62);
  backdrop-filter: blur(4px);
}
.modal-backdrop.front { z-index: 120; }
.trade-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  padding: 16px;
  border: 6px solid var(--navy);
  border-radius: 30px;
  background: linear-gradient(180deg, var(--cream), #fff6bf);
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; }
.round-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  color: white;
  background: var(--navy);
  font-size: 1.6rem;
  font-weight: 950;
}
.match-player.compact {
  grid-template-columns: auto 1fr;
}
.locked-note {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border: 3px solid rgba(23, 35, 69, .24);
  border-radius: 14px;
  background: #fff1b2;
  color: var(--navy);
  font-size: .88rem;
}
.trade-choice {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 7px 0;
  padding: 10px;
  border: 4px solid var(--navy);
  border-radius: 18px;
  color: var(--navy);
  background: #ffffff;
  box-shadow: 0 5px 0 rgba(23,35,69,.16);
  text-align: left;
}
.trade-choice.same { background: #e3fff5; }
.trade-choice.flex { background: #f0e8ff; }
.trade-choice.disabled { filter: grayscale(.55); opacity: .62; }
.trade-choice span { display: grid; gap: 2px; }
.trade-choice small { color: #53617c; font-weight: 950; }
.trade-choice b { font-size: 1.25rem; }
.instruction-modal .prepared-message {
  min-height: 130px;
  font-size: .88rem;
}
.instruction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 12px;
}
.instruction-grid article {
  padding: 12px;
  border: 4px solid rgba(23,35,69,.22);
  border-radius: 18px;
  background: rgba(255,255,255,.70);
}
.instruction-grid p { margin: 6px 0 8px; }
.copy-id.large {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 1.08rem;
}
.compact-link {
  min-height: 38px;
  padding: 6px 10px;
  border-width: 3px;
  box-shadow: 0 4px 0 rgba(23, 35, 69, .20);
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.modal-actions > * { flex: 1 1 180px; }

.admin-player-main small + small {
  color: #51607e;
}

@media (max-width: 700px) {
  .site-stats-strip { flex-wrap: wrap; gap: 4px; }
  .site-stats-strip span { font-size: .68rem; min-height: 30px; padding: 3px; }
  .trader-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; }
  .trader-tile { min-height: 205px; padding: 9px 6px; border-width: 4px; }
  .round-logo.trader-avatar { width: min(34vw, 106px); height: min(34vw, 106px); }
  .trader-progress { width: min(36vw, 135px); }
  .trader-counts span { font-size: .72rem; padding: 3px 5px; }
  .modal-backdrop { padding: 8px; align-items: end; }
  .trade-modal { max-height: 92vh; border-width: 5px; border-radius: 24px 24px 18px 18px; }
  .trade-choice { grid-template-columns: 1fr; text-align: center; }
  .trade-choice b { transform: rotate(90deg); }
  .instruction-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .site-stats-strip { gap: 4px; }
  .trader-tile h3 { font-size: .82rem; }
  .trader-tile small { font-size: .68rem; }
  .round-logo.trader-avatar { width: min(36vw, 94px); height: min(36vw, 94px); }
}
