/* ==================== ШРИФТЫ (локально) ==================== */
@font-face {
  font-family: 'Playfair';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/playfair-display-v40-cyrillic_latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Playfair';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('/fonts/playfair-display-v40-cyrillic_latin-900.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/montserrat-v31-cyrillic_latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/montserrat-v31-cyrillic_latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/montserrat-v31-cyrillic_latin-700.woff2') format('woff2');
}

/* ==================== ТЕМЫ ==================== */
:root {
  --bg: #0d3b2e;
  --felt: #0b3d2e;
  --felt-light: #16543f;
  --felt-dark: #041a13;
  --wood: #4a2c1a;
  --wood-light: #6b4423;
  --wood-dark: #2a1810;
  --acc: #f1c40f;
  --text: #fff;
  --scale: 1;
  --font-title: 'Playfair', Georgia, serif;
  --font-body: 'Montserrat', system-ui, -apple-system, sans-serif;
}

[data-theme="classic"] {
  --bg: #0d3b2e;
  --felt: #0b3d2e;
  --felt-light: #16543f;
  --felt-dark: #041a13;
  --wood: #4a2c1a;
  --wood-light: #6b4423;
  --wood-dark: #2a1810;
  --acc: #f1c40f;
  --text: #fff;
}
[data-theme="dark"] {
  --bg: #0a0e13;
  --felt: #0d1b2a;
  --felt-light: #182a44;
  --felt-dark: #050a14;
  --wood: #1a1a1a;
  --wood-light: #333333;
  --wood-dark: #000000;
  --acc: #ffb84d;
  --text: #e6e6e6;
}
[data-theme="neon"] {
  --bg: #05001a;
  --felt: #08001a;
  --felt-light: #140030;
  --felt-dark: #000000;
  --wood: #1a0d2e;
  --wood-light: #2d1858;
  --wood-dark: #050015;
  --acc: #00e5ff;
  --text: #fff;
}
[data-theme="paper"] {
  --bg: #f4ecd8;
  --felt: #e8dcc0;
  --felt-light: #f5e8d3;
  --felt-dark: #d4c4a0;
  --wood: #d4a574;
  --wood-light: #e6bd8a;
  --wood-dark: #8b6a3d;
  --acc: #b8860b;
  --text: #333;
}

[data-scale="small"]  { --scale: 0.85; }
[data-scale="medium"] { --scale: 1;    }
[data-scale="large"]  { --scale: 1.15; }

:root {
  --card-w-base: 64px;
  --card-h-base: 92px;
  --hand-h-base: 120px;
  --card-w: calc(var(--card-w-base) * var(--scale));
  --card-h: calc(var(--card-h-base) * var(--scale));
  --hand-h: calc(var(--hand-h-base) * var(--scale));
}

@media (orientation: landscape) and (max-height: 500px) {
  :root { --card-w-base: 44px; --card-h-base: 64px; --hand-h-base: 90px; }
}
@media (orientation: landscape) and (max-height: 400px) {
  :root { --card-w-base: 38px; --card-h-base: 56px; --hand-h-base: 76px; }
}
@media (orientation: landscape) and (max-height: 340px) {
  :root { --card-w-base: 34px; --card-h-base: 50px; --hand-h-base: 66px; }
}

/* ==================== ОБЩИЕ ==================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100dvh; display: flex; flex-direction: column; }

/* ==================== ЗАГОЛОВКИ (Playfair) ==================== */
h1, h2, h3, h4,
.splash-title,
.welcome-title,
.waiting-code,
.champ-title {
  font-family: var(--font-title);
  font-weight: 900;
  letter-spacing: 2px;
}

/* Кнопки — Montserrat SemiBold */
button, input, select, textarea {
  font-family: var(--font-body);
}

/* ==================== ПЛАВНЫЕ ПЕРЕХОДЫ ЭКРАНОВ ==================== */
#app { transition: opacity .15s ease-out; }
#app.fade-out { opacity: 0; }
#app.fade-in  { opacity: 0; transition: none; }

/* ==================== SPLASH (приветствие) ==================== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(ellipse at 50% 40%, #0f4d3a 0%, #061d14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .6s ease-out;
  pointer-events: none;
  overflow: hidden;
}
.splash.hide { opacity: 0; }

.splash-inner {
  text-align: center;
  position: relative;
  padding: 20px;
}

.splash-title {
  font-family: var(--font-title);
  font-size: 52px;
  font-weight: 900;
  color: #f1c40f;
  letter-spacing: 4px;
  text-shadow: 0 0 28px rgba(241,196,15,.55);
  opacity: 0;
  animation: titleIn .65s cubic-bezier(.22,.9,.35,1) 0ms forwards;
  will-change: transform, opacity, filter;
}
@keyframes titleIn {
  0%   { opacity: 0; transform: scale(.35); filter: blur(14px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

.splash-emojis {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  margin-bottom: 10px;
  height: 54px;
  align-items: center;
  position: relative;
}
.splash-emojis .se {
  font-size: 42px;
  line-height: 1;
  display: inline-block;
  opacity: 0;
  transform: translateY(-300px) rotate(-40deg) scale(.5);
  animation: emojiFall .68s cubic-bezier(.34,1.56,.64,1) forwards;
  animation-delay: calc(500ms + var(--i) * 110ms);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.55));
  will-change: transform, opacity;
}
@keyframes emojiFall {
  0%   { opacity: 0; transform: translateY(-300px) rotate(-40deg) scale(.5); }
  50%  { opacity: 1; }
  72%  { transform: translateY(8px) rotate(8deg) scale(1.18); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

.splash-sub {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: #9ac6b6;
  margin-top: 8px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0;
  animation: subIn .6s ease-out 1500ms forwards;
}
@keyframes subIn {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: .8; transform: translateY(0); }
}

/* ==================== ЛОББИ ==================== */
.lobby {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}
.lobby h2 { font-family: var(--font-title); margin: 0 0 8px; font-size: 28px; font-weight: 900; letter-spacing: 2px; }
.lobby label { font-size: 13px; opacity: .85; margin-bottom: -4px; margin-top: 6px; font-weight: 600; }
.lobby input, .lobby select, .lobby button {
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  font-family: var(--font-body);
}
.lobby input, .lobby select { background: rgba(255,255,255,.1); color: var(--text); }
[data-theme="paper"] .lobby input, [data-theme="paper"] .lobby select { background: rgba(0,0,0,.05); }
.lobby button { background: var(--acc); color: #000; font-weight: 700; cursor: pointer; }
.lobby button:active { transform: scale(.98); }

/* ==================== НОВОЕ ЛОББИ (welcome) ==================== */
.welcome-title {
  font-family: var(--font-title);
  text-align: center;
  font-size: 40px;
  margin: 40px 0 6px;
  font-weight: 900;
  letter-spacing: 3px;
}
.welcome-sub {
  font-family: var(--font-body);
  text-align: center;
  font-size: 12px;
  opacity: .6;
  margin-bottom: 32px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 500;
}
.welcome-btn {
  padding: 20px;
  font-size: 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-family: var(--font-body);
  transition: transform .12s;
  letter-spacing: .5px;
}
.welcome-btn:active { transform: scale(.97); }
.welcome-btn.primary {
  background: var(--acc);
  color: #000;
  box-shadow: 0 6px 24px rgba(241,196,15,.35);
}
.welcome-btn.secondary {
  background: #95a5a6;
  color: #000;
}
.welcome-footer {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 12px;
  opacity: .65;
}
.welcome-author { cursor: pointer; transition: opacity .15s; }
.welcome-author:active { opacity: 1; }
.welcome-author b { color: var(--acc); font-weight: 700; }

/* ==================== КНОПКИ ==================== */
.b1 { background: var(--acc); color: #000; }
.b2 { background: #95a5a6; color: #000; }
.b3 { background: #e74c3c; color: #fff; }
.b4 { background: #8e44ad; color: #fff; }
.b5 { background: #3498db; color: #fff; }

.err { color: #ffb84d; font-size: 13px; min-height: 18px; padding: 4px 0; }

/* ==================== ВЫБОР (колода, рубашка) ==================== */
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.choice {
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.25);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,.06);
}
.choice.sel { border-color: var(--acc); background: rgba(241,196,15,.2); }
.choice.preview-card { width: 64px; height: 92px; padding: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; }
.choice.preview-card img { width: 100%; height: 100%; object-fit: cover; }
.choice.back-swatch { width: 44px; height: 64px; padding: 0; overflow: hidden;
  border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.choice.back-swatch img { width: 100%; height: 100%; object-fit: cover; }

/* ==================== КНОПКИ-ИКОНКИ ЛОББИ ==================== */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: none;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(.95); }
.icon-btn.active { background: var(--acc); color: #000; }
[data-theme="paper"] .icon-btn { background: rgba(0,0,0,.08); }

/* ==================== ВЫБОР АВАТАРА ==================== */
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 4px;
  padding: 6px;
  background: rgba(255,255,255,.05);
  border-radius: 10px;
}
[data-theme="paper"] .avatar-picker { background: rgba(0,0,0,.04); }
.avatar-choice {
  font-size: 22px;
  text-align: center;
  padding: 6px 0;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  border: 2px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: transform .1s, background .1s, border-color .1s;
}
.avatar-choice:active { transform: scale(.9); }
.avatar-choice.sel {
  border-color: var(--acc);
  background: rgba(241,196,15,.2);
}

/* ==================== ВЫБОР ТЕМЫ СТОЛА ==================== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.theme-preview {
  cursor: pointer;
  border-radius: 10px;
  border: 2px solid transparent;
  padding: 6px 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  user-select: none;
}
.theme-preview:active { transform: scale(.95); }
.theme-preview.sel {
  border-color: var(--acc);
  box-shadow: 0 0 14px rgba(241,196,15,.55);
}
.theme-preview .tp-inner {
  width: 100%;
  height: 42px;
  border-radius: 6px;
  box-shadow: inset 0 0 14px rgba(0,0,0,.6);
  position: relative;
  overflow: hidden;
}
.theme-preview .tp-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.6),
    inset 0 0 0 3px rgba(255,255,255,.06);
}
.theme-preview .tp-label {
  font-size: 10px;
  font-weight: 600;
  opacity: .85;
  letter-spacing: .3px;
}
.theme-preview[data-theme-val="classic"] { background: #4a2c1a; }
.theme-preview[data-theme-val="classic"] .tp-inner {
  background: radial-gradient(circle at 50% 45%, #16543f 0%, #0b3d2e 55%, #041a13 100%);
}
.theme-preview[data-theme-val="dark"] { background: #1a1a1a; }
.theme-preview[data-theme-val="dark"] .tp-inner {
  background: radial-gradient(circle at 50% 45%, #182a44 0%, #0d1b2a 55%, #050a14 100%);
}
.theme-preview[data-theme-val="neon"] {
  background: #1a0d2e;
  box-shadow: 0 0 10px rgba(0,229,255,.35);
}
.theme-preview[data-theme-val="neon"].sel {
  box-shadow: 0 0 18px rgba(0,229,255,.7);
}
.theme-preview[data-theme-val="neon"] .tp-inner {
  background: radial-gradient(circle at 50% 45%, #140030 0%, #08001a 55%, #000 100%);
}
.theme-preview[data-theme-val="neon"] .tp-inner::after {
  box-shadow:
    inset 0 0 0 1px #ff0080,
    inset 0 0 0 3px #00e5ff,
    inset 0 0 14px rgba(0,229,255,.5);
}
.theme-preview[data-theme-val="paper"] { background: #d4a574; }
.theme-preview[data-theme-val="paper"] .tp-inner {
  background: radial-gradient(circle at 50% 45%, #f5e8d3 0%, #e8dcc0 55%, #d4c4a0 100%);
}
.theme-preview[data-theme-val="paper"] .tp-label { color: #333; }
[data-theme="dark"] .theme-preview .tp-label,
[data-theme="neon"] .theme-preview .tp-label,
[data-theme="classic"] .theme-preview .tp-label { color: #fff; }
[data-theme="paper"] .theme-preview .tp-label { color: #333; }

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

/* ==================== МОДАЛКА «О РАЗРАБОТЧИКЕ» ==================== */
.about-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: 14px;
}
[data-theme="paper"] .about-row { border-color: rgba(0,0,0,.1); }
.about-row b { color: var(--acc); }
.simple-modal-close-btn {
  margin-top: 16px;
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: var(--acc);
  color: #000;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}