:root {
  --bg-0: #0c0a17;
  --bg-1: #17142b;
  --ink: #f3f1fb;
  --ink-dim: #9d94bf;
  --accent: #8b7dff;
  --accent-2: #ff85c0;
  --danger: #ff5c78;
  --success: #2ee08a;
  --radius: 26px;

  --f-blue: #2fa8ff;
  --f-red: #ff5b3d;
  --f-green: #4fd66a;
  --f-yellow: #ffbf2e;
  --f-purple: #9b5bff;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/fonts/SpaceGrotesk-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: radial-gradient(circle at 50% 0%, #1c1836, var(--bg-0) 70%);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

button {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: inherit;
}

.cell {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

/* ---------- soft glow background ---------- */

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(34vw 34vw at 10% 12%, rgba(139,125,255,0.22), transparent 62%),
    radial-gradient(38vw 38vw at 92% 10%, rgba(255,133,192,0.2), transparent 62%),
    radial-gradient(30vw 30vw at 85% 88%, rgba(79,214,106,0.14), transparent 62%),
    radial-gradient(32vw 32vw at 8% 90%, rgba(255,191,46,0.14), transparent 62%);
  animation: glowShift 18s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes glowShift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(2%, -3%) scale(1.1); }
}

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

.glyph-float {
  position: absolute;
  bottom: -10%;
  opacity: 0.16;
  filter: saturate(1.2) drop-shadow(0 0 10px rgba(139,125,255,0.3));
  animation-name: floatUp;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  will-change: transform;
}

@keyframes floatUp {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(var(--drift, 24px), -60vh) rotate(var(--spin, 12deg)); }
  100% { transform: translate(0, -125vh) rotate(0deg); }
}

/* ---------- TOP NAV ---------- */

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: rgba(23, 20, 43, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 8px 26px -16px rgba(139,125,255,0.35);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

body.in-match .top-nav {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.nav-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--ink);
}

.nav-logo-glyph {
  font-size: 19px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-logo-text {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--ink);
}

.nav-auth-btn {
  flex: 0 0 auto;
  margin-right: 92px; /* clears the fixed trophy+settings corner buttons sitting on top of the nav's right edge */
  padding: 9px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(139,125,255,0.65);
  transition: transform 0.18s cubic-bezier(.3,1.6,.4,1), box-shadow 0.18s ease;
}

.nav-auth-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 30px -10px rgba(139,125,255,0.75);
}

/* ---------- settings ---------- */

.corner-actions {
  position: fixed;
  top: 13px;
  right: 18px;
  z-index: 3;
  display: flex;
  gap: 10px;
}

.icon-action-wrap {
  position: relative;
}

.nav-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ink-dim);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(.3,1.6,.4,1), border-color 0.15s ease, color 0.15s ease;
}

.nav-icon-btn:hover {
  color: var(--ink);
  border-color: rgba(255,255,255,0.22);
}

.nav-icon-btn.spin {
  transform: rotate(75deg);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 230px;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 22px 50px -18px rgba(139,125,255,0.45);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.3,1.4,.4,1);
  z-index: 5;
}

.settings-panel.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

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

.toggle-switch {
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: none;
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease;
  flex: 0 0 auto;
}

.toggle-switch[data-on="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.toggle-knob {
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s cubic-bezier(.3,1.6,.4,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.toggle-switch[data-on="true"] .toggle-knob {
  transform: translateX(17px);
}

.lang-pick {
  display: flex;
  gap: 6px;
}

.lang-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ink-dim);
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}

.lang-btn.locked {
  opacity: 0.6;
}

.mini-lock { font-size: 9px; }

/* ---------- achievements ---------- */

.achievements-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 290px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 22px 50px -18px rgba(139,125,255,0.45);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.3,1.4,.4,1);
  z-index: 5;
}

.achievements-panel.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ach-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}

.ach-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

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

.ach-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.ach-row.unlocked .ach-icon {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.ach-row.locked .ach-icon {
  filter: grayscale(1);
  opacity: 0.45;
}

.ach-text { min-width: 0; }

.ach-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.ach-row.locked .ach-name { color: var(--ink-dim); }

.ach-desc {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
  line-height: 1.35;
}

.nav-tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: safe center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  flex: 0 0 auto;
  position: relative;
  white-space: nowrap;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.nav-tab:hover {
  color: var(--ink);
  background: rgba(139,125,255,0.14);
  transform: translateY(-1px);
}

.nav-tab-locked {
  opacity: 0.5;
}

.nav-tab-locked:hover {
  opacity: 0.85;
  background: rgba(139,125,255,0.1);
}

.nav-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: rgba(255,255,255,0.12);
}

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: 86px;
}

#screen-campaign {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 40px;
}

.screen.active {
  display: flex;
  animation: screenIn 0.45s cubic-bezier(.25,1,.35,1);
}

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

/* ---------- HOME HERO ---------- */

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.logo-glyph {
  font-size: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(139,125,255,0.5));
  animation: bob 3.4s ease-in-out infinite;
  display: inline-block;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(8deg); }
}

.logo h1 {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 40px;
  letter-spacing: 5px;
  margin: 0;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--ink-dim);
  margin: 8px 0 32px;
  font-size: 14.5px;
  text-align: center;
  font-weight: 500;
}

/* ---------- HUB ---------- */

.hub-grid {
  width: min(92vw, 560px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hub-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mode-card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 22px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 18px 40px -20px rgba(139,125,255,0.3);
  transition: transform 0.22s cubic-bezier(.3,1.5,.4,1), box-shadow 0.22s ease;
  opacity: 0;
  animation: cardPopIn 0.5s cubic-bezier(.3,1.4,.4,1) forwards;
}

.hub-grid > .mode-card { animation-delay: 0.05s; }
.hub-row .mode-card:nth-child(1) { animation-delay: 0.14s; }
.hub-row .mode-card:nth-child(2) { animation-delay: 0.22s; }

@keyframes cardPopIn {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mode-card:hover {
  transform: translateY(-5px) scale(1.015);
  box-shadow: 0 24px 50px -20px rgba(139,125,255,0.5);
}

.mode-card-primary {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, rgba(139,125,255,0.16), rgba(255,133,192,0.13));
}

.mode-glyphs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: 0 0 auto;
}

.mode-glyphs img {
  width: 27px;
  height: 27px;
}

.mode-card-primary .mode-text { flex: 1; }

.mode-card-primary .mode-text h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
}

.mode-card-primary .mode-text p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-dim);
  font-weight: 500;
}

.mode-arrow {
  font-size: 20px;
  color: var(--accent);
  transition: transform 0.2s ease;
}

.mode-card-primary:hover .mode-arrow {
  transform: translateX(5px);
}

.mode-card-compact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.mode-card-locked {
  opacity: 0.68;
}

.mode-card-locked:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px -20px rgba(139,125,255,0.4);
}

.mode-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(139,125,255,0.16);
  border: 1px solid rgba(139,125,255,0.3);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--accent);
  font-weight: 700;
}

.mode-icon {
  font-size: 26px;
}

.mode-card-compact .mode-text h3 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 800;
}

.mode-card-compact .mode-text p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-dim);
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translate(-50%, 20px);
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--ink);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10;
  box-shadow: 0 14px 34px -14px rgba(139,125,255,0.5);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.btn-back {
  align-self: flex-start;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 18px;
  padding: 4px 0;
  transition: color 0.15s ease;
}

.btn-back:hover { color: var(--accent); }

.setup-title {
  font-size: 23px;
  margin: 0 0 22px;
  font-weight: 800;
}

.picker-label {
  color: var(--ink-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 10px;
  text-align: center;
  font-weight: 700;
}

.match-mode-picker { margin-bottom: 22px; }

.match-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* single-mode: the online screen currently has only one match-mode card ("Повний") — a lone
   item inside a repeat(2, 1fr) grid still reserves a second (empty) column sized off the same
   fr ratio, stretching the card roughly 2x wider than its bot-screen equivalents. Pin it to one
   narrow column instead so it matches #screen-start's card size. */
.match-mode-grid.single-mode {
  grid-template-columns: minmax(0, 1fr);
  max-width: 160px;
  margin: 0 auto;
}

.match-mode-card {
  background: var(--bg-1);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 10px 22px -18px rgba(139,125,255,0.3);
  transition: transform 0.18s cubic-bezier(.3,1.5,.4,1), border-color 0.18s ease, box-shadow 0.18s ease;
}

.match-mode-card:hover { transform: translateY(-2px); }

.mmc-icon { font-size: 21px; }
.mmc-name { font-size: 14px; font-weight: 800; color: var(--ink); }
.mmc-desc { font-size: 10.5px; color: var(--ink-dim); line-height: 1.3; }

.match-mode-card.active {
  border-color: var(--accent);
  box-shadow: 0 16px 34px -14px var(--accent);
  background: rgba(139,125,255,0.12);
}
.match-mode-card.active .mmc-name { color: var(--accent); }

.board-size-picker { margin-bottom: 22px; }

.board-size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.board-size-card {
  background: var(--bg-1);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 10px 22px -18px rgba(139,125,255,0.3);
  transition: transform 0.18s cubic-bezier(.3,1.5,.4,1), border-color 0.18s ease, box-shadow 0.18s ease;
}

.board-size-card:hover { transform: translateY(-2px); }

.bsc-name { font-size: 12.5px; font-weight: 800; color: var(--ink); }
.bsc-desc { font-size: 10px; color: var(--ink-dim); }

.board-size-card.active {
  border-color: var(--accent);
  box-shadow: 0 16px 34px -14px var(--accent);
  background: rgba(139,125,255,0.12);
}
.board-size-card.active .bsc-name { color: var(--accent); }

.faction-picker { margin-bottom: 22px; }

.faction-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.faction-card {
  background: var(--bg-1);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: 18px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 12px 26px -18px rgba(139,125,255,0.3);
  transition: transform 0.18s cubic-bezier(.3,1.5,.4,1), border-color 0.18s ease, box-shadow 0.18s ease;
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 600;
}

.faction-card img { width: 52px; height: 52px; transition: filter 0.18s ease; }

.faction-card:hover { transform: translateY(-4px) scale(1.03); }

.faction-card.selected {
  border-color: var(--card-color, var(--accent));
  color: var(--ink);
  box-shadow: 0 16px 34px -14px var(--card-color, var(--accent));
}

.faction-card[data-faction="blue"]   { --card-color: var(--f-blue); }
.faction-card[data-faction="red"]    { --card-color: var(--f-red); }
.faction-card[data-faction="green"]  { --card-color: var(--f-green); }
.faction-card[data-faction="yellow"] { --card-color: var(--f-yellow); }

.skill-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  margin-bottom: 22px;
  border-radius: 16px;
  background: var(--bg-1);
  border: 1px solid var(--skill-color, rgba(255,255,255,0.1));
  box-shadow: 0 14px 30px -18px var(--skill-color, transparent);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(.3,1.4,.4,1);
}
.skill-preview.show { opacity: 1; transform: translateY(0); }

.skill-preview-icon { width: 34px; height: 34px; flex: 0 0 auto; }

.skill-preview-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.skill-preview-name { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.skill-preview-desc { font-size: 11.5px; color: var(--ink-dim); line-height: 1.35; }

.difficulty-picker { margin-bottom: 28px; }

.diff-grid {
  display: flex;
  gap: 10px;
}

.diff-card {
  background: var(--bg-1);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 8px 18px;
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px -18px rgba(139,125,255,0.3);
  transition: all 0.18s ease;
}

.diff-card:hover { transform: translateY(-2px); }

.diff-card.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(139,125,255,0.14);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  padding: 15px 46px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 16px 36px -12px rgba(139,125,255,0.65);
  transition: transform 0.18s cubic-bezier(.3,1.6,.4,1), box-shadow 0.18s ease;
}

.btn-primary:hover:not(:disabled) { transform: translateY(-3px) scale(1.02); box-shadow: 0 20px 42px -12px rgba(139,125,255,0.75); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.99); }

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  margin-top: 16px;
  background: var(--bg-1);
  border: 2px solid rgba(255,255,255,0.08);
  color: var(--ink-dim);
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 20px -16px rgba(139,125,255,0.25);
  transition: all 0.15s ease;
}
.btn-ghost:hover { border-color: var(--danger); color: var(--danger); }

#screen-start, #screen-campaign, #screen-profile, #screen-online { justify-content: flex-start; }

/* ---------- ONLINE MATCHMAKING SCREEN ---------- */

.online-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  margin: 60px 0 28px;
}
/* .online-status's own `display: flex` has the same specificity as the browser's built-in
   `[hidden] { display: none }` rule, and author CSS always wins that tie regardless of source
   order — the same bug class already hit once with .admin-gate. Without this, toggling the
   `hidden` DOM property on #online-searching never actually hides it, so setup and searching
   render stacked on top of each other. */
#online-searching[hidden] { display: none; }

/* #screen-start's pickers (.match-mode-picker, .faction-picker, #btn-start, ...) are direct
   flex children of #screen-start.screen, so each sizes to its own content and centers itself
   individually. #online-setup wraps the equivalent online elements in one plain block div,
   which instead becomes a single flex child sized to fit its WIDEST descendant (stretching every
   picker inside to match), and turns #btn-online-find into ordinary left-aligned inline flow
   instead of an individually-centered flex item — display:contents removes #online-setup as a
   layout box so its children behave exactly like #screen-start's, restoring identical sizing and
   centering. (Same [hidden]-specificity override needed again, see comment above.) */
#online-setup { display: contents; }
#online-setup[hidden] { display: none; }

.online-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  animation: onlineSpin 0.9s linear infinite;
}
@keyframes onlineSpin {
  to { transform: rotate(360deg); }
}

.online-status-text {
  font-size: 15px;
  color: var(--ink-dim);
  text-align: center;
}

/* ---------- GAME SCREEN ---------- */

#screen-game {
  justify-content: flex-start;
  padding-top: 62px;
  padding-bottom: 40px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.match-hud {
  width: 100%;
  max-width: 560px;
  margin-bottom: 14px;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}

/* moved out of .match-hud-row's grid entirely (was grid-column:2/grid-row:1, sharing the same
   center column as the player names) -- on narrow screens it crowded right up against both
   player names (Hantes's report, 2026-07-24). A first attempt made it its own row above the
   header, but that just added height and pushed the board below the fold on a short phone
   screen (also reported). #screen-game reserves a 62px padding-top for the top-nav, which
   .in-match hides (translateY+opacity, see body.in-match .top-nav) -- so that strip sits empty
   during an actual match. Fixed-positioning the buttons into it costs zero extra height. */
.match-center-actions {
  position: fixed;
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* same size/top as .nav-icon-btn (settings/trophy corner cluster) -- Hantes's ask, 2026-07-24 */
.match-surrender-btn,
.match-emoji-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ink-dim);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.match-surrender-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  transform: scale(1.08);
}

.match-emoji-btn:hover {
  border-color: var(--accent);
  transform: scale(1.08);
}

.emoji-picker {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: 200px;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 20px 46px -14px rgba(0,0,0,0.6);
}

.emoji-picker.show { display: flex; }

.emoji-option {
  width: 40px;
  height: 40px;
  padding: 4px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(.3,1.6,.4,1), background 0.15s ease;
}

.emoji-option img { width: 100%; height: 100%; object-fit: contain; }

.emoji-option:hover {
  background: rgba(255,255,255,0.12);
  transform: scale(1.15);
}

.match-avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.match-level-badge {
  position: absolute;
  left: -4px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 2px solid var(--bg-1);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px -2px rgba(139,125,255,0.6);
}

.match-reaction-bubble {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 2px solid var(--accent);
  box-shadow: 0 6px 16px -4px rgba(0,0,0,0.6);
  background-size: 70%;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(.3,1.6,.4,1);
}

.match-reaction-bubble.show {
  opacity: 1;
  transform: scale(1);
}

/* 2 rows x 3 columns, filled in DOM order: player/score/player, then skill/surrender/skill —
   grid auto-placement lines the score and the surrender button up dead-center in both rows */
.match-hud-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px 8px;
}

.match-player-block {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

/* explicit grid coordinates for every HUD item — not just DOM-order auto-placement — because
   Classic mode hides both skill buttons (display:none), and auto-placement would otherwise slide
   the remaining row-2 items (the score capsule) into the wrong column once they're gone */
.match-player-block.me { grid-column: 1; grid-row: 1; justify-self: start; }
.match-player-block.opp { grid-column: 3; grid-row: 1; justify-self: end; }

.match-player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 auto;
  background: rgba(255,255,255,0.06);
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px -2px rgba(139,125,255,0.55);
}

.match-player-block.opp .match-player-avatar {
  border-color: var(--f-purple);
  box-shadow: 0 0 12px -2px rgba(155,91,255,0.55);
}

/* the opp avatar sits at the far right edge of the header -- mirror the reaction bubble to the
   inside (top-left) instead of top-right, or it'd point off toward the screen edge */
.match-player-block.opp .match-reaction-bubble { right: auto; left: -14px; }

.match-player-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.match-player-block.opp .match-player-info { align-items: flex-end; text-align: right; }

/* name + flag as two separate flex children (not one concatenated string) so a long name's
   ellipsis truncation can never eat the flag with it -- that's exactly what happened when they
   were one text node: "OpponentBot 🇵🇱" past the max-width silently dropped the flag entirely */
.match-player-name-row {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.match-player-block.opp .match-player-name-row { justify-content: flex-end; }

.match-player-flag {
  flex: 0 0 auto;
  font-size: 12px;
}

.match-player-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  /* shared by both "me" and "opp" (same class, no per-side override) so they're always the
     same effective length -- tightened from 120px so avatar+name can't crowd the header center
     on a narrow phone screen */
  max-width: 82px;
}

.match-player-rank {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  padding: 1px 7px;
  margin-top: 2px;
}

.skill-card.skill-card-me { grid-column: 1; grid-row: 2; justify-self: start; }
.skill-card.skill-card-opp { grid-column: 3; grid-row: 2; justify-self: end; }

/* two-tone score capsule — replaces the old plain-text "VS" divider. Each half's color comes
   from --turn-color, the same custom property updateTurnHUD() already keeps in sync with each
   side's actual faction (hexFor("me")/hexFor("bot")) — no extra JS needed here. overflow isn't
   hidden here (unlike before) specifically so each half's own glow can escape past the pill's
   edge instead of being clipped — the corner radius trick below keeps the pill shape anyway. */
.match-score-capsule {
  grid-column: 2;
  grid-row: 2;
  justify-self: center;
  display: flex;
  align-items: stretch;
}

.match-score-half {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 9px 18px;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  transition: box-shadow 0.2s ease;
}

.match-score-half.me {
  border-radius: 999px 0 0 999px;
  background: linear-gradient(135deg, var(--turn-color, var(--accent)), color-mix(in srgb, var(--turn-color, var(--accent)) 70%, black));
  box-shadow: -6px 0 26px -2px var(--turn-color, var(--accent));
}
.match-score-half.opp {
  border-radius: 0 999px 999px 0;
  background: linear-gradient(135deg, var(--turn-color, var(--f-purple)), color-mix(in srgb, var(--turn-color, var(--f-purple)) 70%, black));
  box-shadow: 6px 0 26px -2px var(--turn-color, var(--f-purple));
}

.match-score-half span.bump { display: inline-block; animation: scoreBump 0.38s cubic-bezier(.3,1.8,.4,1); }
@keyframes scoreBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.timer-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.timer-track {
  position: relative;
  flex: 1;
  height: 26px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px -2px rgba(139,125,255,0.7);
  transition: width 15s linear, background-color 0.3s ease;
}

.timer-fill.warn {
  background: var(--danger);
  animation: timerWarnPulse 0.6s ease-in-out infinite;
}

@keyframes timerWarnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-overlay-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  pointer-events: none;
}

.turn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
}

.timer-text {
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-dim);
  transition: color 0.3s ease;
}

.timer-text.warn {
  color: var(--danger);
}

.board-wrap {
  width: min(92vw, 68vh, 560px);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  transition: box-shadow 0.4s ease;
}

/* ---------- match-end board effect (plays ~2s before the result screen) ---------- */

.match-end-fx {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}

.match-end-fx.show-win {
  background: radial-gradient(circle at 50% 40%, rgba(46,224,138,0.35), transparent 65%);
  animation: matchEndFlash 1.8s ease-out forwards;
}

.match-end-fx.show-loss {
  background: radial-gradient(circle at 50% 40%, rgba(255,92,120,0.32), transparent 65%);
  animation: matchEndFlash 1.8s ease-out forwards;
}

.match-end-fx.show-draw {
  background: radial-gradient(circle at 50% 40%, rgba(157,148,191,0.28), transparent 65%);
  animation: matchEndFlash 1.8s ease-out forwards;
}

@keyframes matchEndFlash {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  100% { opacity: 0; }
}

.board-wrap.pulse-win {
  animation: boardPulse 0.9s cubic-bezier(.3,1.4,.4,1);
  box-shadow: 0 0 0 3px var(--success), 0 0 60px -6px rgba(46,224,138,0.65);
}

.board-wrap.pulse-loss {
  animation: boardShake 0.6s cubic-bezier(.3,1.4,.4,1);
  box-shadow: 0 0 0 3px var(--danger), 0 0 60px -6px rgba(255,92,120,0.55);
}

.board-wrap.pulse-draw {
  animation: boardPulse 0.9s cubic-bezier(.3,1.4,.4,1);
  box-shadow: 0 0 0 3px var(--ink-dim), 0 0 50px -8px rgba(157,148,191,0.5);
}

@keyframes boardPulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.035); }
  100% { transform: scale(1); }
}

@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-7px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(3px); }
}

.match-end-sparkle {
  position: fixed;
  z-index: 4;
  border-radius: 50%;
  pointer-events: none;
  animation: sparkleRise 1.5s ease-out forwards;
}

@keyframes sparkleRise {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-70px) scale(0.4); opacity: 0; }
}

.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 5px;
  background: var(--bg-1);
  border-radius: var(--radius);
  padding: 9px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 22px 55px -24px rgba(139,125,255,0.4);
}

.cell {
  position: relative;
  border-radius: 30%;
  background: rgba(255,255,255,0.045);
  cursor: default;
  overflow: visible;
}

/* holes: permanently unplayable cells on shaped boards — read as a true gap in the grid */
.cell[data-owner="hole"] {
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}
.cell[data-owner="hole"] .tile,
.cell[data-owner="hole"] .piece {
  display: none;
}

.cell .tile {
  position: absolute;
  inset: 0;
  background-size: 78%;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.4;
}

.cell .piece {
  position: absolute;
  inset: 0;
  background-size: 92%;
  background-repeat: no-repeat;
  background-position: center;
  transform: scale(0);
  transition: transform 0.22s cubic-bezier(.3,1.6,.4,1);
}

.cell.filled .piece { transform: scale(1); }

.cell[data-owner="me"]:not(.spawn):not(.capture) .piece {
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(1.18); transform: scale(1.035); }
}

.cell.spawn .piece { animation: spawnPop 0.36s cubic-bezier(.3,1.8,.4,1); }
@keyframes spawnPop {
  0%   { transform: scale(0); }
  55%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.cell.capture .piece { animation: captureFlip 0.44s ease; }
@keyframes captureFlip {
  0%   { transform: scale(1) rotateY(0deg); filter: brightness(1); }
  45%  { transform: scale(0.72) rotateY(90deg); filter: brightness(2); }
  55%  { transform: scale(0.72) rotateY(90deg); filter: brightness(2); }
  100% { transform: scale(1) rotateY(0deg); filter: brightness(1); }
}

/* ---------- move clarity: flying piece (jump) + growth beam (clone) ---------- */
/* both are appended to <body> and positioned via getBoundingClientRect, independent of the
   board's own grid layout/transforms — see flyPiece()/spawnMoveTrail() in game.js */

.piece-flight {
  position: fixed;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 25;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
}

.move-trail {
  position: fixed;
  height: 3px;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--trail-color, #fff), transparent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  animation: moveTrailFade 0.42s ease forwards;
}
@keyframes moveTrailFade {
  0%   { opacity: 0; transform: rotate(var(--trail-angle)) scaleX(0); }
  20%  { opacity: 0.85; transform: rotate(var(--trail-angle)) scaleX(0.55); }
  100% { opacity: 0; transform: rotate(var(--trail-angle)) scaleX(1); }
}

.cell.playable {
  cursor: pointer;
}
.cell.playable .tile { opacity: 0.6; }
.cell.playable:hover .tile { opacity: 0.95; }
.cell.playable:hover { transform: scale(1.05); }

.cell.hint-short::before,
.cell.hint-long::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 30%;
  pointer-events: none;
}
.cell.hint-short::before {
  border: 2.5px solid var(--hint-color, var(--accent));
  animation: hintPulse 1.3s ease-in-out infinite;
}
.cell.hint-long::before {
  border: 2.5px dashed var(--hint-color, var(--accent-2));
  opacity: 0.85;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.02); }
}

.cell.selected {
  box-shadow: 0 0 0 2.5px var(--hint-color, var(--accent)), 0 0 18px -2px var(--hint-color, var(--accent));
  border-radius: 30%;
}

.cell.selected .tile { opacity: 0.55; }

/* ---------- SKILL CARDS (mine + opponent's, grid children of .match-hud-row's 2nd row) ---------- */
/* .skill-bar is kept only as a JS visibility toggle (Classic vs Full mode) — no layout of its own */

/* icon + name in one compact row, no description line (that text still gets set on the hidden
   .skill-status for anyone inspecting, but isn't shown — state is communicated visually: glow
   when available, a small badge over the icon when locked/used, see .skill-icon-wrap below) */
.skill-card {
  position: relative;
  width: auto;
  min-height: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.1);
  background: var(--bg-1);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.18s cubic-bezier(.3,1.5,.4,1), border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.skill-card-opp { cursor: default; }

.skill-icon-wrap {
  position: relative;
  display: inline-flex;
}

.skill-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  filter: saturate(0.5) brightness(0.75);
  transition: filter 0.2s ease;
}

/* state badge — small circle over the icon's corner, empty/invisible unless locked or used */
.skill-icon-wrap::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  line-height: 1;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.18);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.skill-card.locked .skill-icon-wrap::after { content: "🔒"; opacity: 1; }
.skill-card.used .skill-icon-wrap::after { content: "✓"; opacity: 1; color: var(--success); font-weight: 800; }

.skill-name {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* available: my turn, unlocked, unused — inviting, glowing */
.skill-card.available {
  border-color: var(--skill-color, var(--accent));
  box-shadow: 0 0 0 1px var(--skill-color, var(--accent)), 0 0 26px -6px var(--skill-color, var(--accent));
  animation: skillGlow 2.2s ease-in-out infinite;
}
.skill-card.available .skill-icon { filter: none; }
.skill-card.available:hover { transform: translateY(-2px) scale(1.01); }

@keyframes skillGlow {
  0%, 100% { box-shadow: 0 0 0 1px var(--skill-color, var(--accent)), 0 0 22px -8px var(--skill-color, var(--accent)); }
  50% { box-shadow: 0 0 0 1px var(--skill-color, var(--accent)), 0 0 34px -6px var(--skill-color, var(--accent)); }
}

/* unlocked and armed, just not tappable this instant (my turn hasn't come, or it's the opponent's card) */
.skill-card.waiting,
.skill-card.armed {
  border-color: var(--skill-color, var(--accent));
  opacity: 0.7;
}
.skill-card.waiting .skill-icon,
.skill-card.armed .skill-icon { filter: saturate(0.7) brightness(0.9); }

/* locked: hasn't unlocked yet */
.skill-card.locked {
  opacity: 0.45;
  cursor: default;
}

/* used: spent for the rest of the match */
.skill-card.used {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(0.6);
}

/* targeting mode: waiting for the player to pick where to aim */
.skill-card.targeting {
  border-color: var(--skill-color, var(--accent));
  box-shadow: 0 0 0 2px var(--skill-color, var(--accent)), 0 0 30px -4px var(--skill-color, var(--accent));
}

/* one-shot pop the instant a skill unlocks (5th move) — separate from .available's continuous
   breathing glow, this fires once so the unlock moment itself grabs attention */
.skill-card.just-unlocked {
  animation: skillUnlockPop 0.7s cubic-bezier(.25,1.6,.4,1);
}

@keyframes skillUnlockPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.28); box-shadow: 0 0 0 5px var(--skill-color, var(--accent)), 0 0 34px 6px var(--skill-color, var(--accent)); }
  65%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}

.cell.skill-target::before {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 30%;
  border: 2.5px dashed var(--skill-color, var(--accent));
  animation: hintPulse 1.1s ease-in-out infinite;
  pointer-events: none;
}
.cell.skill-target { cursor: pointer; }
.cell.skill-source-picked {
  box-shadow: 0 0 0 2.5px var(--skill-color, var(--accent)), 0 0 20px var(--skill-color, var(--accent));
}

/* ---------- skill effects on the board ---------- */

.cell.frozen { cursor: not-allowed; }
.cell.frozen .tile { opacity: 0.7; }
.cell.frozen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 30%;
  background: radial-gradient(circle, rgba(120,210,255,0.35), transparent 70%);
  box-shadow: inset 0 0 0 2px rgba(150,220,255,0.7);
  animation: frostPulse 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes frostPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.cell.fx-destroy .piece { animation: fxDestroy 0.55s ease forwards; }
@keyframes fxDestroy {
  0%   { transform: scale(1) rotate(0deg); filter: brightness(1) saturate(1); }
  35%  { transform: scale(1.3) rotate(-6deg); filter: brightness(3) saturate(2) hue-rotate(-20deg); }
  100% { transform: scale(0) rotate(12deg); filter: brightness(0.5); }
}

.cell.fx-warp-out .piece { animation: fxWarpOut 0.5s ease forwards; }
@keyframes fxWarpOut {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; filter: brightness(1); }
  60%  { transform: scale(1.25) rotate(140deg); filter: brightness(2) saturate(1.6); }
  100% { transform: scale(0) rotate(280deg); opacity: 0; }
}


.cell.fx-hack .piece { animation: fxHack 0.6s steps(6) forwards; }
@keyframes fxHack {
  0%   { transform: scale(1) translateX(0); filter: hue-rotate(0deg) saturate(1); }
  20%  { transform: scale(1.05) translateX(-3px); filter: hue-rotate(90deg) saturate(3); }
  40%  { transform: scale(0.95) translateX(3px); filter: hue-rotate(180deg) saturate(3); }
  60%  { transform: scale(1.05) translateX(-2px); filter: hue-rotate(270deg) saturate(3); }
  80%  { transform: scale(0.98) translateX(2px); filter: hue-rotate(320deg) saturate(2); }
  100% { transform: scale(1) translateX(0); filter: hue-rotate(360deg) saturate(1); }
}

.spark-piece {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 16;
  animation: sparkOut 0.6s ease-out forwards;
}
@keyframes sparkOut {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--sx), var(--sy)) scale(0.2); opacity: 0; }
}

/* ---------- EPIC skill activation sequence: dim screen, center impact card, spotlight the board ---------- */

.skill-epic-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: rgba(5, 4, 14, 0);
  transition: background 0.28s ease;
}
.skill-epic-overlay.dim { background: rgba(5, 4, 14, 0.8); }

.skill-epic-ring {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 41;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 3px solid var(--skill-color, #fff);
  transform: translate(-50%, -50%);
  opacity: 0.85;
  pointer-events: none;
  animation: epicRing 0.85s ease-out forwards;
}
@keyframes epicRing {
  0%   { width: 10px; height: 10px; opacity: 0.9; }
  100% { width: 640px; height: 640px; opacity: 0; }
}

.skill-epic-card {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 42;
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  text-align: center;
}
.skill-epic-card.burst {
  animation: epicBurst 0.95s cubic-bezier(.2,1.8,.3,1) forwards;
}
@keyframes epicBurst {
  0%   { transform: translate(-50%,-50%) scale(0.2) rotate(-6deg); opacity: 0; }
  16%  { transform: translate(-50%,-50%) scale(1.18) rotate(2deg); opacity: 1; }
  26%  { transform: translate(-50%,-50%) scale(1) rotate(0deg); opacity: 1; }
  78%  { transform: translate(-50%,-50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.85) rotate(0deg); opacity: 0; }
}

.skill-epic-by {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--ink-dim);
}
.skill-epic-icon {
  width: 104px;
  height: 104px;
  filter: drop-shadow(0 0 36px var(--skill-color, #fff));
}
.skill-epic-name {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 26px var(--skill-color, #fff), 0 4px 14px rgba(0,0,0,0.6);
  max-width: 84vw;
}

.skill-epic-hole {
  position: fixed;
  z-index: 40;
  border-radius: 24%;
  box-shadow: 0 0 0 9999px var(--dim-color, rgba(5, 4, 14, 0.84));
  pointer-events: none;
  transition: top 0.5s cubic-bezier(.3,1,.3,1), left 0.5s cubic-bezier(.3,1,.3,1),
              width 0.5s cubic-bezier(.3,1,.3,1), height 0.5s cubic-bezier(.3,1,.3,1);
}
.skill-epic-hole.settle {
  animation: epicHoleSettle 0.35s cubic-bezier(.2,1,.3,1);
}
@keyframes epicHoleSettle {
  0%   { outline: 3px solid var(--skill-color, #fff); outline-offset: 10px; }
  100% { outline: 3px solid transparent; outline-offset: 0; }
}
.skill-epic-hole.fade-out {
  opacity: 0;
  transition: opacity 0.32s ease;
}

/* ---------- CAMPAIGN MAP ---------- */

.campaign-subtitle {
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
  margin: -14px 0 18px;
}

.campaign-map {
  position: relative;
  width: 100%;
  max-width: 380px;
  /* aspect-ratio set inline by campaign.js — grows with level count, so it can't be a fixed value here */
  margin: 0 auto;
}

.campaign-path-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.campaign-path-svg path {
  fill: none;
  stroke: rgba(139,125,255,0.35);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 2 14;
}

.campaign-node {
  position: absolute;
  width: 66px;
  height: 66px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.12);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  box-shadow: 0 14px 30px -16px rgba(139,125,255,0.4);
  transition: transform 0.18s cubic-bezier(.3,1.6,.4,1), border-color 0.18s ease, box-shadow 0.18s ease;
}
.campaign-node:hover { transform: translate(-50%, -50%) scale(1.07); }

.campaign-node.locked {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.7);
}
.campaign-node.locked:hover { transform: translate(-50%, -50%); }

.campaign-node.next-up {
  border-color: var(--accent);
  animation: campaignNodeGlow 2.2s ease-in-out infinite;
}
@keyframes campaignNodeGlow {
  0%, 100% { box-shadow: 0 0 0 1px var(--accent), 0 0 22px -8px var(--accent); }
  50%      { box-shadow: 0 0 0 1px var(--accent), 0 0 34px -4px var(--accent); }
}

.campaign-node.done { border-color: #ffd23f; }

.campaign-node-lock { font-size: 20px; }

.campaign-node-stars {
  display: flex;
  gap: 1px;
  font-size: 10px;
  line-height: 1;
  color: rgba(255,255,255,0.22);
}
.campaign-node-stars .filled { color: #ffd23f; }

/* ---------- campaign level-intro modal (reuses .tutorial-modal shell) ---------- */

.campaign-intro-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.campaign-intro-badge.easy   { background: rgba(79,214,106,0.15); color: #4fd66a; }
.campaign-intro-badge.medium { background: rgba(255,191,46,0.15); color: #ffbf2e; }
.campaign-intro-badge.hard   { background: rgba(255,91,61,0.15);  color: #ff5b3d; }

.campaign-intro-goal {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px 14px;
  margin: -8px 0 18px;
}

.campaign-intro-best {
  display: flex;
  justify-content: center;
  gap: 4px;
  font-size: 18px;
  color: rgba(255,255,255,0.18);
  margin: -12px 0 18px;
}
.campaign-intro-best .filled { color: #ffd23f; }

/* ---------- RESULT SCREEN ---------- */

.result-card {
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 30px;
  padding: 42px 46px;
  text-align: center;
  max-width: 360px;
  animation: resultPop 0.42s cubic-bezier(.3,1.5,.4,1);
  box-shadow: 0 32px 70px -24px rgba(139,125,255,0.45);
}

@keyframes resultPop {
  0% { transform: scale(0.82); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-icon { font-size: 54px; margin-bottom: 6px; }

.result-card h2 {
  margin: 0 0 6px;
  font-size: 27px;
  font-weight: 800;
}

.result-card p {
  color: var(--ink-dim);
  margin: 0 0 20px;
  font-size: 14px;
  font-weight: 500;
}

.result-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 26px;
}
.result-score img { width: 34px; height: 34px; }

/* ---------- campaign-specific result screen additions ---------- */

.result-stars {
  justify-content: center;
  gap: 8px;
  font-size: 34px;
  line-height: 1;
  margin-bottom: 10px;
  color: rgba(255,255,255,0.15);
}
.result-star.earned {
  color: #ffd23f;
  text-shadow: 0 0 18px rgba(255,210,63,0.7);
  animation: starPop 0.4s cubic-bezier(.3,1.8,.4,1) backwards;
}
.result-star:nth-child(1).earned { animation-delay: 0.1s; }
.result-star:nth-child(2).earned { animation-delay: 0.25s; }
.result-star:nth-child(3).earned { animation-delay: 0.4s; }
@keyframes starPop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.3) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-campaign-note {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 18px;
}

.result-stars, .result-campaign-note,
#btn-campaign-retry, #btn-campaign-next, #btn-campaign-map {
  display: none;
}
.result-card.campaign-mode #btn-again,
.result-card.campaign-mode #btn-home {
  display: none;
}
.result-card.campaign-mode .result-stars { display: flex; }
.result-card.campaign-mode .result-campaign-note { display: block; }
.result-card.campaign-mode #btn-campaign-map { display: inline-block; }
.result-card.campaign-mode.won #btn-campaign-next { display: inline-block; }
.result-card.campaign-mode.lost #btn-campaign-retry { display: inline-block; }

.result-card.shake { animation: resultShake 0.5s ease; }
@keyframes resultShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-1deg); }
  40% { transform: translateX(8px) rotate(1deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ---------- click ripple ---------- */

.ripple {
  position: fixed;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  pointer-events: none;
  z-index: 50;
  animation: rippleOut 0.55s ease-out forwards;
}
@keyframes rippleOut {
  0%   { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(16); opacity: 0; }
}

/* ---------- victory confetti ---------- */

.confetti-piece {
  position: fixed;
  top: -20px;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 50;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(var(--spin, 480deg)); opacity: 0.15; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* ---------- tutorial: offer modal ---------- */

.tutorial-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(6, 5, 18, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.tutorial-modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-modal {
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 30px 28px;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 30px 70px -20px rgba(139,125,255,0.45);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(.3,1.5,.4,1);
}

.tutorial-modal-backdrop.show .tutorial-modal {
  transform: scale(1);
}

.tutorial-modal .tm-icon { font-size: 40px; margin-bottom: 10px; }
.tutorial-modal h3 { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
.tutorial-modal p { margin: 0 0 22px; color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; }

.tutorial-modal .tm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- tutorial: side notice (declined earlier) ---------- */

.tutorial-notice {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 6;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 12px 14px;
  max-width: 230px;
  box-shadow: 0 18px 40px -18px rgba(139,125,255,0.4);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.3,1.4,.4,1);
}

.tutorial-notice.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tutorial-notice p {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.4;
}

.tutorial-notice .tn-yes {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.tutorial-notice .tn-close {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
}
.tutorial-notice .tn-close:hover { color: var(--ink); }

/* ---------- tutorial: guided spotlight overlay ---------- */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.tutorial-hole {
  position: absolute;
  border-radius: 30%;
  box-shadow: 0 0 0 9999px rgba(6, 5, 18, 0.78);
  transition: top 0.4s cubic-bezier(.3,1,.3,1), left 0.4s cubic-bezier(.3,1,.3,1),
              width 0.4s cubic-bezier(.3,1,.3,1), height 0.4s cubic-bezier(.3,1,.3,1),
              opacity 0.25s ease;
}

.tutorial-finger {
  position: absolute;
  font-size: 36px;
  transform: translate(-50%, -30%);
  animation: tutorialTap 0.9s ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.55));
  transition: top 0.4s cubic-bezier(.3,1,.3,1), left 0.4s cubic-bezier(.3,1,.3,1), opacity 0.25s ease;
}

@keyframes tutorialTap {
  0%, 100% { transform: translate(-50%, -30%) scale(1); }
  50% { transform: translate(-50%, -18%) scale(0.9); }
}

.tutorial-caption {
  position: absolute;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.16);
  padding: 16px 24px;
  border-radius: 22px;
  font-size: 21px;
  line-height: 1.3;
  font-weight: 800;
  text-align: center;
  max-width: min(320px, 88vw);
  box-shadow: 0 20px 46px -14px rgba(139,125,255,0.55);
  transition: top 0.4s cubic-bezier(.3,1,.3,1), left 0.4s cubic-bezier(.3,1,.3,1), opacity 0.25s ease;
}

.tutorial-hole.hidden, .tutorial-finger.hidden, .tutorial-caption.hidden {
  opacity: 0;
}

/* ---------- profile screen ---------- */

#screen-profile {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 40px;
  align-items: stretch;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: 8px auto 28px;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex: 0 0 auto;
}

.profile-avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.profile-avatar-edit {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(.3,1.6,.4,1), border-color 0.15s ease;
}

.profile-avatar-edit:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

.profile-level-badge {
  position: absolute;
  left: -4px;
  bottom: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 2px solid var(--bg-1);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px -2px rgba(139,125,255,0.6);
}

.profile-xp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: -12px auto 22px;
}

.profile-xp-label {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-dim);
}

.profile-xp-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.profile-xp-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s cubic-bezier(.3,1,.3,1);
}

.profile-xp-text {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.avatar-picker {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: -14px auto 22px;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px;
}

.avatar-picker.show { display: flex; }

.avatar-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.avatar-picker-credit {
  font-size: 10px;
  color: var(--ink-dim);
  text-align: center;
  margin: 0;
}

.avatar-picker-credit a {
  color: var(--ink-dim);
  text-decoration: underline;
}

.avatar-option {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  padding: 0;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s cubic-bezier(.3,1.6,.4,1), border-color 0.15s ease;
}

.avatar-option img { width: 100%; height: 100%; object-fit: cover; }

.avatar-option:hover { transform: scale(1.08); }

.avatar-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,125,255,0.35);
}

.profile-hero-text {
  flex: 1 1 auto;
  min-width: 0;
}

.profile-name {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 19px;
  color: var(--ink);
  margin: 0 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-rank-pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 5px 11px;
}

.profile-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.profile-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 22px;
}

.profile-tab {
  flex: 1 1 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.profile-tab:hover { color: var(--ink); }

.profile-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.profile-panel { display: none; width: 100%; }
.profile-panel.active { display: block; }

.profile-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 26px;
}

.profile-stat-card {
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
}

.profile-stat-value {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.profile-stat-label {
  font-size: 10.5px;
  color: var(--ink-dim);
  margin-top: 4px;
}

.profile-section {
  width: 100%;
  max-width: 560px;
  margin: 0 auto 26px;
}

.profile-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
}

.profile-section-title span {
  color: var(--ink-dim);
  font-weight: 600;
}

.profile-faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.profile-faction-card {
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
}

.profile-faction-card img {
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
}

.profile-faction-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.profile-faction-stat {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.profile-ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.profile-ach-grid .ach-row {
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 12px;
}

.profile-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-history-empty {
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.profile-history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-1);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 3px solid var(--ink-dim);
  border-radius: 14px;
  padding: 10px 14px;
}

.profile-history-row.won {
  border-left-color: var(--success);
  background: linear-gradient(90deg, rgba(46,224,138,0.14), rgba(46,224,138,0.04) 60%), var(--bg-1);
}

.profile-history-row.lost {
  border-left-color: var(--danger);
  background: linear-gradient(90deg, rgba(255,92,120,0.14), rgba(255,92,120,0.04) 60%), var(--bg-1);
}

.profile-history-faction {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.profile-history-info {
  flex: 1 1 auto;
  min-width: 0;
}

.profile-history-result {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.profile-history-meta {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.profile-history-score {
  flex: 0 0 auto;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 4px 12px;
}

.profile-history-row.won .profile-history-score { color: var(--success); }
.profile-history-row.lost .profile-history-score { color: var(--danger); }

@media (max-width: 480px) {
  .logo h1 { font-size: 30px; letter-spacing: 3px; }
  .faction-card img { width: 42px; height: 42px; }
}
