/* ============================================
   EmoForge — Style
   Dark gaming theme · Mobile-first · Responsive
   ============================================ */

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

:root {
  --bg: #0a0a1a;
  --bg-card: rgba(255,255,255,0.05);
  --primary: #7c3aed;
  --primary-glow: rgba(124,58,237,0.4);
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 16px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button, .game-chip, .option, .palette-tile, .palette-tab,
.lobby-game-btn, .fab-btn, .map-strip-card,
.template-item, .hud-item {
  touch-action: manipulation;
}

/* === Screen System === */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

.screen-content {
  width: 100%;
  max-width: 560px;
  padding: 24px 20px;
  text-align: center;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* === Home Screen === */

.floating-emojis {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.floating-emoji {
  position: absolute;
  bottom: -40px;
  opacity: 0;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.12; }
  90%  { opacity: 0.12; }
  100% { transform: translateY(-105vh) rotate(360deg); opacity: 0; }
}

.home-content {
  position: relative;
  z-index: 1;
}

.logo {
  font-size: 3rem;
  margin-bottom: 6px;
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.tagline {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.match-history-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  opacity: 0.55;
  margin: 0 0 24px;
  text-align: center;
}

.difficulty-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.difficulty-opt {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 10px 6px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, border-color .2s, background .2s;
  min-height: 44px;
  touch-action: manipulation;
}
.difficulty-opt:hover { transform: translateY(-1px); }
.difficulty-opt.active {
  background: rgba(124,58,237,0.25);
  border-color: var(--primary);
  color: #fff;
}

/* (result-clutch moved to results-layout section below) */

/* === Wave B §3.9 — Victory/Defeat banner & award cards === */
.result-banner {
  font: 900 28px/1 -apple-system, sans-serif;
  letter-spacing: 0.18em;
  padding: 10px 22px;
  border-radius: 12px;
  margin: 0 auto 12px;
  display: inline-block;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
  animation: bannerSlideIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.result-banner--win  { background: linear-gradient(90deg, #f59e0b, #facc15); color: #1a1a2e; }
.result-banner--loss { background: linear-gradient(90deg, #475569, #64748b); color: #f8fafc; }
.result-banner--draw { background: linear-gradient(90deg, #6366f1, #8b5cf6); color: #f8fafc; }

@keyframes bannerSlideIn {
  0%   { opacity: 0; transform: translateY(-22px) scale(0.85); }
  60%  { opacity: 1; transform: translateY(2px) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.result-awards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 0 auto 14px;
  max-width: 420px;
}
.award-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  text-align: center;
  opacity: 0;
  animation: awardCardIn 0.4s ease-out forwards;
}
.award-card--mvp  { border-color: rgba(250,204,21,0.5); background: linear-gradient(180deg, rgba(250,204,21,0.12), rgba(250,204,21,0.04)); }
.award-card--gold { border-color: rgba(245,158,11,0.5); background: linear-gradient(180deg, rgba(245,158,11,0.12), rgba(245,158,11,0.04)); }
.award-card--life { border-color: rgba(34,197,94,0.5);  background: linear-gradient(180deg, rgba(34,197,94,0.12), rgba(34,197,94,0.04)); }
.award-card--you  { box-shadow: 0 0 0 1.5px rgba(124,58,237,0.6); }
.award-label { font-size: 0.7rem; opacity: 0.75; letter-spacing: 0.04em; }
.award-body  { display: flex; align-items: center; gap: 4px; font-weight: 700; }
.award-emoji { font-size: 1.1rem; }
.award-name  { font-size: 0.82rem; }
.award-stat  { font-size: 0.7rem; opacity: 0.6; }

@keyframes awardCardIn {
  0%   { opacity: 0; transform: translateY(8px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

body.rm .result-banner,
body.rm .award-card {
  animation: none !important;
  opacity: 1;
}

/* === Game Chips (horizontal row) === */

.game-chips {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.game-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.game-chip:not(.coming-soon):hover,
.game-chip:not(.coming-soon):focus-visible {
  background: rgba(124,58,237,0.12);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--primary-glow);
  outline: none;
}

.game-chip:not(.coming-soon):active {
  transform: translateY(0);
}

.game-chip.coming-soon {
  opacity: 0.3;
  cursor: not-allowed;
}

.game-chip-emoji { font-size: 1.4rem; }
.game-chip-name { font-size: 0.85rem; }

/* === Map Strip (horizontal scroll) === */

.map-strip-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.map-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}
.map-strip::-webkit-scrollbar { display: none; }

.map-strip-empty {
  opacity: 0.3;
  font-size: 0.8rem;
  white-space: nowrap;
}

.map-strip-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  max-width: 160px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
  font-family: inherit;
  scroll-snap-align: start;
  flex-shrink: 0;
  text-align: left;
}
.map-strip-card:hover { background: rgba(255,255,255,0.08); border-color: var(--primary); }

.map-strip-card-name { font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-strip-card-meta { font-size: 0.65rem; opacity: 0.4; }
.map-strip-card-actions { display: flex; gap: 6px; font-size: 0.7rem; opacity: 0.5; }
.map-strip-action { cursor: pointer; transition: opacity 0.15s; }
.map-strip-action:hover { opacity: 1; }
.map-strip-action[data-action="del"]:hover { color: var(--danger); }

.map-strip-add {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 2px dashed rgba(255,255,255,0.15);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.map-strip-add:hover { border-color: var(--primary); background: rgba(124,58,237,0.1); }

/* === Back Button (generic) === */

.btn-icon {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }

/* In lobby/editor: position absolute */
.lobby-content .btn-icon,
.editor-toolbar .btn-icon {
  position: absolute;
  top: 0;
  left: 0;
}

/* === Customizer Screen (tabbed layout) === */

.cust-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 20px 0;
  box-sizing: border-box;
}

.cust-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  position: relative;
}

.cust-topbar .btn-icon {
  position: static;
  flex-shrink: 0;
}

.cust-preview-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

#preview-canvas {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  border: 2px solid rgba(255,255,255,0.06);
}

.cust-preview-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cust-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.cust-tab {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.cust-tab:hover { background: rgba(255,255,255,0.06); }
.cust-tab.active {
  border-color: var(--primary);
  background: rgba(124,58,237,0.15);
  color: var(--text);
}

.cust-panels {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  padding-bottom: 8px;
}

.cust-panel { display: none; }
.cust-panel.active { display: block; }

.cust-footer {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px 0;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.cust-footer .btn-primary,
.cust-footer .btn-secondary {
  flex: 1;
  max-width: 200px;
}

.customize-section { margin-bottom: 14px; }

.customize-section h3 {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.picker-grid .option {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.picker-grid .option .face-emoji { font-size: 1.5rem; }
.picker-grid .option .face-ability {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 0.6rem;
  line-height: 1;
  opacity: 0.8;
}

.picker-grid .option:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.1);
}

.picker-grid .option.selected {
  border-color: var(--primary);
  background: rgba(124,58,237,0.2);
  box-shadow: 0 0 14px var(--primary-glow);
  transform: scale(1.1);
}

/* Ability info bar below face picker */
.ability-info {
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-radius: 10px;
  font-size: 0.85rem;
  color: #ccc;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 36px;
}
.ability-badge {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}
.ability-desc {
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
}
.ability-cd {
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
  white-space: nowrap;
}

.color-grid .option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 0;
}

.name-input {
  width: 100%;
  max-width: 280px;
  padding: 10px 14px;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  text-align: center;
}

.name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.name-input::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.flag-grid .option {
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
}

/* === Buttons === */

.btn-primary, .btn-secondary {
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px var(--primary-glow);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* === Game Screen === */

#screen-game {
  background: #050510;
  display: block;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 12px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 20;
  padding: 4px 8px;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}

.hud-item {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 18px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  transition: color 0.3s;
}

.hud-item.urgent { color: var(--danger); }


.hud-exit {
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  padding: 8px 14px;
  transition: color 0.2s, background 0.2s;
}

.hud-exit:hover, .hud-exit:active {
  color: #fff;
  background: rgba(239,68,68,0.35);
  border-color: rgba(239,68,68,0.5);
}

#game-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  font-weight: 700;
  text-shadow: 0 0 16px rgba(0,0,0,0.9), 0 2px 6px rgba(0,0,0,0.5);
  z-index: 25;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  text-align: center;
  max-width: 90vw;
  line-height: 1.2;
}

#game-message.visible { opacity: 1; }

/* === Mobile Joystick === */

#mobile-controls {
  display: none;
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: max(24px, env(safe-area-inset-left, 24px));
  z-index: 20;
}

#joystick-zone {
  width: clamp(110px, 28vmin, 150px);
  height: clamp(110px, 28vmin, 150px);
  position: relative;
  touch-action: none;
}

#joystick-base {
  width: 80%;
  height: 80%;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-thumb {
  width: 34%;
  height: 34%;
  background: rgba(124,58,237,0.5);
  border: 2px solid rgba(124,58,237,0.7);
  border-radius: 50%;
  transition: transform 0.05s ease-out;
  pointer-events: none;
}

/* Show joystick on touch devices or narrow screens */
@media (pointer: coarse) {
  #mobile-controls { display: block; }
}
@media (max-width: 768px) and (hover: none) {
  #mobile-controls { display: block; }
}

#ability-btn {
  position: fixed;
  right: max(24px, env(safe-area-inset-right, 24px));
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  width: clamp(56px, 14vmin, 72px);
  height: clamp(56px, 14vmin, 72px);
  border-radius: 50%;
  background: rgba(124,58,237,0.4);
  border: 2px solid rgba(124,58,237,0.7);
  color: #fff;
  font-size: clamp(22px, 6vmin, 30px);
  display: none;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  z-index: 21;
  transition: opacity 0.2s, background 0.2s;
}
#ability-btn.on-cooldown {
  opacity: 0.4;
  background: rgba(100,100,100,0.4);
  border-color: rgba(100,100,100,0.5);
}
#ability-btn.ready-flash {
  background: rgba(250,204,21,0.5);
  border-color: rgba(250,204,21,0.8);
}

/* (play-mode-buttons replaced by .cust-footer) */

/* === Lobby Screen === */

.lobby-content {
  max-width: 440px;
}

.lobby-room-info {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin: 16px 0;
  flex-wrap: wrap;
}

.room-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.5;
}

.room-code {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  background: rgba(124,58,237,0.15);
  padding: 8px 20px;
  border-radius: 12px;
  border: 2px solid rgba(124,58,237,0.3);
}

.btn-copy {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.btn-copy:hover {
  background: rgba(255,255,255,0.15);
}

.lobby-section {
  margin: 20px 0;
}

.lobby-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-bottom: 10px;
}

.lobby-game-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.lobby-game-label {
  background: rgba(124,58,237,0.15);
  border: 2px solid var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

.lobby-game-btn {
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.lobby-game-btn.selected {
  border-color: var(--primary);
  background: rgba(124,58,237,0.2);
}

.lobby-game-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

#lobby-player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}

.lobby-player-emoji {
  font-size: 1.6rem;
}

.lobby-player-name {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.lobby-player-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(124,58,237,0.3);
  color: var(--primary);
}

.lobby-player-badge.you {
  background: rgba(16,185,129,0.2);
  color: #10b981;
}

.lobby-status-text {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.5;
  margin-top: 12px;
}

/* === Results Screen === */

/* === Results Screen (compact, no-scroll layout) === */

.results-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 20px 0;
  box-sizing: border-box;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.results-hero {
  text-align: center;
  flex-shrink: 0;
}

.results-hero-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 4px;
}

.results-hero-text { text-align: left; }
.results-hero-text h2 { font-size: 1.3rem; margin: 0; }
.results-hero-text p  { font-size: 0.85rem; color: var(--text-dim); margin: 2px 0 0; }

.result-big-emoji {
  font-size: 3rem;
  line-height: 1;
  animation: emojiPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

@keyframes emojiPop {
  0%   { transform: scale(0.2) rotate(-20deg); }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.result-clutch {
  background: linear-gradient(90deg, rgba(239,68,68,0.18), rgba(245,158,11,0.18));
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: 10px;
  padding: 6px 12px;
  margin: 6px auto 0;
  font-size: 0.78rem;
  font-weight: 600;
  max-width: 360px;
  text-align: center;
}

.results-rankings-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  margin: 8px 0;
  padding-bottom: 8px;
}

#result-rankings { margin-bottom: 0; }

/* === Results Tabs (mobile compact view) === */
.results-tabs {
  display: flex;
  gap: 0;
  margin: 6px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.results-tab {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,0.45);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.results-tab.active {
  color: #fff;
  border-bottom-color: #7c3aed;
}

.results-tab:hover:not(.active) {
  color: rgba(255,255,255,0.7);
}

.results-tab-panels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.results-tab-panel {
  display: none;
  padding: 8px 0;
}

.results-tab-panel.active {
  display: block;
}

/* Mobile: compact sizing */
@media (max-width: 600px) {
  .results-layout {
    padding: 10px 12px 0;
  }
  
  .result-banner {
    font-size: 22px;
    padding: 7px 16px;
    margin-bottom: 8px;
  }
  
  .result-big-emoji {
    font-size: 2.2rem;
  }
  
  .results-hero-text h2 { font-size: 1.1rem; }
  .results-hero-text p  { font-size: 0.78rem; }
  
  .result-clutch {
    font-size: 0.7rem;
    padding: 4px 8px;
    margin: 4px auto 0;
  }
  
  .result-awards {
    gap: 6px;
  }
  
  .award-card {
    padding: 6px 8px;
  }
  
  .award-label { font-size: 0.65rem; }
  .award-emoji { font-size: 0.95rem; }
  .award-name  { font-size: 0.75rem; }
  .award-stat  { font-size: 0.65rem; }
  
  .ranking-item {
    padding: 4px 8px;
    font-size: 0.78rem;
    gap: 6px;
  }
  
  .result-rewards {
    padding: 8px 10px;
    margin: 4px 0;
  }
  
  .reward-header { font-size: 1rem; }
}

@media (min-width: 601px) {
  .results-rankings-wrap {
    max-height: 40vh;
  }
}

.ranking-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.ranking-item.winner {
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.25);
  font-weight: 700;
}

.ranking-item .rank { width: 24px; text-align: center; }

/* Floating action buttons — bottom-right corner */
.results-fab {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  right: max(16px, env(safe-area-inset-right, 16px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 30;
}

.fab-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(30,30,50,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.fab-btn:hover {
  transform: scale(1.1);
  background: rgba(50,50,80,0.9);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

.fab-btn:active { transform: scale(0.95); }

.fab-primary {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  background: var(--primary);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.fab-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 28px var(--primary-glow);
}

.fab-sm {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

/* === Home Top Bar (streak + settings) === */

.home-top-bar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 12px));
  left: max(12px, env(safe-area-inset-left, 12px));
  right: max(12px, env(safe-area-inset-right, 12px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  pointer-events: none;
}
.home-top-bar > * { pointer-events: auto; }

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fde68a;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.18);
  animation: streakPulse 2.4s ease-in-out infinite;
}
.streak-badge[hidden] { display: none; }
.streak-badge.bump { animation: streakBump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.streak-flame { font-size: 1.05rem; }

@keyframes streakPulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(245, 158, 11, 0.18); }
  50%      { box-shadow: 0 2px 20px rgba(245, 158, 11, 0.45); }
}
@keyframes streakBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25) rotate(-4deg); }
  100% { transform: scale(1) rotate(0); }
}

.btn-settings {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.15s;
}
.btn-settings:hover { background: rgba(255,255,255,0.12); transform: rotate(45deg); }

/* === Modal Shell (shared by settings + tutorial) === */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: #1a1a2e;
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 16px;
  padding: 1.5rem 1.25rem 1.25rem;
  width: min(420px, 100%);
  max-height: min(88vh, 88dvh);
  overflow-y: auto;
  animation: slideUpModal 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes slideUpModal {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-card h3 { font-size: 1.15rem; margin-bottom: 1rem; }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.14); }

.modal-foot-btn { width: 100%; margin-top: 0.25rem; padding: 8px 14px; font-size: 0.82rem; }

/* === Settings toggles === */

.settings-card { padding: 1.25rem 1rem 1rem; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  font-size: 0.85rem;
}
.toggle-row:last-of-type { border-bottom: none; }

/* Wave A deferred — editor name dirty asterisk */
.editor-name-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.editor-dirty-asterisk {
  position: absolute;
  right: -4px;
  top: -2px;
  font: 700 14px -apple-system, sans-serif;
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(251,191,36,0.6);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
.editor-name-input.is-dirty + .editor-dirty-asterisk { opacity: 1; }

/* Wave B §4.6 — keyboard shortcut overlay */
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.85rem;
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font: 600 0.78rem ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  color: #f8fafc;
}
.shortcut-row span { flex: 1; opacity: 0.8; }

/* Wave B §5.5 — slider rows */
.slider-row {
  padding: 10px 4px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.85rem;
}
.slider-row label {
  display: block;
  margin-bottom: 6px;
  opacity: 0.85;
}
.slider-row input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
.slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.18);
}
.slider-row input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.18);
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #a855f7;
  margin-top: -6px;
  cursor: pointer;
  border: 2px solid #fff;
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #a855f7;
  cursor: pointer;
  border: 2px solid #fff;
}

.toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.toggle-row input[type="checkbox"]:checked {
  background: var(--primary);
}
.toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

/* === Tutorial === */

.tutorial-card { padding: 2rem 1.25rem 1.25rem; }
.tutorial-slides { min-height: 190px; position: relative; }
.tutorial-slide {
  display: none;
  text-align: center;
  animation: fadeSlide 0.35s ease;
}
.tutorial-slide.active { display: block; }
.tutorial-emoji { font-size: 3.2rem; margin-bottom: 0.75rem; line-height: 1; }
.tutorial-slide h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.tutorial-slide p { font-size: 0.95rem; color: var(--text-dim); line-height: 1.5; max-width: 320px; margin: 0 auto; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 1rem 0 1.25rem;
}
.tutorial-dots .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 0.2s, transform 0.2s;
}
.tutorial-dots .dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.tutorial-actions { display: flex; gap: 10px; }
.tutorial-actions > button { flex: 1; padding: 10px 16px; font-size: 0.95rem; }
.tutorial-actions .btn-secondary:disabled { opacity: 0.35; cursor: default; }

/* (old custom-map-item-plays removed — now inline in .map-strip-card-meta) */

/* === Focus rings (keyboard a11y) === */

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124,58,237,0.35);
  border-radius: 8px;
}
/* Remove default Chrome focus ring on buttons without :focus-visible */
button:focus:not(:focus-visible) { outline: none; }

/* === Accessibility — High Contrast mode (body.hc) === */

body.hc {
  --bg: #000;
  --bg-card: rgba(255,255,255,0.12);
  --text: #fff;
  --text-dim: #e2e8f0;
}
body.hc .game-chip,
body.hc .lobby-player,
body.hc .map-strip-card,
body.hc .template-item,
body.hc .modal-card {
  border-color: rgba(255,255,255,0.4);
}
body.hc .hud-item,
body.hc .btn-secondary,
body.hc .btn-tool {
  border-width: 2px;
  border-color: rgba(255,255,255,0.6);
}
body.hc .tagline,
body.hc .home-section-label,
body.hc .customize-section h3,
body.hc .lobby-section h3 { opacity: 0.85; color: #e2e8f0; }

/* === Accessibility — Colorblind assist (body.cb) === */
/* Adds outline differentiation so hue-only cues aren't load-bearing. */

body.cb .game-chip,
body.cb .lobby-game-btn.selected,
body.cb .ranking-item.winner,
body.cb .map-strip-card,
body.cb .palette-tile.selected,
body.cb .picker-grid .option.selected {
  outline: 2px dashed rgba(255,255,255,0.6);
  outline-offset: 2px;
}
body.cb .streak-badge { outline: 2px dashed #fde68a; outline-offset: 2px; }

/* === Accessibility — Reduced motion (body.rm) === */

body.rm .floating-emoji,
body.rm .logo,
body.rm .results-layout,
body.rm .result-big-emoji,
body.rm .streak-badge { animation: none !important; }
body.rm *, body.rm *::before, body.rm *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

/* === Scrollbar === */

.screen-content::-webkit-scrollbar { width: 5px; }
.screen-content::-webkit-scrollbar-track { background: transparent; }
.screen-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* === Home Custom Maps === */

.home-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.4;
  margin-top: 14px;
  margin-bottom: 6px;
}

/* (old custom-map-list/item styles replaced by .map-strip-* above) */

/* === Map Editor === */

.editor-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
  z-index: 5;
}

.editor-name-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  width: 140px;
  outline: none;
}

.editor-name-input:focus {
  border-color: var(--primary);
}

.editor-select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  outline: none;
}

.editor-tool-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.editor-respawn-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  user-select: none;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.15s;
}
.editor-respawn-toggle:hover { background: rgba(255,255,255,0.08); }
.editor-respawn-toggle:has(input:checked) { color: #22c55e; border-color: rgba(34,197,94,0.3); }
.editor-respawn-toggle input { accent-color: #22c55e; }

.btn-tool {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  touch-action: manipulation;
}

.btn-tool:hover { background: rgba(255,255,255,0.12); }
.btn-tool-primary { border-color: rgba(124,58,237,0.4); background: rgba(124,58,237,0.15); }
.btn-tool-success { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.15); }

.editor-canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #151530;
}

#editor-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.editor-palette {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.4);
  border-top: 1px solid rgba(255,255,255,0.06);
  overflow-x: auto;
  flex-wrap: nowrap;
  z-index: 5;
}

.palette-tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.palette-tab {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
  transition: all 0.15s;
}

.palette-tab.active {
  background: rgba(124,58,237,0.2);
  border-color: var(--primary);
}

.palette-tiles {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.palette-tile {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.palette-tile:hover { background: rgba(255,255,255,0.1); }
.palette-tile.selected { border-color: var(--primary); background: rgba(124,58,237,0.2); }

.editor-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 50;
}

.editor-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Template modal */
.template-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  animation: fadeIn 0.2s ease;
}
.template-modal.hidden { display: none; }
.template-modal-inner {
  background: #1a1a2e;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 16px;
  padding: 1.25rem;
  width: min(420px, 100%);
  max-height: min(80vh, 80dvh);
  overflow-y: auto;
}
.template-modal-inner h3 { margin-bottom: 0.25rem; font-size: 1.1rem; }
.template-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.template-filter {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, color .15s, border-color .15s;
}
.template-filter.active {
  background: rgba(124,58,237,0.3);
  border-color: var(--primary);
  color: #fff;
}

.template-list { display: flex; flex-direction: column; gap: 8px; }
.template-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.template-item:hover {
  background: rgba(124,58,237,0.15);
  border-color: rgba(124,58,237,0.4);
}
.template-item-emoji { font-size: 1.6rem; }
.template-item-info { flex: 1; }
.template-item-name { font-weight: 600; font-size: 0.95rem; display: block; }
.template-item-desc { font-size: 0.78rem; opacity: 0.5; display: block; }

/* === Responsive === */

@media (max-width: 400px) {
  .logo { font-size: 2.4rem; }
  .tagline { font-size: 0.95rem; margin-bottom: 8px; }
  .match-history-label { font-size: 0.72rem; margin-bottom: 16px; }
  .game-chip { padding: 8px 14px; }
  .game-chip-emoji { font-size: 1.2rem; }
  .game-chip-name { font-size: 0.78rem; }
  /* R4: keep touch target ≥ 44px per WCAG 2.1 AA */
  .picker-grid .option { width: 44px; height: 44px; font-size: 1.3rem; }
  .picker-grid .option .face-emoji { font-size: 1.3rem; }
  .picker-grid .option .face-ability { font-size: 0.5rem; }
  .ability-info { font-size: 0.75rem; padding: 6px 10px; }
  .ability-desc { display: none; }
  .color-grid .option  { width: 44px; height: 44px; }
  .flag-grid .option   { width: 44px; height: 44px; font-size: 1.1rem; }
  .name-input { max-width: 240px; font-size: 0.9rem; }
  /* R5: prevent message overflow on narrow phones */
  #game-message { font-size: 1.4rem; word-break: break-word; }
  .hud-item { font-size: 0.9rem; padding: 6px 12px; }
}

/* R5b: ultra-narrow (iPhone SE / Galaxy Fold closed) */
@media (max-width: 360px) {
  #game-message { font-size: 1.2rem; }
  .picker-grid { gap: 6px; }
}

/* R3: editor toolbar compacts to avoid stealing canvas height */
@media (max-width: 600px) {
  .editor-toolbar { gap: 6px; padding: 6px 8px; }
  .editor-name-input { width: 110px; font-size: 0.8rem; padding: 6px 8px; }
  .editor-select { font-size: 0.75rem; padding: 4px 6px; max-width: 96px; }
  .editor-respawn-toggle { font-size: 0.7rem; padding: 2px 6px; }
  .btn-tool { width: 40px; height: 40px; min-width: 40px; font-size: 0.95rem; }
  .palette-tile { width: 44px; height: 44px; }
  .palette-tab { padding: 6px 10px; font-size: 0.78rem; }
}

/* R9: landscape phones — suggest rotate if the game canvas height collapses */
@media (max-height: 420px) and (orientation: landscape) {
  #hud { top: max(4px, env(safe-area-inset-top, 4px)); padding: 2px 6px; gap: 6px; }
  .hud-item { padding: 4px 10px; font-size: 0.85rem; }
  #mobile-controls {
    bottom: max(8px, env(safe-area-inset-bottom, 8px));
    left: max(8px, env(safe-area-inset-left, 8px));
  }
  #joystick-zone { width: clamp(90px, 22vmin, 120px); height: clamp(90px, 22vmin, 120px); }
  #game-message { font-size: 1.8rem; }
}

/* Respect users with reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .floating-emoji { animation: none; opacity: 0; }
  .logo { animation: none; }
  .results-layout { animation: none; }
  .result-big-emoji { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Settings — Account Card (top of settings modal)
   ========================================================================== */

.settings-account-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.settings-account-card--active {
  border-color: rgba(88, 101, 242, 0.35);
  background: rgba(88, 101, 242, 0.06);
}
.settings-account-card[hidden] { display: none; }

.settings-account-guest,
.settings-account-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-account-avatar { font-size: 1.6rem; flex-shrink: 0; }
.settings-account-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-account-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-account-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.settings-auth-btns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.settings-auth-btns .auth-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.settings-signout-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.settings-signout-btn:hover { background: rgba(239,68,68,0.2); }

/* Settings groups */
.settings-group {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 10px;
}
.settings-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 4px 0 2px;
}
.settings-group .toggle-row { padding: 6px 0; font-size: 0.82rem; }
.settings-group .slider-row { padding: 4px 0; }
.settings-group .slider-row label { font-size: 0.8rem; margin-bottom: 2px; }

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.account-pill:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); }
.account-pill.signed-in { border-color: rgba(88, 101, 242, 0.5); background: rgba(88, 101, 242, 0.12); }
.account-pill.signed-in:hover { background: rgba(88, 101, 242, 0.2); }
#account-pill-icon { font-size: 1.1rem; }
.home-top-spacer { flex: 1; }

/* ==========================================================================
   Auth Buttons (shared)
   ========================================================================== */

.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  color: #fff;
}
.auth-btn:active { transform: scale(0.97); }
.auth-icon { width: 18px; height: 18px; flex-shrink: 0; }

.auth-btn-discord {
  background: #5865F2;
  border-color: rgba(88, 101, 242, 0.6);
}
.auth-btn-discord:hover { background: #4752C4; }

.auth-btn-google {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
}
.auth-btn-google:hover { background: rgba(255,255,255,0.12); }

.auth-provider-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.15);
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Auth loading state */
.auth-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}
.auth-btn.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
}
@keyframes authSpin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Leaderboard Modal
   ========================================================================== */

.lb-card {
  display: flex;
  flex-direction: column;
  max-height: min(85vh, 85dvh);
}

/* Game tabs (Rift / Sumo / Tag) */
.lb-game-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.lb-game-tab {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lb-game-tab:hover { background: rgba(255,255,255,0.08); }
.lb-game-tab.active {
  background: rgba(124,58,237,0.18);
  border-color: rgba(124,58,237,0.4);
  color: var(--text);
}

/* Time filter tabs */
.lb-time-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.lb-time-tab {
  flex: 1;
  padding: 5px 4px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lb-time-tab:hover { background: rgba(255,255,255,0.04); }
.lb-time-tab.active {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: rgba(255,255,255,0.12);
}

/* My stats bar */
.lb-my-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 600;
}
.lb-my-stats[hidden] { display: none; }

/* Scrollable list */
.lb-list-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Empty state */
.lb-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Individual row */
.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}
.lb-row:hover { background: rgba(255,255,255,0.06); }
.lb-row.lb-me {
  background: rgba(124,58,237,0.1);
  border-color: rgba(124,58,237,0.3);
}

/* Rank badge */
.lb-rank {
  width: 28px;
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.lb-rank-1 { color: #fbbf24; }
.lb-rank-2 { color: #94a3b8; }
.lb-rank-3 { color: #d97706; }

/* Player info */
.lb-emoji { font-size: 1.2rem; flex-shrink: 0; }
.lb-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats on the right */
.lb-stats {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.lb-stat {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Loading spinner */
.lb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.lb-loading[hidden] { display: none; }
.lb-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(124,58,237,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
}

/* ============================================================
   Cosmetic Shop Modal
   ============================================================ */
.shop-card {
  max-width: 420px;
  padding: 16px;
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-right: 28px;
}
.shop-header h3 { margin: 0; font-size: 1.1rem; }

.shop-balance {
  background: linear-gradient(135deg, #f59e0b22, #f59e0b44);
  border: 1px solid #f59e0b55;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #f59e0b;
}

.shop-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  overflow-x: auto;
}
.shop-tab {
  flex: 1;
  padding: 6px 4px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #aaa;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.shop-tab.active {
  background: var(--primary);
  color: #fff;
}

.shop-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}
.shop-preview canvas {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: rgba(0,0,0,0.3);
}
.shop-preview-name {
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 4px;
}

.shop-grid-wrap {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  padding: 2px;
}

.shop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.shop-item:hover {
  background: rgba(255,255,255,0.1);
}
.shop-item.selected {
  border-color: var(--primary);
  background: rgba(124,58,237,0.15);
}
.shop-item.equipped::after {
  content: '✅';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.6rem;
}
.shop-item.owned {
  border-color: rgba(34,197,94,0.3);
}
.shop-item.placeholder {
  opacity: 0.45;
  pointer-events: auto;
  border-style: dashed;
}

.shop-item-emoji {
  font-size: 1.5rem;
  line-height: 1;
}
.shop-item-label {
  font-size: 0.6rem;
  color: #aaa;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.shop-item-price-tag {
  font-size: 0.55rem;
  color: #f59e0b;
  font-weight: 700;
}

/* Rarity borders */
.shop-item[data-rarity="common"] { border-color: rgba(148,163,184,0.25); }
.shop-item[data-rarity="rare"] { border-color: rgba(59,130,246,0.35); }
.shop-item[data-rarity="epic"] { border-color: rgba(168,85,247,0.4); }
.shop-item[data-rarity="legendary"] { border-color: rgba(245,158,11,0.5); }
.shop-item[data-rarity="mythic"] { border-color: rgba(239,68,68,0.6); box-shadow: 0 0 8px rgba(239,68,68,0.3); }

.shop-item.selected[data-rarity="common"] { border-color: #94a3b8; }
.shop-item.selected[data-rarity="rare"] { border-color: #3b82f6; }
.shop-item.selected[data-rarity="epic"] { border-color: #a855f7; }
.shop-item.selected[data-rarity="legendary"] { border-color: #f59e0b; }
.shop-item.selected[data-rarity="mythic"] { border-color: #ef4444; box-shadow: 0 0 12px rgba(239,68,68,0.5); }

/* Daily shop header */
.daily-shop-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 4px 2px;
  color: #94a3b8;
}
.daily-countdown { color: #f59e0b; font-weight: 600; }
.featured-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.55rem;
  color: #f59e0b;
  font-weight: 700;
}
.shop-item.featured {
  border-width: 2px;
  position: relative;
  grid-column: span 2;
}
.shop-item.featured .shop-item-emoji { font-size: 2rem; }
.shop-item-owned-tag { font-size: 0.6rem; opacity: 0.7; }

/* Season Pass Modal */
.season-card { max-width: 420px; }
.sp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sp-name { font-weight: 700; font-size: 1rem; }
.sp-level { font-size: 0.85rem; color: #fbbf24; font-weight: 600; }
.sp-countdown {
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 6px;
}
.sp-countdown--urgent {
  color: #ef4444;
  font-weight: 600;
  animation: hintPulse 1.5s ease-in-out infinite;
}
.sp-xp-bar {
  position: relative;
  height: 18px;
  background: rgba(255,255,255,0.08);
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 6px;
}
.sp-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 9px;
  transition: width 0.3s;
}
.sp-xp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.sp-premium-badge {
  text-align: center;
  font-size: 0.75rem;
  color: #fbbf24;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Season track */
.season-track {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.sp-tier {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  border-left: 3px solid rgba(255,255,255,0.1);
}
.sp-tier.unlocked { border-left-color: #22c55e; }
.sp-tier.locked { opacity: 0.6; }
.sp-tier-level {
  min-width: 40px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
}
.sp-tier-rewards { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sp-reward {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
  padding: 2px 4px;
  border-radius: 4px;
}
.sp-reward.free { background: rgba(34,197,94,0.08); }
.sp-reward.premium { background: rgba(251,191,36,0.08); }
.sp-reward.premium.locked { opacity: 0.5; }
.sp-reward.claimed { opacity: 0.6; }
.sp-reward.empty { opacity: 0.3; }
.sp-reward-label { flex: 1; }
.sp-claim-btn {
  font-size: 0.65rem;
  padding: 2px 8px;
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.sp-claim-btn:hover { background: #16a34a; }
.sp-claimed { font-size: 0.65rem; }
.sp-lock { font-size: 0.6rem; }

/* Season buy bar */
.season-buy-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(251,191,36,0.1);
  border-radius: 10px;
  margin-top: 8px;
}
.sp-buy-info { display: flex; flex-direction: column; gap: 2px; font-size: 0.8rem; }
.sp-buy-price { color: #fbbf24; font-weight: 700; }
.sp-buy-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1e1b4b;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}
.sp-buy-btn:hover { filter: brightness(1.1); }
.sp-buy-btn:disabled { cursor: not-allowed; }

/* Reward XP line */
.reward-xp {
  font-size: 0.75rem;
  color: #fbbf24;
  margin-top: 4px;
  font-weight: 600;
}
.reward-levelup {
  font-size: 0.85rem;
  color: #fbbf24;
  font-weight: 700;
  animation: pulse 0.5s ease;
}

/* Action bar */
.shop-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
}
.shop-item-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shop-item-price {
  font-size: 0.78rem;
  color: #f59e0b;
  font-weight: 700;
}
.shop-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.shop-btn.buy {
  background: #f59e0b;
  color: #1a1a2e;
}
.shop-btn.buy:hover { background: #d97706; }
.shop-btn.equip {
  background: var(--primary);
  color: #fff;
}
.shop-btn.equip:hover { background: #6d28d9; }
.shop-equipped-badge {
  font-size: 0.78rem;
  color: #22c55e;
  font-weight: 600;
}

/* Premium & locked faces in face picker */
.picker-grid .option.premium {
  border-color: rgba(168,85,247,0.3);
}
.picker-grid .option.locked {
  opacity: 0.6;
  cursor: pointer;
  position: relative;
}
.picker-grid .option.locked:hover {
  opacity: 0.8;
  border-color: rgba(245,158,11,0.4);
}
.picker-grid .option .face-lock {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 0.6rem;
  line-height: 1;
}

/* ============================================================
   EmoCoins Reward on Results Screen
   ============================================================ */
.result-rewards {
  text-align: center;
  margin: 8px 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(245,158,11,0.04));
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 12px;
  animation: rewardPop 0.4s ease-out;
}
@keyframes rewardPop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
.reward-header {
  font-size: 1.2rem;
  font-weight: 800;
  color: #f59e0b;
  margin-bottom: 4px;
}
.reward-breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
}
.reward-line {
  font-size: 0.75rem;
  color: #ccc;
}
.reward-line b {
  color: #fbbf24;
}
.reward-mission-hint {
  margin-top: 6px;
  font-size: 0.72rem;
  color: #a78bfa;
  font-weight: 600;
  animation: hintPulse 1.5s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ── Missions Detail Modal ── */
.missions-card {
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
}
.missions-timer {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  margin: -6px 0 10px;
}
.missions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mm-card {
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.06);
}
.mm-card.ready { border-color: #22c55e44; background: rgba(34,197,94,0.06); }
.mm-card.done { opacity: 0.55; }
.mm-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mm-emoji { font-size: 1.3rem; flex-shrink: 0; }
.mm-info { flex: 1; min-width: 0; }
.mm-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 4px;
}
.mm-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mm-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.mm-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.3s ease;
}
.mm-bar-fill.full { background: #22c55e; }
.mm-frac {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
}
.mm-reward {
  font-size: 0.72rem;
  color: #f59e0b;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.mm-claimed {
  font-size: 0.72rem;
  color: #22c55e;
  white-space: nowrap;
  flex-shrink: 0;
}
.mm-claim-btn {
  padding: 5px 10px;
  border: none;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #22c55e;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  animation: hintPulse 1.5s ease-in-out infinite;
}
.mm-claim-btn:hover { background: #16a34a; }

.missions-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 14px 0;
}
.missions-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
  margin: 0 0 8px;
}

/* Today's stats row */
.missions-stats {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}
.ms-stat {
  flex: 1;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 8px 4px;
}
.ms-val {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
}
.ms-lbl {
  display: block;
  font-size: 0.6rem;
  color: #64748b;
  margin-top: 2px;
}

/* Earning guide */
.missions-guide {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.guide-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #94a3b8;
  padding: 4px 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
}
.guide-ec {
  color: #f59e0b;
  font-weight: 700;
}

/* =============================================================================
   Phase 3: FOMO & Social — Limited Drops, Bundles, Tips, Rarest Showcase
   ============================================================================= */

/* Sold-out seasonal items */
.shop-item.sold-out {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.6);
}
.sold-out-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  background: var(--danger);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 2;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Supply bar under seasonal items */
.supply-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.supply-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  border-radius: 2px;
  transition: width 0.3s;
}
.supply-text {
  font-size: 0.48rem;
  color: #94a3b8;
  margin-top: 1px;
}

/* Bundle cards */
.bundle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(245,158,11,0.3);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  grid-column: 1 / -1;
  position: relative;
}
.bundle-card:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.01);
}
.bundle-card.selected {
  border-color: var(--primary);
  background: rgba(124,58,237,0.15);
}
.bundle-card.owned {
  border-color: rgba(34,197,94,0.3);
  opacity: 0.7;
  pointer-events: none;
}
.bundle-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.bundle-emoji { font-size: 1.6rem; }
.bundle-name { font-weight: 700; font-size: 0.9rem; }
.bundle-items {
  font-size: 1.3rem;
  letter-spacing: 4px;
  margin: 4px 0;
}
.bundle-desc {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 6px;
}
.bundle-pricing {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bundle-original-price {
  font-size: 0.75rem;
  color: #64748b;
  text-decoration: line-through;
}
.bundle-sale-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: #f59e0b;
}
.bundle-bonus {
  font-size: 0.65rem;
  color: #10b981;
  font-weight: 600;
  margin-top: 2px;
}
.bundle-owned-badge {
  font-size: 0.7rem;
  color: #22c55e;
  font-weight: 600;
  margin-top: 4px;
}

/* Tip bar on results screen */
.tip-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.tip-label {
  font-size: 0.75rem;
  color: #f9a8d4;
  margin-right: 4px;
}
.tip-btn {
  padding: 4px 10px;
  border: 1px solid rgba(249,168,212,0.3);
  border-radius: 6px;
  background: rgba(249,168,212,0.1);
  color: #f9a8d4;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.tip-btn:hover {
  background: rgba(249,168,212,0.25);
  transform: scale(1.05);
}
.tip-btn:active { transform: scale(0.95); }
.tip-confirmed {
  font-size: 0.8rem;
  color: #f9a8d4;
  font-weight: 600;
  animation: fadeInUp 0.3s ease;
}

/* Rarest items showcase on home screen */
.rarest-showcase {
  margin-top: 8px;
  margin-bottom: 4px;
}
.rarest-items {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 4px 0;
}
.rarest-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 2px solid transparent;
  min-width: 72px;
  transition: transform 0.15s;
}
.rarest-card:hover { transform: scale(1.05); }
.rarest-card-emoji {
  font-size: 1.4rem;
  line-height: 1;
  margin-bottom: 2px;
}
.rarest-card-name {
  font-size: 0.6rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}
.rarest-card-rarity {
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Phase 2 — Editor UX Additions
   ========================================================================== */

/* Tile badge (behavior category) */
.palette-tile {
  position: relative;
}
.tile-emoji {
  font-size: 1.3rem;
  line-height: 1;
}
.tile-badge {
  position: absolute;
  bottom: 1px;
  right: 1px;
  font-size: 0.55rem;
  line-height: 1;
  opacity: 0.7;
  pointer-events: none;
}

/* Small palette tiles (recent tray) */
.palette-tile-sm {
  width: 30px;
  height: 30px;
  min-width: 30px;
  font-size: 1rem;
  padding: 0;
}

/* Editor palette search */
.editor-palette-search {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 6px;
  border: 1px solid rgba(124,58,237,0.35);
  border-radius: 8px;
  background: rgba(15,23,42,0.6);
  color: #E5E7EB;
  font-size: 0.8rem;
  outline: none;
  box-sizing: border-box;
}
.editor-palette-search:focus {
  border-color: rgba(124,58,237,0.7);
}
.editor-palette-search::placeholder {
  color: rgba(229,231,235,0.4);
}

/* Recent tiles tray */
.editor-recent-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  min-height: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.editor-recent-tray:empty {
  display: none;
}
.recent-label {
  font-size: 0.65rem;
  color: rgba(229,231,235,0.5);
  white-space: nowrap;
  margin-right: 2px;
}

/* Minimap */
.editor-minimap {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 4;
  border: 1px solid rgba(124,58,237,0.45);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0.85;
}

/* Brush size buttons */
.editor-brush-group .btn-tool {
  font-size: 0.85rem;
  min-width: 28px;
  padding: 2px 6px;
}
.btn-brush-size.active {
  background: rgba(124,58,237,0.35);
  border-color: rgba(124,58,237,0.7);
  color: #c4b5fd;
}

/* Editor select small variant */
.editor-select-sm {
  font-size: 0.7rem;
  padding: 3px 6px;
  min-width: 0;
}

/* Editor meta group */
.editor-meta-group {
  gap: 3px;
}

/* Validation panel overlay */
.emoforge-validation-panel {
  position: absolute;
  top: 40px;
  left: 12px;
  z-index: 10;
  width: 280px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(15,23,42,0.95);
  border: 1px solid rgba(124,58,237,0.5);
  border-radius: 10px;
  padding: 10px;
  font: 12px/1.4 -apple-system, BlinkMacSystemFont, sans-serif;
  color: #E5E7EB;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.vp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
}
.vp-close {
  background: none;
  border: none;
  color: #E5E7EB;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}
.vp-close:hover {
  background: rgba(255,255,255,0.1);
}
.vp-section {
  margin-bottom: 8px;
}
.vp-section h4 {
  font-size: 0.75rem;
  margin: 0 0 4px;
  font-weight: 600;
}
.vp-errors h4 { color: #FCA5A5; }
.vp-warnings h4 { color: #FCD34D; }
.vp-info h4 { color: #93C5FD; }
.vp-item {
  font-size: 0.72rem;
  padding: 2px 0;
  opacity: 0.9;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* === Stats Modal === */
.stats-card { width: min(480px, 100%); }
.stats-prompt { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 1.1rem; }
.stats-loading { text-align: center; padding: 2rem; color: var(--text-muted); }

.stats-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  text-align: center;
}
.stats-stat { background: rgba(255,255,255,0.04); border-radius: 10px; padding: 0.6rem 0.25rem; }
.stats-val { display: block; font-size: 1.3rem; font-weight: 700; color: #a78bfa; }
.stats-label { display: block; font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.stats-section { margin-bottom: 1rem; }
.stats-section h4 { font-size: 0.85rem; margin-bottom: 0.5rem; color: var(--text-muted); }

.stats-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.4rem;
}
.stats-game-item {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.8rem;
}
.stats-game-item .sg-name { font-weight: 600; margin-bottom: 3px; }
.stats-game-item .sg-detail { color: var(--text-muted); font-size: 0.7rem; }

.stats-emoji-list, .stats-map-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.stats-emoji-chip, .stats-map-chip {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.stats-emoji-chip .se-icon { font-size: 1.2rem; }
.stats-emoji-chip .se-detail, .stats-map-chip .sm-detail { font-size: 0.7rem; color: var(--text-muted); }

.stats-recent-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 260px; overflow-y: auto; }
.stats-match-row {
  display: grid;
  grid-template-columns: 2rem 1.5rem 1fr auto;
  gap: 0.4rem;
  align-items: center;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
}
.stats-match-row.smr-win { border-left: 3px solid #22c55e; }
.stats-match-row.smr-loss { border-left: 3px solid #ef4444; }
.stats-match-result { font-weight: 700; }
.stats-match-result.smr-w { color: #22c55e; }
.stats-match-result.smr-l { color: #ef4444; }
.stats-match-game { font-size: 1rem; }
.stats-match-info { color: var(--text-muted); }
.stats-match-time { color: var(--text-muted); font-size: 0.65rem; text-align: right; }

@media (max-width: 400px) {
  .stats-summary { grid-template-columns: repeat(2, 1fr); }
}

/* === Ranked Section === */
.ranked-section { margin-top: 0.5rem; }
.ranked-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(96,165,250,0.08));
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
}
.ranked-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.ranked-badge-emoji { font-size: 2.2rem; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3)); }
.ranked-badge-info { text-align: left; }
.ranked-badge-tier { display: block; font-size: 1.1rem; font-weight: 700; }
.ranked-badge-mmr { display: block; font-size: 0.8rem; color: var(--text-muted); }
.ranked-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.ranked-play-btn {
  width: 100%;
  font-size: 1rem;
  padding: 0.7rem;
  margin-bottom: 0.4rem;
}
.ranked-note { font-size: 0.65rem; color: var(--text-muted); margin: 0; }

/* Rank tier colors */
.ranked-badge-tier.rank-iron     { color: #78716c; }
.ranked-badge-tier.rank-bronze   { color: #cd7f32; }
.ranked-badge-tier.rank-silver   { color: #c0c0c0; }
.ranked-badge-tier.rank-gold     { color: #fbbf24; }
.ranked-badge-tier.rank-diamond  { color: #60a5fa; }
.ranked-badge-tier.rank-champion { color: #a855f7; }

/* Placement badge */
.ranked-placement {
  display: inline-block;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: #a78bfa;
  margin-top: 4px;
}

/* MMR change on end screen */
.result-mmr {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  animation: fadeIn 0.5s ease 0.3s both;
}
.result-mmr .mmr-up { color: #22c55e; }
.result-mmr .mmr-down { color: #ef4444; }
.result-mmr .mmr-tier { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; display: block; }
.result-mmr .rank-up-anim {
  display: inline-block;
  animation: rankUp 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
  font-size: 1.4rem;
}
@keyframes rankUp {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1); }
}

/* In-game rank badge (nameplate) */
.rank-pip {
  display: inline-block;
  font-size: 0.7rem;
  margin-right: 2px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
