/* ==========================================================================
   TOKKUROW - SCREENS (menus, modals, dialogs)
   Full combined file: original + Phase 1 + Phase 3 + Phase 5
   ========================================================================== */

/* ---------- Screen ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--sp-3) + var(--safe-top))
    calc(var(--sp-3) + var(--safe-right))
    calc(var(--sp-3) + var(--safe-bottom))
    calc(var(--sp-3) + var(--safe-left));
  z-index: var(--z-screen);
  background: rgba(6, 4, 2, 0.9);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  opacity: 1;
  visibility: visible;
  transition: opacity var(--dur-slow) var(--ease), visibility var(--dur-slow) var(--ease);
  overflow: hidden;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(160deg, #2a1f14 0%, #1a1209 55%, #0e0805 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255, 220, 160, 0.07);
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 164, 92, 0.3) transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--r-xl);
  right: var(--r-xl);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-mid), transparent);
  pointer-events: none;
}

.card.narrow { max-width: 420px; }
.card.wide { max-width: 720px; }

/* ---------- Card controls ---------- */
.card-x {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 164, 92, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0;
  z-index: 2;
  min-width: 36px;
  min-height: 36px;
  transition: all var(--dur-fast) var(--ease);
}

.card-x:hover {
  background: rgba(192, 57, 43, 0.18);
  border-color: var(--bad);
  color: var(--bad-bright);
  transform: rotate(90deg);
}

.card-x svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.card-back {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(200, 164, 92, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  min-height: 36px;
}

.card-back:hover {
  background: rgba(200, 164, 92, 0.18);
  border-color: var(--gold-2);
}

.card-back svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Brand ---------- */
.brand {
  text-align: center;
  margin-bottom: var(--sp-6);
}

.brand-title {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #f5dc98 0%, #e8c170 35%, #c8a45c 70%, #8a6a2a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  line-height: 1;
  margin-bottom: var(--sp-2);
  filter: drop-shadow(0 3px 12px rgba(232, 193, 112, 0.3));
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--dim);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  font-weight: 600;
}

.brand-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
}

.brand-ornament .line {
  height: 1px;
  width: 44px;
  background: linear-gradient(90deg, transparent, var(--gold-3), transparent);
}

.brand-ornament svg {
  width: 12px;
  height: 12px;
  fill: var(--gold-3);
}

/* ---------- Menu buttons ---------- */
.menu-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.05), rgba(200, 164, 92, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: var(--font);
  transition: all var(--dur-base) var(--ease);
  min-height: 56px;
  position: relative;
  overflow: hidden;
}

.menu-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold), var(--gold-3));
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}

.menu-btn:hover {
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.12), rgba(200, 164, 92, 0.04));
  border-color: var(--border-hover);
  transform: translateX(2px);
}

.menu-btn:hover::before { opacity: 1; }

.menu-btn .mbi {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(232, 193, 112, 0.18), rgba(200, 164, 92, 0.06));
  border: 1px solid rgba(200, 164, 92, 0.25);
}

.menu-btn .mbi svg {
  width: 20px;
  height: 20px;
  stroke: var(--gold);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-btn .txt {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.menu-btn .title {
  font-size: var(--fs-sm);
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-btn .desc {
  font-size: var(--fs-xs);
  color: var(--dim);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Section label ---------- */
.section-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--gold-3);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: var(--sp-5) 0 var(--sp-3);
  font-weight: 800;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* ---------- Difficulty picker ---------- */
.diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--sp-3);
}

.diff-btn {
  flex: 1 1 calc(20% - 4px);
  min-width: 60px;
  padding: var(--sp-2) 2px;
  text-align: center;
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.05), rgba(200, 164, 92, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-2xs);
  font-weight: 700;
  transition: all var(--dur-fast) var(--ease);
  overflow: hidden;
}

.diff-btn .lbl {
  display: block;
  font-size: var(--fs-sm);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diff-btn .sub {
  font-size: 0.55rem;
  opacity: 0.75;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.diff-btn.selected {
  background: linear-gradient(180deg, #f0d28a, #e8c170 40%, #c8a45c);
  color: #1a1410;
  border-color: var(--gold);
  box-shadow: 0 3px 14px rgba(232, 193, 112, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.diff-btn:hover:not(.selected) {
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.12), rgba(200, 164, 92, 0.05));
  border-color: var(--border-hover);
}

/* ---------- Theme pickers ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.theme-btn {
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.05), rgba(200, 164, 92, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 700;
  min-width: 0;
  transition: all var(--dur-fast) var(--ease);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-btn .swatch {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 0 0 6px;
}

.theme-btn .swatch span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.35), inset 2px 2px 3px rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.theme-btn.selected {
  background: linear-gradient(180deg, rgba(232, 193, 112, 0.22), rgba(200, 164, 92, 0.10));
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(232, 193, 112, 0.18);
}

/* ---------- Text input ---------- */
.text-input {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  min-height: 44px;
}

.text-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 193, 112, 0.15);
}

.text-input::placeholder {
  color: var(--dim-2);
  font-weight: 500;
}

/* ---------- Profile ---------- */
.profile-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #f0d28a, #e8c170 40%, #8a6a2a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #1a1410;
  box-shadow: 0 6px 20px rgba(232, 193, 112, 0.35), inset 0 2px 3px rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 220, 160, 0.35);
}

.profile-head .pinfo { flex: 1; min-width: 0; }

.profile-head .pname {
  font-size: var(--fs-lg);
  font-weight: 800;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-head .plevel {
  font-size: var(--fs-xs);
  color: var(--dim);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-bar {
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.level-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #f0d28a, #e8c170 40%, #c8a45c);
  border-radius: var(--r-pill);
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 8px rgba(232, 193, 112, 0.5);
}

.level-bar-txt {
  font-size: 0.6rem;
  color: var(--dim-2);
  font-weight: 600;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.stat-box {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.22));
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.stat-box .n {
  font-size: var(--fs-lg);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  letter-spacing: -0.5px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-box .l {
  font-size: var(--fs-2xs);
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-box.blue .n  { color: var(--blue); }
.stat-box.green .n { color: var(--ok-bright); }
.stat-box.red .n   { color: var(--warn); }

/* ---------- Achievements ---------- */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.ach {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.22));
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  transition: all var(--dur-base) var(--ease);
  min-width: 0;
  overflow: hidden;
}

.ach.locked {
  opacity: 0.4;
  filter: grayscale(0.7);
}

.ach.unlocked {
  border-color: rgba(232, 193, 112, 0.55);
  background: linear-gradient(180deg, rgba(232, 193, 112, 0.10), rgba(0, 0, 0, 0.3));
  box-shadow: 0 0 14px rgba(232, 193, 112, 0.15);
}

.ach .aicon {
  font-size: 1.3rem;
  margin-bottom: 4px;
  line-height: 1;
}

.ach .atitle {
  font-size: var(--fs-2xs);
  font-weight: 700;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ach .adesc {
  font-size: 0.55rem;
  color: var(--dim);
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- Leaderboard ---------- */
.lb-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid transparent;
  min-width: 0;
}

.lb-row.me {
  background: linear-gradient(90deg, rgba(232, 193, 112, 0.14), rgba(0, 0, 0, 0.25));
  border-color: var(--gold-3);
}

.lb-row .rank {
  width: 26px;
  text-align: center;
  font-weight: 800;
  font-size: var(--fs-xs);
  color: var(--dim);
  flex-shrink: 0;
}

.lb-row.me .rank { color: var(--gold); }

.lb-row .name {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.lb-row .pts {
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---------- Online list ---------- */
.online-list {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: var(--sp-3);
}

.online-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  margin-bottom: 5px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  min-width: 0;
}

.online-row .av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--fs-xs);
  color: #1a1410;
  background: linear-gradient(135deg, var(--gold), #8a6a2a);
}

.online-row .inf { flex: 1; min-width: 0; }

.online-row .n {
  font-size: var(--fs-sm);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-row .s {
  font-size: var(--fs-2xs);
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-row .s .live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.online-row button {
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  min-height: 34px;
  flex-shrink: 0;
}

/* ---------- Settings rows ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid rgba(200, 164, 92, 0.08);
  min-width: 0;
}

.setting-row:last-child { border-bottom: none; }

.setting-row .slabel { flex: 1; min-width: 0; }

.setting-row .slabel .sn {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.setting-row .slabel .sd {
  font-size: var(--fs-xs);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slider {
  width: 110px;
  max-width: 40%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--r-pill);
  outline: none;
  flex-shrink: 0;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f0d28a, #c8a45c);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border: 1px solid var(--gold-3);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f0d28a, #c8a45c);
  cursor: pointer;
  border: 1px solid var(--gold-3);
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease);
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #8a7a62, #5e5044);
  transition: all var(--dur-base) var(--ease-spring);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.toggle.on {
  background: linear-gradient(180deg, rgba(232, 193, 112, 0.35), rgba(200, 164, 92, 0.20));
  border-color: var(--gold);
}

.toggle.on::after {
  left: 22px;
  background: linear-gradient(180deg, #f0d28a, #e8c170);
  box-shadow: 0 0 8px rgba(232, 193, 112, 0.6), 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ---------- Share ---------- */
.share-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.share-btn {
  padding: var(--sp-3) var(--sp-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.22));
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-2xs);
  font-weight: 700;
  min-height: 64px;
  min-width: 0;
  transition: all var(--dur-base) var(--ease);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  background: linear-gradient(180deg, rgba(200, 164, 92, 0.12), rgba(0, 0, 0, 0.24));
}

.share-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.share-btn.whatsapp svg { fill: #25D366; }
.share-btn.facebook svg { fill: #1877F2; }
.share-btn.twitter svg  { fill: var(--text); }
.share-btn.link svg {
  stroke: var(--gold);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Prose ---------- */
.card h2 {
  color: var(--gold);
  font-size: var(--fs-xl);
  font-weight: 800;
  margin-bottom: var(--sp-3);
  letter-spacing: 0.01em;
  overflow-wrap: break-word;
}

.card h3 {
  color: var(--text-2);
  font-size: var(--fs-md);
  font-weight: 700;
  margin: var(--sp-4) 0 var(--sp-2);
  overflow-wrap: break-word;
}

.card p,
.card li {
  color: var(--dim);
  font-size: var(--fs-sm);
  line-height: 1.6;
  margin-bottom: var(--sp-2);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.card ul {
  padding-left: var(--sp-5);
  margin-bottom: var(--sp-3);
}

.card .rule-key { color: var(--gold); font-weight: 700; }

.card .warn {
  color: var(--warn);
  font-size: var(--fs-xs);
  padding: var(--sp-3);
  background: linear-gradient(180deg, rgba(200, 100, 50, 0.10), rgba(200, 100, 50, 0.05));
  border-left: 3px solid var(--warn);
  border-radius: var(--r-xs);
  margin: var(--sp-3) 0;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.card .dev-credit {
  text-align: center;
  font-size: var(--fs-2xs);
  color: rgba(200, 164, 92, 0.55);
  margin-top: var(--sp-5);
  padding-top: var(--sp-3);
  border-top: 1px solid rgba(200, 164, 92, 0.10);
  letter-spacing: 0.04em;
  font-weight: 600;
  overflow-wrap: break-word;
}

/* ---------- Button row ---------- */
.btn-row {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--sp-4);
}

.btn-row button {
  flex: 1;
  min-width: 100px;
  min-height: 44px;
  padding: 0 var(--sp-4);
}

/* ---------- Game over ---------- */
.go-trophy {
  font-size: clamp(2.6rem, 8vw, 3.6rem);
  margin-bottom: var(--sp-2);
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 8px 28px rgba(232, 193, 112, 0.6));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.go-title {
  color: var(--gold);
  font-size: var(--fs-2xl);
  font-weight: 800;
  text-align: center;
  margin-bottom: var(--sp-2);
  letter-spacing: 0.02em;
}

.go-reason {
  color: var(--dim);
  font-size: var(--fs-sm);
  text-align: center;
  line-height: 1.5;
  margin-bottom: var(--sp-5);
  overflow-wrap: break-word;
}

.final-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.25));
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}

.final-scores .side { text-align: center; min-width: 0; }

.final-scores .n {
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.final-scores .l {
  font-size: var(--fs-2xs);
  color: var(--dim);
  letter-spacing: 0.10em;
  margin-top: 4px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-scores .p0n { color: var(--gold); }
.final-scores .p1n { color: var(--blue); }

/* ---------- Pause ---------- */
.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-pause);
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--sp-3) + var(--safe-top))
    calc(var(--sp-3) + var(--safe-right))
    calc(var(--sp-3) + var(--safe-bottom))
    calc(var(--sp-3) + var(--safe-left));
  background: rgba(6, 4, 2, 0.88);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  opacity: 1;
  visibility: visible;
  transition: opacity var(--dur-slow) var(--ease), visibility var(--dur-slow) var(--ease);
}

.pause-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pause-card {
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(160deg, #2a1f14 0%, #1a1209 55%, #0e0805 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255, 220, 160, 0.07);
  position: relative;
  text-align: center;
  overscroll-behavior: contain;
}

.pause-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--sp-4);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(232, 193, 112, 0.18), rgba(200, 164, 92, 0.08));
  border: 1px solid rgba(232, 193, 112, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(232, 193, 112, 0.2);
}

.pause-icon svg {
  width: 26px;
  height: 26px;
  stroke: var(--gold);
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.pause-title {
  color: var(--gold);
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.pause-sub {
  color: var(--dim);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-5);
  line-height: 1.4;
}

.pause-btns {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.pause-btns button {
  width: 100%;
  padding: var(--sp-3);
  font-size: var(--fs-sm);
  min-height: 44px;
}

/* ---------- Resume banner ---------- */
.resume-banner {
  display: none;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  background: linear-gradient(90deg, rgba(39, 174, 96, 0.18), rgba(39, 174, 96, 0.04));
  border: 1px solid rgba(39, 174, 96, 0.4);
  border-radius: var(--r-md);
  min-width: 0;
}

.resume-banner.show { display: flex; }

.resume-banner .rb-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(39, 174, 96, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.resume-banner .rb-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--ok-bright);
  fill: none;
  stroke-width: 2.2;
}

.resume-banner .rb-txt { flex: 1; min-width: 0; }

.resume-banner .rb-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ok-bright);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-banner .rb-desc {
  font-size: var(--fs-2xs);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-banner button {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  background: linear-gradient(180deg, rgba(39, 174, 96, 0.28), rgba(39, 174, 96, 0.15));
  border-color: var(--ok);
  color: var(--ok-bright);
  min-height: 34px;
  flex-shrink: 0;
}

/* ---------- Benchmark ---------- */
.bench-output {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ok-bright);
  max-height: 220px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* ==========================================================================
   PHASE 1 — Leaderboard tabs, personal records, profile diff table,
             recent-match history, honest empty states
   ========================================================================== */

/* ---------- Leaderboard tabs ---------- */
.lb-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--sp-3);
  padding: 3px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.lb-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
}
.lb-tab:hover {
  color: var(--text);
  background: rgba(200, 164, 92, 0.08);
}
.lb-tab.selected {
  background: linear-gradient(180deg,
    rgba(232, 193, 112, 0.22),
    rgba(200, 164, 92, 0.10));
  color: var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ---------- Leaderboard personal-record rows ---------- */
.lb-records {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-record {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-3);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.lb-record .lr-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  line-height: 1;
}
.lb-record .lr-label {
  flex: 1;
  font-size: var(--fs-xs);
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-record .lr-value {
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---------- Honest empty states ---------- */
.lb-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--dim);
  line-height: 1.6;
}
.lb-empty-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  line-height: 1;
}
.lb-empty-title {
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--text-2);
  margin-bottom: 6px;
}
.lb-empty-text {
  font-size: var(--fs-xs);
  max-width: 320px;
  margin: 0 auto;
}

.lb-extra {
  font-size: var(--fs-2xs);
  color: var(--dim-2);
  font-weight: 500;
  margin-left: 4px;
}

/* ---------- Profile · difficulty table ---------- */
.diff-stats-table {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.diff-stat-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px var(--sp-3);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
}
.diff-stat-row .ds-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diff-stat-row .ds-num {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.diff-stat-row .ds-rate {
  min-width: 44px;
  text-align: right;
  color: var(--gold);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- Profile · recent matches ---------- */
.hist-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hist-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px var(--sp-3);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
}
.hist-row .h-tag {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.6rem;
  flex-shrink: 0;
  line-height: 1;
}
.hist-row.win  .h-tag { background: rgba(39, 174, 96, 0.25);  color: var(--ok-bright); }
.hist-row.loss .h-tag { background: rgba(192, 57, 43, 0.25);  color: var(--bad-bright); }
.hist-row.draw .h-tag { background: rgba(127, 184, 232, 0.22); color: var(--blue); }
.hist-row .h-body {
  flex: 1;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-row .h-diff {
  font-size: var(--fs-2xs);
  color: var(--dim-2);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.hist-row .h-date {
  font-size: var(--fs-2xs);
  color: var(--dim-2);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 46px;
  text-align: right;
}
.hist-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--dim);
  font-size: var(--fs-xs);
}

/* ==========================================================================
   PHASE 3 — PWA logo in menu brand
   ========================================================================== */
.brand-logo {
  display: block;
  width: clamp(72px, 20vw, 128px);
  height: auto;
  max-height: 128px;
  margin: 0 auto var(--sp-3);
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(232, 193, 112, 0.35));
  user-select: none;
  -webkit-user-drag: none;
}
@media (max-height: 520px) {
  .brand-logo {
    width: clamp(56px, 14vw, 88px);
    margin-bottom: var(--sp-2);
  }
}

/* ==========================================================================
   PHASE 5 — Glove collection
   ========================================================================== */
.glove-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-3);
}
.glove-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  min-height: 56px;
}
.glove-btn:hover:not(.locked) {
  border-color: var(--border-hover);
  background: rgba(200, 164, 92, 0.08);
}
.glove-btn.selected {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(232, 193, 112, 0.25);
  background: linear-gradient(180deg,
    rgba(232, 193, 112, 0.12),
    rgba(0, 0, 0, 0.28));
}
.glove-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.glove-btn .gswatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow:
    inset -3px -3px 6px rgba(0, 0, 0, 0.4),
    inset 3px 3px 5px rgba(255, 255, 255, 0.25),
    0 2px 6px rgba(0, 0, 0, 0.3);
}
.glove-btn .ginfo { flex: 1; min-width: 0; }
.glove-btn .gname {
  font-size: var(--fs-sm);
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.glove-btn .gsub {
  font-size: var(--fs-2xs);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ============================================================
   v8 additions — match cards, global rankings, achievements
   ============================================================ */
.go-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.match-card {
  min-width: 0;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .1);
  display: flex; flex-direction: column; gap: 6px;
}
.match-card.p0 { border-color: rgba(232, 193, 112, .35); }
.match-card.p1 { border-color: rgba(127, 184, 232, .35); }
.match-card.winner { box-shadow: 0 0 0 1px currentColor inset, 0 0 18px rgba(232, 193, 112, .18); }
.mc-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mc-avatar {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .8rem; background: rgba(255, 255, 255, .1);
}
.match-card.p0 .mc-avatar { color: var(--gold); }
.match-card.p1 .mc-avatar { color: var(--blue); }
.mc-name {
  min-width: 0; flex: 1; font-weight: 800; font-size: .82rem; line-height: 1.2;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.mc-result { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; color: var(--dim); }
.match-card.winner .mc-result { color: var(--gold); }
.mc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.mc-stat { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.mc-v { font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.mc-l { font-size: .56rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
@media (max-width: 380px) { .go-cards { grid-template-columns: 1fr; } }

/* Global rankings */
.lb-note { font-size: .72rem; color: var(--dim); line-height: 1.4; margin-bottom: 10px; }
.lb-status { font-size: .74rem; line-height: 1.4; padding: 8px 10px; border-radius: 10px; margin-bottom: 10px; background: rgba(255, 255, 255, .05); color: var(--dim); }
.lb-status.warn { background: rgba(255, 150, 80, .12); color: #ffcf9f; border: 1px solid rgba(255, 150, 80, .35); }
.lb-retry, .lb-more {
  margin-left: 6px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  background: rgba(232, 193, 112, .15); color: var(--gold); border: 1px solid rgba(232, 193, 112, .45); font-weight: 700; font-size: .74rem;
}
.lb-more { display: block; margin: 10px auto 0; padding: 8px 20px; }
.lb-more.hidden { display: none; }
.lb-me-card { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; justify-content: center; padding: 8px 10px; margin-bottom: 10px; border-radius: 10px; background: rgba(232, 193, 112, .1); border: 1px solid rgba(232, 193, 112, .3); font-size: .74rem; color: var(--dim); }
.lb-me-card b { font-size: 1.15rem; color: var(--gold); font-variant-numeric: tabular-nums; }
#lbBody { max-height: min(52vh, 460px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
#lbBody.cached { opacity: .72; filter: saturate(.7); }
#lbBody .lb-row {
  display: grid; grid-template-columns: 2.2em 34px minmax(0, 1fr) auto; align-items: center;
  gap: 8px; padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, .06);
}
#lbBody .lb-row.me { background: rgba(232, 193, 112, .08); border-radius: 8px; }
#lbBody .lb-row .rank { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-av { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: rgba(255, 255, 255, .08); }
.lb-av-fallback { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--gold); }
.lb-main { display: flex; flex-direction: column; min-width: 0; }
.lb-name { font-weight: 800; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name em { font-style: normal; color: var(--gold); font-weight: 700; }
.lb-sub { font-size: .62rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbBody .lb-row .pts { font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums; text-align: right; }
#lbBody .lb-row .pts small { display: block; font-size: .52rem; color: var(--dim); letter-spacing: .1em; text-transform: uppercase; }
@media (max-width: 380px) { #lbBody .lb-row { grid-template-columns: 1.8em 28px minmax(0, 1fr) auto; gap: 6px; } .lb-av { width: 28px; height: 28px; } }

/* Achievement progress + unlock popup */
.ach .aprog { height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .1); margin-top: 6px; overflow: hidden; }
.ach .aprog > div { height: 100%; background: var(--gold); }
.ach .aprogtxt { font-size: .58rem; color: var(--dim); margin-top: 3px; font-variant-numeric: tabular-nums; }
#achPopup {
  position: fixed; left: 50%; top: calc(var(--safe-top, 0px) + 64px); z-index: 200;
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px; max-width: min(92vw, 380px);
  padding: 10px 16px; border-radius: 14px;
  background: linear-gradient(180deg, #2b2013, #1a120a); border: 1px solid rgba(232, 193, 112, .6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 22px rgba(232, 193, 112, .25);
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), opacity .3s;
}
#achPopup.show { transform: translate(-50%, 0); opacity: 1; }
#achPopup .ap-icon { font-size: 1.9rem; }
#achPopup .ap-text { display: flex; flex-direction: column; min-width: 0; }
#achPopup b { font-size: .56rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
#achPopup strong { font-size: .92rem; }
#achPopup small { font-size: .7rem; color: var(--dim); }

/* Gloves shop */
.coin-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 10px; margin-bottom: 8px; border-radius: 10px; background: rgba(232,193,112,.1); border: 1px solid rgba(232,193,112,.3); font-size: .9rem; }
.coin-bar span { font-size: .66rem; color: var(--dim); flex-basis: 100%; }
.glove-btn .gtag { font-size: .58rem; letter-spacing: .12em; font-weight: 800; color: var(--gold); }
.cap-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cap-chip { padding: 6px 10px; border-radius: 999px; font-weight: 800; font-size: .7rem; letter-spacing: .06em; cursor: pointer; color: var(--text, #f2e6cf); background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.16); max-width: 100%; }
.cap-chip small { color: var(--gold); font-weight: 700; }
.cap-chip.locked { opacity: .75; border-style: dashed; }
.cap-chip.selected { border-color: var(--gold); background: rgba(232,193,112,.16); }

/* Online */
.online-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; margin: 0 0 8px; border-radius: 999px; font-size: .74rem; background: rgba(39,174,96,.14); border: 1px solid rgba(39,174,96,.4); color: var(--ok-bright); }
.online-pill[hidden] { display: none; }
.live-dot { color: #2ecc71; animation: turnTimerPulse 1.6s ease-in-out infinite; }
.online-hero { text-align: center; padding: 14px 0 10px; }
.online-count { font-size: 2.6rem; font-weight: 900; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.online-sub { font-size: .76rem; color: var(--dim); margin-top: 4px; }
.online-status { min-height: 1.4em; text-align: center; font-size: .8rem; color: var(--dim); margin-bottom: 10px; }
#btnFindMatch, #btnCancelMatch { width: 100%; margin-top: 4px; }
#btnFindMatch.hidden, #btnCancelMatch.hidden { display: none; }
.theme-seg { display: flex; gap: 6px; margin-bottom: 8px; }
.theme-seg button { flex: 1; padding: 9px 0; border-radius: 10px; cursor: pointer; font-weight: 800; background: rgba(255,255,255,.05); color: var(--text); border: 1px solid var(--border); }
.theme-seg button.selected { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }

/* ============ LIGHT MODE ============ */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4ecdc; --bg-deep: #e9dfca;
  --surface: rgba(255,250,240,.96); --surface-2: rgba(250,243,228,.97);
  --gold: #8f5f0c; --gold-2: #7d530a; --gold-3: #6a4408; --gold-4: #573607;
  --gold-soft: rgba(143,95,12,.12); --gold-mid: rgba(143,95,12,.28); --gold-strong: rgba(143,95,12,.5);
  --blue: #1d5c96; --blue-2: #184f82; --blue-3: #134069;
  --blue-soft: rgba(29,92,150,.12); --blue-mid: rgba(29,92,150,.28); --blue-strong: rgba(29,92,150,.5);
  --text: #2a1d0e; --text-2: #3f2e18; --text-3: #58442a;
  --dim: #6a5638; --dim-2: #85704c; --dim-3: #a89878;
  --ok-bright: #1c8449; --bad-bright: #a5302a; --warn: #b05a1a;
  --border: rgba(110,76,18,.24); --border-hover: rgba(110,76,18,.4); --border-strong: rgba(110,76,18,.55);
}
html[data-theme="light"] .screen { background: rgba(244,236,220,.9); }
html[data-theme="light"] .card { background: linear-gradient(160deg,#fffaf0 0%,#f6ecd8 60%,#ecdfc3 100%); box-shadow: 0 18px 50px rgba(80,55,15,.28), inset 0 1px 0 rgba(255,255,255,.8); }
html[data-theme="light"] .badge { background: linear-gradient(180deg, rgba(255,250,240,.97), rgba(243,233,212,.97)); box-shadow: 0 6px 18px rgba(80,55,15,.22); }
html[data-theme="light"] .menu-btn { background: linear-gradient(180deg, rgba(120,84,20,.06), rgba(120,84,20,.02)); }
html[data-theme="light"] .text-input { background: rgba(255,255,255,.8); color: var(--text); }
html[data-theme="light"] .stat-box, html[data-theme="light"] .match-card, html[data-theme="light"] .cap-chip,
html[data-theme="light"] .theme-seg button, html[data-theme="light"] .lb-status, html[data-theme="light"] .ach { background: rgba(120,84,20,.06); }
html[data-theme="light"] .lb-row, html[data-theme="light"] #lbBody .lb-row { border-bottom-color: rgba(110,76,18,.14); }
html[data-theme="light"] .lb-av { background: rgba(110,76,18,.12); }
html[data-theme="light"] #toast { background: rgba(255,250,240,.97); color: var(--text); border-color: var(--border-strong); }
html[data-theme="light"] #achPopup { background: linear-gradient(180deg,#fffaf0,#f1e4c8); }
html[data-theme="light"] .badge .turn-clock.active { color: var(--gold); }


/* ========================================================================
   LIGHT THEME — complete readable foreground/background pairing.
   Keep the existing layout, artwork and component geometry unchanged.
   ======================================================================== */
html[data-theme="light"] {
  color-scheme: light;
  --text: #20170d;
  --text-2: #302313;
  --text-3: #49351d;
  --dim: #594326;
  --dim-2: #6b5435;
  --dim-3: #786344;
  --border: rgba(70, 48, 18, .28);
  --border-hover: rgba(70, 48, 18, .45);
  --border-strong: rgba(70, 48, 18, .62);
  --gold: #704600;
  --gold-2: #684000;
  --gold-3: #593600;
  --gold-4: #492c00;
  --blue: #174f82;
  --blue-2: #12436f;
  --blue-3: #0e365b;
}
html[data-theme="light"] body,
html[data-theme="light"] .screen,
html[data-theme="light"] .screen :not(svg):not(path):not(circle):not(rect):not(line):not(polyline):not(polygon) {
  text-shadow: none;
}
html[data-theme="light"] .screen,
html[data-theme="light"] .screen p,
html[data-theme="light"] .screen label,
html[data-theme="light"] .screen small,
html[data-theme="light"] .screen span,
html[data-theme="light"] .screen li,
html[data-theme="light"] .screen .sub,
html[data-theme="light"] .screen .desc,
html[data-theme="light"] .screen .hint,
html[data-theme="light"] .screen .muted,
html[data-theme="light"] .screen .lb-status,
html[data-theme="light"] .screen .online-sub,
html[data-theme="light"] .screen .online-status,
html[data-theme="light"] .screen .s,
html[data-theme="light"] .screen .sc,
html[data-theme="light"] .screen .lr-label,
html[data-theme="light"] .screen .meta,
html[data-theme="light"] .screen .caption,
html[data-theme="light"] .screen .secondary-text {
  color: var(--dim);
}
html[data-theme="light"] .screen h1,
html[data-theme="light"] .screen h2,
html[data-theme="light"] .screen h3,
html[data-theme="light"] .screen h4,
html[data-theme="light"] .screen strong,
html[data-theme="light"] .screen b,
html[data-theme="light"] .screen .title,
html[data-theme="light"] .screen .name,
html[data-theme="light"] .screen .n,
html[data-theme="light"] .screen .value,
html[data-theme="light"] .screen .lb-name,
html[data-theme="light"] .screen .lb-points,
html[data-theme="light"] .screen .stat-value,
html[data-theme="light"] .screen .menu-title {
  color: var(--text);
}
html[data-theme="light"] .screen a:not(.primary),
html[data-theme="light"] .screen a:visited { color: #174f82; }
html[data-theme="light"] .screen button,
html[data-theme="light"] .screen input,
html[data-theme="light"] .screen select,
html[data-theme="light"] .screen textarea {
  color: var(--text);
}
html[data-theme="light"] .screen button:not(.primary):not(.danger),
html[data-theme="light"] .screen .menu-btn,
html[data-theme="light"] .screen .tab-btn,
html[data-theme="light"] .screen .theme-seg button,
html[data-theme="light"] .screen .lb-tab,
html[data-theme="light"] .screen .online-row button,
html[data-theme="light"] .screen .glove-btn,
html[data-theme="light"] .screen .cap-chip {
  color: var(--text);
  border-color: var(--border-strong);
}
html[data-theme="light"] .screen button:disabled,
html[data-theme="light"] .screen button[disabled] {
  color: #65553e;
  opacity: .78;
}
html[data-theme="light"] .screen button.primary { color: #fffdf7; }
html[data-theme="light"] .screen button.danger { color: #fff; }
html[data-theme="light"] .screen button.selected,
html[data-theme="light"] .screen .selected button,
html[data-theme="light"] .screen .tab-btn.active,
html[data-theme="light"] .screen .lb-tab.active,
html[data-theme="light"] .screen .theme-seg button.selected {
  color: #563500;
}
html[data-theme="light"] .screen input,
html[data-theme="light"] .screen select,
html[data-theme="light"] .screen textarea,
html[data-theme="light"] .screen .text-input {
  background: #fffefa;
  color: #20170d;
  border: 1px solid rgba(70,48,18,.42);
}
html[data-theme="light"] .screen input::placeholder,
html[data-theme="light"] .screen textarea::placeholder { color: #6b5a40; opacity: 1; }
html[data-theme="light"] .screen input:focus,
html[data-theme="light"] .screen select:focus,
html[data-theme="light"] .screen textarea:focus {
  outline: 2px solid rgba(23,79,130,.55);
  outline-offset: 1px;
}
html[data-theme="light"] .screen svg { opacity: 1; }
html[data-theme="light"] .screen svg:not([fill]) { color: currentColor; }
html[data-theme="light"] .screen .card,
html[data-theme="light"] .screen .stat-box,
html[data-theme="light"] .screen .match-card,
html[data-theme="light"] .screen .ach,
html[data-theme="light"] .screen .cap-chip,
html[data-theme="light"] .screen .lb-status,
html[data-theme="light"] .screen .lb-me-card,
html[data-theme="light"] .screen .lb-row,
html[data-theme="light"] .screen .online-row,
html[data-theme="light"] .screen .theme-seg button,
html[data-theme="light"] .screen .glove-btn {
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="light"] .screen .badge,
html[data-theme="light"] .screen .pill,
html[data-theme="light"] .screen .tag,
html[data-theme="light"] .screen .status,
html[data-theme="light"] .screen .online-pill {
  text-shadow: none;
}
html[data-theme="light"] #toast,
html[data-theme="light"] #achPopup,
html[data-theme="light"] .modal,
html[data-theme="light"] .popup {
  color: var(--text);
}
html[data-theme="light"] #toast *,
html[data-theme="light"] #achPopup * { text-shadow: none; }
html[data-theme="light"] .badge .nm { color: var(--text); }
/* The in-game player badges are dark team-colored overlays, not light cards. */
html[data-theme="light"] .badge .nm,
html[data-theme="light"] .badge .sc,
html[data-theme="light"] .badge .turn-clock,
html[data-theme="light"] .badge.p0 .nm,
html[data-theme="light"] .badge.p1 .nm { color: #fffaf0; }
html[data-theme="light"] .badge .sc { color: #f0e2c6; }
html[data-theme="light"] .badge .turn-clock.active { color: #fff0bd; }
html[data-theme="light"] .badge .turn-clock.low { color: #ffd0c8; }
html[data-theme="light"] #centerInfo { color: #fffaf0; }
html[data-theme="light"] #centerInfo .ci-main { color: #fffaf0; }
html[data-theme="light"] #centerInfo .ci-stats,
html[data-theme="light"] #centerInfo .ci-match,
html[data-theme="light"] .sideStats .lbl,
html[data-theme="light"] .sideStats .sub { color: #f0e2c6; }
html[data-theme="light"] #sideStatsP0 .big { color: #f0d28a; }
html[data-theme="light"] #sideStatsP1 .big { color: #b8dcff; }

/* Game chrome is outside .screen, so give it its own light-theme contrast rules. */
html[data-theme="light"] #controls button {
  color: #20170d;
  background: linear-gradient(180deg, #fffefa, #eee3cf);
  border-color: rgba(70, 48, 18, .48);
  box-shadow: 0 2px 8px rgba(55, 38, 15, .18);
}
html[data-theme="light"] #controls button:active,
html[data-theme="light"] #controls button.on {
  color: #563500;
  background: #e8d5b4;
  border-color: #80570f;
}
html[data-theme="light"] #controls button svg,
html[data-theme="light"] #controls button svg * {
  stroke: currentColor;
  fill: none;
  opacity: 1;
}
html[data-theme="light"] #watermark {
  color: rgba(32, 23, 13, .76);
  text-shadow: 0 1px 2px rgba(255, 255, 255, .8);
}
html[data-theme="light"] .kickoff-num {
  color: #704600;
  text-shadow: 0 1px 0 #fffefa, 0 2px 5px rgba(32, 23, 13, .28);
}
html[data-theme="light"] .kickoff-label {
  color: #20170d;
  background: linear-gradient(180deg, #fffefa, #f1e6d2);
  border-color: rgba(70, 48, 18, .48);
}
html[data-theme="light"] .kickoff-label .hint { color: #594326; }
html[data-theme="light"] .pause-overlay { background: rgba(35, 27, 17, .58); }
html[data-theme="light"] .pause-card {
  color: #20170d;
  background: linear-gradient(160deg, #fffefa 0%, #f5ead7 55%, #eadcc4 100%);
  border-color: rgba(70, 48, 18, .42);
}
html[data-theme="light"] .pause-title { color: #704600; }
html[data-theme="light"] .pause-sub { color: #594326; }
html[data-theme="light"] .pause-btns button {
  color: #20170d;
  background: linear-gradient(180deg, #fffefa, #eee3cf);
  border-color: rgba(70, 48, 18, .48);
}
html[data-theme="light"] .pause-btns button.primary { color: #fffefa; }
html[data-theme="light"] .pause-btns button.danger { color: #fff; }
