:root {
  --bg-1: #ff2fb2;
  --bg-2: #d91598;
  --bg-3: #a61182;
  --card: #5e1d64;
  --card-2: #4a1552;
  --line: #d58ee9;
  --text: #fff3ff;
  --muted: #ffd6f4;
  --accent: #43ef8f;
  --accent-2: #19cfe8;
  --warn: #ffe36a;
  --danger: #ffd166;
}

* { box-sizing: border-box; }
* {
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 560px at 8% 0%, rgba(124, 255, 247, 0.22), transparent 60%),
    radial-gradient(900px 540px at 100% 100%, rgba(255, 154, 236, 0.26), transparent 60%),
    linear-gradient(165deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
}

.bg-orb, .bg-glow { pointer-events: none; }
.bg-orb { position: fixed; border-radius: 50%; filter: blur(52px); opacity: 0.24; animation: float 9s ease-in-out infinite; }
.orb-a { width: 220px; height: 220px; left: -80px; top: 10%; background: #1f5ccf; }
.orb-b { width: 280px; height: 280px; right: -100px; top: 14%; background: #1a9a83; animation-delay: -2.5s; }
.orb-c { width: 220px; height: 220px; right: 24%; bottom: -80px; background: #5929d0; animation-delay: -5s; }

.app {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 12px 28px;
  z-index: 3;
}
.global-back {
  position: sticky;
  top: 10px;
  z-index: 45;
  margin-bottom: 10px;
  min-width: 100px;
}
.theme-fab {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 40;
  min-width: 108px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.2px;
  text-shadow: 0 1px 0 rgba(7, 19, 39, 0.9);
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.08) 22%, rgba(255, 255, 255, 0) 24%),
    linear-gradient(170deg, var(--accent), var(--accent-2) 52%, color-mix(in srgb, var(--accent-2) 70%, black 30%));
  box-shadow: 0 7px 0 color-mix(in srgb, var(--accent-2) 55%, black 45%), 0 14px 22px rgba(0, 0, 0, 0.25);
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.theme-fab:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}
.theme-fab:active {
  transform: translateY(2px);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent-2) 55%, black 45%), 0 10px 16px rgba(0, 0, 0, 0.25);
}
.theme-drawer {
  position: absolute;
  top: 56px;
  right: 10px;
  width: min(440px, calc(100% - 20px));
  z-index: 39;
  border: 1px solid rgba(255, 206, 247, 0.62);
  background: linear-gradient(160deg, rgba(94, 29, 100, 0.9), rgba(74, 21, 82, 0.86));
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 12px 28px rgba(66, 0, 62, 0.35);
}
#settingsPanel .theme-drawer {
  position: static;
  width: 100%;
  margin: 8px 0 0;
}
.theme-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.theme-head-actions {
  display: flex;
  gap: 6px;
}
.theme-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.theme-chip {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.theme-chip:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
}
.theme-chip.active {
  border-color: #fff6a8;
  box-shadow: 0 0 0 2px rgba(255, 241, 160, 0.28);
}
.btn.tiny {
  padding: 6px 10px;
  font-size: 12px;
}
.main-menu-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
#mainMenuPanel .mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.lottie-icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 0 rgba(9, 32, 63, 0.65));
  background: rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  overflow: hidden;
}
#mainMenuPanel h1 {
  font-size: clamp(34px, 7vw, 48px);
  text-align: center;
}
#mainMenuPanel .subtitle {
  text-align: center;
}
#mainMenuPanel .mode-btn {
  font-size: 22px;
  padding: 14px 16px;
}

.panel {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 16px 40px rgba(66, 0, 62, 0.34);
  animation: panelIn 220ms ease;
}
.panel + .panel { margin-top: 10px; }

h1, h2 { margin: 0 0 10px; }
.subtitle, .hint, .label { color: var(--muted); }
.error { color: var(--danger); min-height: 18px; }
.status { margin: 8px 0 10px; color: var(--warn); min-height: 20px; }
.value { margin: 2px 0 0; font-size: 20px; font-weight: 700; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0; }
.join-block { display: flex; gap: 8px; margin-top: 8px; }
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 12px 0 6px; }

input, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card-2) 78%, black 22%);
  color: var(--text);
  padding: 10px;
  font-size: 14px;
}

.btn, .big-btn {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44) 0%, rgba(255, 255, 255, 0.05) 22%, rgba(255, 255, 255, 0) 24%),
    linear-gradient(170deg, var(--accent), var(--accent-2) 52%, color-mix(in srgb, var(--accent-2) 70%, black 30%));
  color: var(--text);
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(9, 32, 63, 0.95);
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 8px 0 rgba(10, 82, 138, 0.72), 0 16px 24px rgba(0, 0, 0, 0.3);
}
.btn:focus,
.big-btn:focus,
.theme-chip:focus,
.theme-fab:focus,
.game-card:focus,
.cell:focus,
button:focus {
  outline: none;
}
.btn:hover, .big-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.mode-btn {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44) 0%, rgba(255, 255, 255, 0.05) 22%, rgba(255, 255, 255, 0) 24%),
    linear-gradient(170deg, var(--accent), var(--accent-2) 52%, color-mix(in srgb, var(--accent-2) 70%, black 30%));
}
.mode-btn:hover {
  box-shadow: 0 8px 0 rgba(10, 82, 138, 0.72), 0 18px 26px rgba(0, 0, 0, 0.32);
}
.btn.primary, .big-btn.primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.08) 24%, rgba(255, 255, 255, 0) 26%),
    linear-gradient(145deg, var(--accent), var(--accent-2) 70%, #11a6da);
  border: 1px solid rgba(159, 255, 247, 0.62);
  color: #f7fffe;
  text-shadow: 0 2px 0 rgba(8, 42, 50, 0.95);
  box-shadow: 0 8px 0 rgba(12, 124, 128, 0.76), 0 18px 26px rgba(0, 0, 0, 0.34);
}
.btn.ghost {
  background: color-mix(in srgb, var(--card) 72%, black 28%);
  border-color: var(--line);
  box-shadow: 0 8px 0 rgba(88, 22, 86, 0.72), 0 16px 24px rgba(0, 0, 0, 0.28);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
  box-shadow: none !important;
}
.lower-gap {
  margin-top: 14px;
}
.hidden-controls {
  display: none;
}
.big-btn { width: 100%; padding: 12px; font-size: 15px; }
.theme-profile {
  background: linear-gradient(130deg, #2e4f89, #1c2f58);
  border-color: #4c6fb5;
}
.theme-store {
  background: linear-gradient(130deg, #3b6b55, #214437);
  border-color: #59b28a;
}
.theme-games {
  background: linear-gradient(130deg, #5b3f93, #2e2150);
  border-color: #8c6ee0;
}
.theme-profile:hover,
.theme-store:hover,
.theme-games:hover {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}

.profile-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-top: 10px;
  background: color-mix(in srgb, var(--card-2) 84%, black 16%);
  white-space: pre-line;
}
.profile-minimal-head {
  border: 1px solid color-mix(in srgb, var(--line) 42%, transparent);
  border-radius: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--card-2) 92%, black 8%);
}
.profile-subline {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.profile-sections {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.profile-section {
  border: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card-2) 94%, black 6%);
  overflow: hidden;
}
.profile-section summary {
  list-style: none;
  cursor: pointer;
  padding: 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  border-bottom: 1px solid transparent;
}
.profile-section summary::-webkit-details-marker {
  display: none;
}
.profile-section[open] summary {
  border-bottom-color: color-mix(in srgb, var(--line) 34%, transparent);
}
.mini-list {
  display: grid;
  gap: 6px;
  padding: 10px 12px 12px;
}
.mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--card-2) 98%, black 2%);
  border: 1px solid color-mix(in srgb, var(--line) 24%, transparent);
}
.mini-row b {
  color: var(--text);
  font-weight: 800;
  text-align: right;
  word-break: break-word;
}
.profile-hero {
  border: 1px solid color-mix(in srgb, var(--line) 58%, transparent);
  border-radius: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--card-2) 88%, black 12%);
}
.profile-name {
  font-size: clamp(20px, 4.2vw, 26px);
  font-weight: 800;
  letter-spacing: 0.1px;
  color: var(--text);
  text-shadow: none;
}
.profile-kpis {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.profile-kpi {
  border: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  border-radius: 10px;
  padding: 9px 10px;
  background: color-mix(in srgb, var(--card-2) 90%, black 10%);
}
.kpi-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.kpi-value {
  display: block;
  margin-top: 3px;
  font-size: 21px;
  line-height: 1.05;
  font-weight: 800;
  color: var(--text);
}
.profile-summary {
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  border-radius: 10px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  background: color-mix(in srgb, var(--card-2) 90%, black 10%);
  color: var(--text);
}
.profile-summary span {
  font-size: 13px;
}
.profile-games-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.profile-game-card {
  border: 1px solid color-mix(in srgb, var(--line) 48%, transparent);
  border-radius: 10px;
  padding: 10px;
  background: color-mix(in srgb, var(--card-2) 90%, black 10%);
}
.game-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.game-stats-list {
  display: grid;
  gap: 5px;
}
.game-stat-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 8px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--card-2) 94%, black 6%);
  border: 1px solid color-mix(in srgb, var(--line) 28%, transparent);
  font-size: 12px;
  color: var(--muted);
}
.game-stat-line b {
  font-size: 13px;
  color: var(--text);
}
.profile-hidden-field {
  margin-top: 8px;
  border: 1px dashed color-mix(in srgb, var(--line) 58%, transparent);
  border-radius: 10px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--card-2) 94%, black 6%);
}
.profile-hidden-field summary {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.profile-hidden-field summary::-webkit-details-marker {
  display: none;
}
.profile-hidden-field .hidden-value {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}
.games-hero {
  border: 1px solid #334872;
  border-radius: 16px;
  padding: 12px;
  background:
    radial-gradient(160px 80px at 90% 10%, rgba(90, 167, 255, 0.28), transparent 70%),
    linear-gradient(160deg, #172646, #101a31);
}
.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.hero-pill {
  border: 1px solid #4f6fb0;
  background: rgba(14, 29, 57, 0.9);
  color: #b8cbff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
}
.game-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.game-card {
  border: 1px solid #31466f;
  border-radius: 14px;
  background: linear-gradient(160deg, #17233f, #111a31);
  padding: 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.game-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.32);
  border-color: #4a6ca9;
}
.game-card.active {
  border-color: #ffd166;
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.24), 0 14px 28px rgba(0, 0, 0, 0.35);
  background:
    radial-gradient(120px 50px at 10% 0%, rgba(255, 209, 102, 0.14), transparent 70%),
    linear-gradient(160deg, #1b2a49, #121c35);
}
.game-card-icon {
  font-size: 20px;
  line-height: 1;
}
.game-card-title {
  font-size: 14px;
  font-weight: 700;
}
.game-card-sub {
  font-size: 12px;
  color: var(--muted);
}

#gamesPanel.games-panel {
  position: relative;
  overflow: hidden;
  border-color: var(--line);
  background:
    radial-gradient(800px 380px at 100% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 60%),
    radial-gradient(900px 520px at 0% 100%, color-mix(in srgb, var(--accent-2) 26%, transparent), transparent 60%),
    linear-gradient(165deg, var(--bg-1) 0%, var(--bg-2) 46%, var(--bg-3) 100%);
}
.games-shell {
  position: relative;
  z-index: 2;
  max-width: 460px;
  margin: 0 auto;
  padding-top: 2px;
}
.games-glass {
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 70%, transparent);
  backdrop-filter: blur(4px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 22px 36px rgba(68, 0, 64, 0.42);
}
#gamesPanel h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(34px, 7.2vw, 52px);
  line-height: 1;
  letter-spacing: 0.4px;
  color: color-mix(in srgb, var(--accent) 70%, white 30%);
  text-shadow:
    0 2px 0 rgba(2, 14, 41, 0.9),
    0 0 20px rgba(110, 255, 254, 0.75);
}
#gamesPanel #userHint {
  margin: 10px 0 2px;
  text-align: center;
  color: var(--muted);
}
#gamesPanel .subtitle {
  margin: 0 0 10px;
  text-align: center;
  color: var(--muted);
}
#gamesPanel .game-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}
#gamesPanel .game-card {
  min-height: 68px;
  border-radius: 12px;
  border-color: var(--line);
  background: linear-gradient(145deg, color-mix(in srgb, var(--card) 75%, var(--accent) 25%), color-mix(in srgb, var(--card-2) 80%, black 20%));
}
#gamesPanel .game-card.active {
  border-color: var(--warn);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 35%, transparent), 0 10px 20px rgba(44, 0, 56, 0.3);
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 68%, white 32%), color-mix(in srgb, var(--accent-2) 72%, black 28%));
}
#gamesPanel .game-card-title { color: var(--text); }
#gamesPanel .game-card-sub { color: var(--muted); }
#gamesPanel .mode-grid {
  margin: 10px 0 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#gamesPanel .mode-only-grid {
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: 440px;
  margin: 12px auto 6px;
}
#gamesPanel .mode-only-grid .mode-btn {
  font-size: clamp(18px, 3.1vw, 24px);
  line-height: 1.2;
  white-space: normal;
  word-break: keep-all;
  text-align: center;
  min-height: 74px;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#gamesPanel .mode-btn {
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
  padding: 14px 18px;
  color: var(--text);
  text-shadow: 0 2px 0 rgba(9, 32, 63, 0.95);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44) 0%, rgba(255, 255, 255, 0.05) 22%, rgba(255, 255, 255, 0) 24%),
    linear-gradient(170deg, var(--accent), var(--accent-2) 52%, color-mix(in srgb, var(--accent-2) 70%, black 30%));
  box-shadow: 0 10px 0 rgba(10, 82, 138, 0.72), 0 20px 30px rgba(0, 0, 0, 0.33);
}
#gamesPanel .mode-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 0 rgba(10, 82, 138, 0.72), 0 22px 32px rgba(0, 0, 0, 0.34);
}
#gamesPanel .mode-btn:active {
  transform: translateY(3px);
  box-shadow: 0 6px 0 rgba(10, 82, 138, 0.72), 0 14px 22px rgba(0, 0, 0, 0.31);
}
#gamesPanel #modeHintText {
  margin: 6px 0 2px;
  text-align: center;
  color: var(--muted);
}
#gamesPanel .join-block {
  margin-top: 10px;
}
#gamesPanel #joinModeSelect,
#gamesPanel #stakeInput,
#gamesPanel #roomCodeInput {
  border-radius: 14px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--card-2) 78%, black 22%);
  color: var(--text);
}
#gamesPanel .create-main-btn {
  border-radius: 999px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.4px;
  border: 1px solid var(--line);
  color: var(--text);
  text-shadow: 0 2px 0 rgba(8, 42, 50, 0.95);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.08) 24%, rgba(255, 255, 255, 0) 26%),
    linear-gradient(145deg, var(--accent), var(--accent-2) 70%, color-mix(in srgb, var(--accent-2) 70%, black 30%));
  box-shadow: 0 10px 0 rgba(12, 124, 128, 0.76), 0 20px 32px rgba(0, 0, 0, 0.36);
}
#gamesPanel #openRoomsBox {
  border-color: var(--line);
  background: color-mix(in srgb, var(--card-2) 84%, black 16%);
}
#gamesPanel #errorText {
  text-align: center;
  color: var(--warn);
  margin: 10px 0 2px;
}

.players { margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player { border: 1px solid var(--line); border-radius: 12px; padding: 9px; background: #0c1224; }
.player.active { border-color: rgba(57, 225, 168, 0.8); box-shadow: 0 0 14px rgba(57, 225, 168, 0.35); }

.board {
  width: 100%;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#tttBoard { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#tttBoard .cell { font-size: clamp(34px, 7vw, 56px); }
#minesGrid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  max-width: 100%;
}

.cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  font-size: clamp(13px, 2.2vw, 20px);
  font-weight: 700;
  border: 1px solid #3a4770;
  border-radius: 10px;
  color: var(--text);
  background: linear-gradient(180deg, #1d2b4a, #15203b);
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.18s ease;
}
.cell:hover:enabled { transform: scale(1.03); filter: brightness(1.1); }
.cell.win { border-color: var(--accent); box-shadow: 0 0 16px rgba(57, 225, 168, 0.45); }

.cell.mines-closed { background: linear-gradient(180deg, #31507b, #233b5c); }
.cell.mines-flag { background: linear-gradient(180deg, #7f3650, #552134); }
.cell.mines-open { background: linear-gradient(180deg, #e9efff, #c8d5f8); color: #102444; border-color: #8ca2d8; }
.cell.mines-mine { background: linear-gradient(180deg, #963e5a, #5d2638); }
.cell.num-1 { color: #2b66ff; }
.cell.num-2 { color: #0b8a5f; }
.cell.num-3 { color: #b82f45; }
.cell.num-4 { color: #5d42bf; }
.cell.num-5 { color: #85500d; }
.cell.num-6 { color: #0d7e85; }
.cell.num-7 { color: #1f273a; }
.cell.num-8 { color: #484848; }

.bottom-actions { margin-top: 10px; display: flex; gap: 8px; }
.rps-panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.chess-board {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
  background: #121a30;
  border: 1px solid #34456d;
  border-radius: 10px;
  padding: 4px;
}
.chess-cell {
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 6px;
  font-size: clamp(20px, 4.8vw, 34px);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-image 0.25s ease, transform 0.15s ease;
}
.chess-cell:hover { transform: scale(1.02); }
.chess-piece-anim {
  animation: piecePop 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes piecePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.chess-light { background: #e4ebff; color: #111a34; }
.chess-dark { background: #7b8fbf; color: #0b1230; }
.chess-cell.sel { outline: 3px solid #ffd166; }
.chess-cell.last { box-shadow: inset 0 0 0 3px rgba(57, 225, 168, 0.6); }
.chess-cell.can-source {
  box-shadow: inset 0 0 0 2px rgba(255, 209, 102, 0.45);
}
.chess-cell.can-move {
  background: linear-gradient(170deg, #ffe27d, #f4c84f);
  color: #111a34;
  box-shadow: inset 0 0 0 2px rgba(255, 241, 197, 0.9);
}
.chess-piece-img {
  width: 55%;
  height: 55%;
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}
.uno-board {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}
body.uno-mode #gameRoomPanel {
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(255, 255, 255, 0.08), transparent 65%),
    linear-gradient(180deg, #0a172d, #071325);
  border-color: #35507e;
}
.uno-headline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.uno-headline .status {
  margin: 0;
}
.uno-headline .hint {
  margin: 0;
}
.uno-opponent {
  border: 1px solid rgba(151, 181, 240, 0.35);
  border-radius: 12px;
  padding: 8px;
  background: rgba(19, 33, 62, 0.72);
}
.uno-opponent-cards {
  margin-top: 6px;
  position: relative;
  min-height: 66px;
  overflow: hidden;
}
.uno-center {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
}
.uno-pile-btn {
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: #ffffff;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  place-items: center;
  gap: 6px;
  color: #1f2f54;
}
.uno-pile-btn span {
  color: #1f2f54;
  font-weight: 700;
}
.uno-discard-box {
  border: 1px solid rgba(151, 181, 240, 0.45);
  border-radius: 12px;
  padding: 8px;
  background: rgba(18, 31, 59, 0.86);
  display: grid;
  place-items: center;
  gap: 6px;
}
.uno-discard-box small {
  color: #c4d4f5;
}
.uno-wild-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.uno-color-btn {
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  padding: 10px 8px;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.uno-color-btn.red { background: linear-gradient(180deg, #f95656, #cf2323); }
.uno-color-btn.blue { background: linear-gradient(180deg, #4393ff, #1f5fd6); }
.uno-color-btn.green { background: linear-gradient(180deg, #3ed47a, #1d9f4f); }
.uno-color-btn.yellow { background: linear-gradient(180deg, #f7db58, #d0ac1f); color: #292200; }
.uno-color-btn:hover { filter: brightness(1.06); }
.uno-color-btn:active { transform: translateY(1px); }
.uno-hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.uno-card-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  animation: unoCardIn 220ms ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.uno-card-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.uno-card {
  width: 78px;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.uno-card.back {
  width: 42px;
  border-radius: 6px;
  position: absolute;
  left: calc(var(--i, 0) * 16px);
  top: 4px;
  transform: rotate(calc((var(--i, 0) - 3) * 2deg));
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.28);
}
.uno-opponent-more {
  position: absolute;
  left: 118px;
  top: 20px;
  font-size: 13px;
  font-weight: 800;
  color: #d7e4ff;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(170, 197, 255, 0.55);
  background: rgba(31, 52, 90, 0.92);
}
.uno-card.top-card {
  width: 90px;
}
.uno-card.pile-card {
  width: 90px;
}
.uno-card-btn:hover .uno-card {
  transform: translateY(-4px) scale(1.03);
  transition: transform 0.14s ease, box-shadow 0.18s ease;
  box-shadow: 0 14px 20px rgba(0, 0, 0, 0.35);
}
.uno-card-btn:active .uno-card {
  transform: translateY(-1px) scale(1.01);
}
.top-card-pop {
  animation: topCardPop 260ms ease;
}
@keyframes unoCardIn {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes topCardPop {
  0% { transform: scale(0.9) rotate(-2deg); }
  65% { transform: scale(1.06) rotate(1deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.hidden { display: none !important; }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti { position: absolute; top: -20px; width: 8px; height: 16px; border-radius: 2px; opacity: 0.9; animation: fall 1300ms linear forwards; }

@keyframes panelIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0; } }
@keyframes float { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-18px);} }

@media (max-width: 420px) {
  .app { max-width: 100%; padding: 10px 8px 20px; }
  .panel { padding: 12px; border-radius: 16px; }
  .join-block { flex-direction: column; }
  .cell { font-size: clamp(12px, 3.5vw, 17px); }
  .game-cards { grid-template-columns: 1fr; }
  #gamesPanel .mode-grid { grid-template-columns: 1fr; }
  #gamesPanel .mode-btn { font-size: 18px; padding: 12px 10px; }
  #gamesPanel .mode-only-grid .mode-btn { min-height: 70px; }
  #gamesPanel .create-main-btn { font-size: 22px; }
  .theme-list { grid-template-columns: 1fr; }
  .theme-fab { min-width: 92px; padding: 8px 12px; }
  .profile-kpis,
  .profile-summary,
  .profile-games-grid {
    grid-template-columns: 1fr;
  }
  .profile-name {
    font-size: clamp(20px, 7vw, 28px);
  }
  .kpi-value {
    font-size: 20px;
  }
}

body.theme-midnight_cyan {
  --bg-1: #071326; --bg-2: #0d2e4d; --bg-3: #10192f;
  --card: #12253d; --card-2: #102036; --line: #6fd6ff;
  --text: #e9f8ff; --muted: #b3dcf5; --accent: #2ef1df; --accent-2: #52b8ff;
}
body.theme-sunset_glass {
  --bg-1: #ff5c77; --bg-2: #ff7e5f; --bg-3: #b64a88;
  --card: #682d5f; --card-2: #51244b; --line: #ffc3d0;
  --text: #fff2f5; --muted: #ffd8e6; --accent: #ffd56f; --accent-2: #ff8cb3;
}
body.theme-emerald_night {
  --bg-1: #0d2a22; --bg-2: #145947; --bg-3: #15272f;
  --card: #1f3e38; --card-2: #1a322d; --line: #85ffd7;
  --text: #eafff7; --muted: #bdf3df; --accent: #6df7bd; --accent-2: #46d8a5;
}
body.theme-ruby_arcade {
  --bg-1: #690a21; --bg-2: #9f1638; --bg-3: #3f1028;
  --card: #5a1731; --card-2: #431125; --line: #ff8db1;
  --text: #fff0f4; --muted: #ffd0de; --accent: #ff6d9f; --accent-2: #ff9a4b;
}
body.theme-ice_luxe {
  --bg-1: #8dd9ff; --bg-2: #66b8ff; --bg-3: #2a4c7a;
  --card: #375b8d; --card-2: #2e4d79; --line: #d7efff;
  --text: #f4fbff; --muted: #d4e8ff; --accent: #84ffe6; --accent-2: #8cc8ff;
}
body.theme-carbon_gold {
  --bg-1: #151515; --bg-2: #252525; --bg-3: #0f0f0f;
  --card: #2a2a2a; --card-2: #1f1f1f; --line: #f2ce6a;
  --text: #fff7df; --muted: #e9d8a8; --accent: #f3cf6f; --accent-2: #c6a44e;
}
body.theme-violet_wave {
  --bg-1: #5828c8; --bg-2: #8f35e7; --bg-3: #2f1768;
  --card: #442689; --card-2: #341d69; --line: #cfb1ff;
  --text: #f7f0ff; --muted: #ddcbff; --accent: #83e6ff; --accent-2: #b990ff;
}
body.theme-cyberpunk_flux {
  --bg-1: #0b0418; --bg-2: #1f0b3f; --bg-3: #090014;
  --card: #240f43; --card-2: #1a0a31; --line: #ff47c7;
  --text: #ffeaff; --muted: #f4b8ff; --accent: #2bf7ff; --accent-2: #ff4fd8;
}
body.theme-retro_synth {
  --bg-1: #180532; --bg-2: #40107a; --bg-3: #14042b;
  --card: #32115f; --card-2: #230d45; --line: #ff9f5f;
  --text: #fff0df; --muted: #ffd8b6; --accent: #ff8a66; --accent-2: #ffd166;
}
body.theme-pastel_candy {
  --bg-1: #ff9ec4; --bg-2: #ffb3d9; --bg-3: #c276d8;
  --card: #9f60bf; --card-2: #8b52ab; --line: #ffe5f4;
  --text: #fff7fb; --muted: #ffe9f6; --accent: #8effd0; --accent-2: #7bd3ff;
}
body.theme-mono_steel {
  --bg-1: #1a1d24; --bg-2: #2d3442; --bg-3: #141820;
  --card: #2a3140; --card-2: #212838; --line: #b7c0d2;
  --text: #f2f5fb; --muted: #d2d9e6; --accent: #a9c7ff; --accent-2: #8fa8d8;
}
body.theme-lava_core {
  --bg-1: #3d0f07; --bg-2: #7a1e0d; --bg-3: #220a06;
  --card: #5a1d14; --card-2: #42140e; --line: #ff9d68;
  --text: #fff2e7; --muted: #ffd6be; --accent: #ff8b4d; --accent-2: #ffd166;
}
body.theme-ocean_deep {
  --bg-1: #031f3a; --bg-2: #0a4377; --bg-3: #02152a;
  --card: #123d68; --card-2: #0f3154; --line: #8fd6ff;
  --text: #e9f7ff; --muted: #c1e9ff; --accent: #4ee2ff; --accent-2: #7bc9ff;
}
body.theme-forest_mint {
  --bg-1: #0d2818; --bg-2: #1f5935; --bg-3: #0a1b12;
  --card: #1f4930; --card-2: #183a27; --line: #9cf7c6;
  --text: #edfff5; --muted: #c9f4de; --accent: #6ff3b3; --accent-2: #7ce8d0;
}
body.theme-royal_amethyst {
  --bg-1: #271145; --bg-2: #4a1f7f; --bg-3: #1a0b31;
  --card: #3f1d69; --card-2: #2f164f; --line: #d6b0ff;
  --text: #f7eeff; --muted: #e3d2ff; --accent: #b084ff; --accent-2: #8de7ff;
}
body.theme-dark_mode {
  --bg-1: #06080d; --bg-2: #0b1019; --bg-3: #04060a;
  --card: #121825; --card-2: #0d131e; --line: #2a3447;
  --text: #edf2fc; --muted: #9aa8be; --accent: #51627e; --accent-2: #3e4b62;
  --warn: #ffd978; --danger: #ff8f8f;
}
body.theme-dark_mode {
  background:
    radial-gradient(900px 480px at 8% 0%, rgba(105, 120, 145, 0.08), transparent 60%),
    radial-gradient(900px 540px at 100% 100%, rgba(70, 82, 104, 0.1), transparent 60%),
    linear-gradient(165deg, #06080d, #0b1019 52%, #04060a);
}
body.theme-dark_mode .bg-orb {
  opacity: 0.09;
  filter: blur(62px);
}
body.theme-dark_mode .orb-a,
body.theme-dark_mode .orb-b,
body.theme-dark_mode .orb-c {
  background: #4b5568;
}
body.theme-dark_mode .panel,
body.theme-dark_mode .games-glass,
body.theme-dark_mode .theme-drawer {
  background: linear-gradient(160deg, #121825, #0d131e);
  border-color: #2a3447;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.48);
}
body.theme-dark_mode #gamesPanel.games-panel {
  background:
    radial-gradient(900px 480px at 100% 0%, rgba(96, 114, 141, 0.08), transparent 62%),
    radial-gradient(900px 520px at 0% 100%, rgba(84, 96, 120, 0.08), transparent 64%),
    linear-gradient(165deg, #06080d 0%, #0b1019 52%, #04060a 100%);
}
body.theme-dark_mode .btn,
body.theme-dark_mode .big-btn,
body.theme-dark_mode .mode-btn,
body.theme-dark_mode .theme-fab,
body.theme-dark_mode .theme-chip {
  background: linear-gradient(170deg, #2a3447, #1e2738 62%, #161d2c);
  border-color: #3c4b65;
  color: #edf2fc;
  text-shadow: none;
  box-shadow: 0 7px 0 #151b28, 0 14px 22px rgba(0, 0, 0, 0.4);
}
body.theme-dark_mode .btn.primary,
body.theme-dark_mode .big-btn.primary {
  background: linear-gradient(160deg, #3a4862, #27344c 70%, #1b2537);
  border-color: #556886;
  box-shadow: 0 7px 0 #161f2f, 0 16px 24px rgba(0, 0, 0, 0.44);
}
body.theme-dark_mode .game-card,
body.theme-dark_mode #gamesPanel .game-card,
body.theme-dark_mode .profile-box,
body.theme-dark_mode input,
body.theme-dark_mode select {
  background: #0f1521;
  border-color: #2f3a50;
  color: #edf2fc;
}
body.theme-dark_mode .game-card.active,
body.theme-dark_mode #gamesPanel .game-card.active {
  border-color: #5f6f8d;
  box-shadow: 0 0 0 2px rgba(95, 111, 141, 0.24), 0 10px 20px rgba(0, 0, 0, 0.36);
}
body.theme-dark_mode #gamesPanel h2 {
  color: #edf2fc;
  text-shadow: none;
}
