/* =============================================================
   base.css — CSS-переменные, сброс, типографика, фон, экраны
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@400;600;700;900&family=Nunito:wght@400;600;700&display=swap');

:root {
  --bg:     #0d0d1a;
  --card:   #13132a;
  --card2:  #1a1a38;
  --accent: #e94560;
  --accent2:#ff6b6b;
  --blue:   #4a90e2;
  --gold:   #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --green:  #2ecc71;
  --text:   #ffffff;
  --text2:  #a0a0c0;
  --border: rgba(255,255,255,0.08);
  --glow:   0 0 20px rgba(233,69,96,0.4);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  user-select: none;
}

/* ===== BACKGROUND ===== */
.bg-stars {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(74,144,226,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(233,69,96,0.08) 0%, transparent 50%);
}
.bg-stars::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 45%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 20%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 65%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 30%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 80%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 90%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 10%, rgba(255,255,255,0.3) 0%, transparent 100%);
}

/* ===== SCREENS ===== */
.screen {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto; overflow-x: hidden;
  padding: 16px 16px 130px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.screen.active { opacity: 1; pointer-events: all; }

/* ===== LOGO ===== */
.logo {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(28px, 8vw, 52px);
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 60%, #ff9a9e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(233,69,96,0.5));
  margin-bottom: 4px;
  text-align: center;
}
.logo-sub {
  font-size: 12px; color: var(--text2);
  letter-spacing: 0.1em; text-transform: uppercase;
  text-align: center; margin-bottom: 32px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  width: 100%; max-width: 480px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text2);
  margin-bottom: 12px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 0 12px;
  backdrop-filter: blur(20px);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; padding: 4px 12px; border-radius: 10px;
  transition: all 0.2s; color: var(--text2); font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; }

/* ===== AD BANNER =====
   Баннер над навбаром. Высота навбара задаётся JS через --nav-height.
   Fallback: 60px.
*/
.ad-banner {
  position: fixed;
  bottom: var(--nav-height, 60px);
  left: 0; right: 0;
  height: 48px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text2); letter-spacing: 0.05em;
  z-index: 99; /* между контентом и навбаром */
}

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; pointer-events: none;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 20px;
  font-size: 14px; font-weight: 700; white-space: nowrap;
  opacity: 0; transition: all 0.3s ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--accent); color: var(--accent); }
.toast.bonus   { border-color: var(--gold); color: var(--gold); background: rgba(255,215,0,0.1); }

/* ===== WORD FLASH ===== */
.word-flash {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 150; pointer-events: none;
  font-family: 'Unbounded', sans-serif; font-size: clamp(24px, 8vw, 40px); font-weight: 900;
  color: var(--gold); text-shadow: 0 0 30px var(--gold);
  opacity: 0; animation: none;
}
.word-flash.flash { animation: word-flash 1s ease forwards; }
@keyframes word-flash {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}

/* ===== STREAK BADGE ===== */
.streak-badge {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  background: linear-gradient(135deg, rgba(255,165,0,0.2), rgba(255,69,0,0.2));
  border: 1px solid rgba(255,165,0,0.4);
  border-radius: 20px; padding: 6px 12px;
  font-size: 13px; font-weight: 700; color: #ffa500;
  pointer-events: none; opacity: 0; transition: all 0.3s;
}
.streak-badge.visible { opacity: 1; }

/* ===== LOADING ===== */
.loading-screen {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.5s ease;
}
.loading-logo {
  font-family: 'Unbounded', sans-serif; font-size: 36px; font-weight: 900; margin-bottom: 24px;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.loading-bar-wrap { width: 200px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.loading-bar { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--blue)); transition: width 0.3s; }
.loading-msg { margin-top: 12px; font-size: 12px; color: var(--text2); letter-spacing: 0.05em; }

/* ===== CONNECTING OVERLAY ===== */
.connecting {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(13,13,26,0.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.connecting.show { opacity: 1; pointer-events: all; }
.spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== ROUND TRANSITION ===== */
.round-transition {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.round-transition.show { opacity: 1; pointer-events: all; }
.new-word-reveal {
  text-align: center;
  animation: reveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes reveal { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
.new-word-reveal .word-big {
  font-family: 'Unbounded', sans-serif; font-size: clamp(28px, 10vw, 52px); font-weight: 900;
  letter-spacing: 0.15em; color: var(--accent);
  filter: drop-shadow(0 0 20px rgba(233,69,96,0.6));
}
.new-word-reveal .new-label { font-size: 12px; color: var(--text2); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 12px; }

/* ===== CUSTOM CONFIRM MODAL ===== */
.confirm-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.85);
  align-items: center; justify-content: center;
}
.confirm-modal-overlay.show { display: flex; }
.confirm-modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px 24px;
  width: 90%; max-width: 340px; text-align: center;
}
.confirm-modal h3 {
  font-family: 'Unbounded', sans-serif; font-size: 18px; margin-bottom: 10px; color: var(--accent);
}
.confirm-modal p { font-size: 13px; color: var(--text2); margin-bottom: 24px; line-height: 1.6; }
.confirm-modal-btns { display: flex; gap: 12px; }
.confirm-modal-btns button { flex: 1; padding: 12px; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer; border: none; transition: all 0.2s; }
.confirm-btn-ok     { background: linear-gradient(135deg, var(--accent), #c0392b); color: #fff; }
.confirm-btn-cancel { background: transparent; border: 1px solid var(--border) !important; color: var(--text2); }

/* ===== SIDEBAR AD (только на широких экранах) =====
   Показывается справа от игровой зоны (max-width: 480px)
   когда viewport шире 780px — то есть есть реальное свободное место.
   ===================================================== */
.sidebar-ad {
  display: none; /* скрыт по умолчанию */
}

@media (min-width: 780px) {
  .sidebar-ad {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;

    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    /* Правый край = центр экрана + половина игровой зоны + отступ */
    left: calc(50% + 256px);
    width: 160px;
    z-index: 10;
  }

  /* Если экран очень широкий — увеличиваем блок */
  @media (min-width: 1100px) {
    .sidebar-ad {
      left: calc(50% + 260px);
      width: 200px;
    }
  }
}

.sidebar-ad-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2);
  opacity: 0.5;
}

.sidebar-ad-block {
  width: 100%;
  min-height: 300px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
}

.sidebar-ad-block-icon {
  font-size: 28px;
  opacity: 0.4;
}

.sidebar-ad-block-text {
  font-size: 11px;
  color: var(--text2);
  opacity: 0.5;
  line-height: 1.5;
}


.word-info-btn {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(74,144,226,0.15);
  border: 1px solid rgba(74,144,226,0.4);
  color: var(--blue); font-size: 12px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; line-height: 1;
}
.word-info-btn:hover { background: rgba(74,144,226,0.3); transform: scale(1.1); }
.word-info-btn.loading { opacity: 0.5; cursor: default; animation: spin 0.8s linear infinite; }

/* ===== WORD DEFINITION MODAL ===== */
.word-def-modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(4px);
}
.word-def-modal.show { opacity: 1; pointer-events: all; }
.word-def-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  width: 100%; max-width: 400px;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 75vh; overflow-y: auto;
}
.word-def-modal.show .word-def-card { transform: scale(1); }
.word-def-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.word-def-pos {
  display: inline-block; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(74,144,226,0.15); color: var(--blue);
  padding: 2px 7px; border-radius: 6px; margin-bottom: 6px;
}
.word-def-meaning {
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.word-def-meaning:last-child { border-bottom: none; }
.word-def-syn { color: var(--text2); font-size: 12px; margin-top: 4px; }
.word-def-empty { color: var(--text2); font-size: 13px; padding: 8px 0; }
.word-def-key-hint {
  font-size: 10px; color: var(--text2); margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--border);
  text-align: center;
}


.toggle-switch { position: relative; display: inline-block; width: 48px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border); transition: 0.3s; border-radius: 34px;
}
.toggle-slider:before {
  position: absolute; content: "";
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: var(--text2); transition: 0.3s; border-radius: 50%;
}
input:checked + .toggle-slider { background-color: var(--accent); }
input:checked + .toggle-slider:before { transform: translateX(24px); background-color: white; }

/* ===== MUSIC BUTTON ===== */
.music-btn {
  position: fixed; top: 16px; left: 16px; z-index: 1000;
  width: 44px; height: 44px; border-radius: 30px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease; backdrop-filter: blur(10px); box-shadow: var(--shadow);
}
.music-btn:hover { border-color: var(--accent); transform: scale(1.1); box-shadow: var(--glow); }
.music-btn.off { opacity: 0.6; background: var(--card2); }
.music-btn.off::after {
  content: ''; position: absolute; width: 2px; height: 24px;
  background: var(--accent); transform: rotate(45deg); border-radius: 2px;
}

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  .music-btn { top: 12px; left: 12px; width: 40px; height: 40px; font-size: 20px; }
}
@media (max-width: 360px) {
  .room-btn { padding: 14px 16px; }
}
@media (max-height: 600px) {
  .found-words-wrap { max-height: 120px; }
  .big-word-wrap    { padding: 10px; }
  .input-area       { padding: 10px; }
}

#screen-home {
  justify-content: flex-start;
  padding-top: 20px;
  padding-bottom: 130px;
  overflow-y: auto;
}

.logo {
  margin-bottom: 4px;
  margin-top: 0;
}

.logo-sub {
  margin-bottom: 24px;
}

.card {
  margin-bottom: 16px;
}

.room-btn {
  margin-bottom: 12px;
}

.random-btn {
  margin-bottom: 20px;
}

/* Убираем лишние отступы у последних элементов */
#screen-home .card:last-child {
  margin-bottom: 0;
}