/* =========================================================
   ГЛОБАЛЬНЫЕ СТИЛИ
   ========================================================= */
body {
  background:
    linear-gradient(rgba(0,0,0,0.35), rgba(0,0,0,0.35)),
    url('img/arena.png') no-repeat center center fixed;
  background-size: cover;

  font-family: 'Segoe UI', sans-serif;
  color: #fff;
  text-align: center;
  margin: 0;
  padding: 0;
}


/* =========================================================
   АНИМАЦИИ
   ========================================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}


/* =========================================================
   АРЕНА БОЯ
   ========================================================= */
.arena {
  padding: 20px;
  animation: fadeIn 1s ease-in;
}


/* =========================================================
   ПОЛОСКИ ЗДОРОВЬЯ
   ========================================================= */
.hp-container {
  margin: 20px auto;
  width: 300px;
}

.hp-label {
  margin-top: 10px;
  font-weight: bold;
}

.hp-bar {
  width: 100%;
  height: 20px;
  background: #333;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #81C784);
  transition: width 0.5s ease;
}


/* =========================================================
   КАРТЫ
   ========================================================= */
.hand {
  margin-top: 30px;
}

.card {
  display: inline-block;
  width: 100px;
  height: 140px;
  margin: 10px;
  perspective: 600px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.card:hover .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.card-front {
  background: linear-gradient(135deg, #444, #666);
}

.card-back {
  background: linear-gradient(135deg, #b71c1c, #e53935);
  transform: rotateY(180deg);
}


/* =========================================================
   ЛОГ ХОДОВ
   ========================================================= */
.log {
  margin-top: 30px;
  font-size: 1.2em;
  animation: pulse 1s infinite alternate;
}


/* =========================================================
   СТАРТОВАЯ СТРАНИЦА
   ========================================================= */
.start-screen {
  background:
    linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)),
    url('img/start.png') no-repeat center center fixed;
  background-size: cover;

  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.menu {
  text-align: center;
  background: rgba(0,0,0,0.6);
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.title {
  font-size: 2.5em;
  margin-bottom: 30px;
  color: #fff;
  text-shadow: 0 0 10px #4CAF50;
}

.menu button {
  display: block;
  width: 240px;
  margin: 15px auto;
  padding: 14px 0;
  font-size: 1.2em;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.menu button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px #4CAF50;
}

/* ============================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ============================================================ */

/* Для планшетов и телефонов (ширина до 768px) */
@media (max-width: 768px) {
    body {
        padding: 10px;
        background-attachment: scroll;
    }

    /* Общие контейнеры */
    .menu, .container, .deckbuilder-container, .shop-container,
    .story-container, .profile-container, .hero-container,
    .rating-container, .dungeon-list, .dungeon-container {
        padding: 15px;
        margin: 0 auto;
        width: 100%;
        box-sizing: border-box;
    }

    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }

    /* Кнопки */
    .btn, .btn-action, .btn-buy, .back-btn, .nav-btn,
    .filter-btn, .choice-btn, .finish-btn, .battle-btn, .deck-btn,
    .btn-avatar, .expand-btn, .craft-btn {
        padding: 12px 18px;
        font-size: 16px;
        min-height: 44px;
        min-width: 44px;
        border-radius: 25px;
    }

    /* Главная страница */
    .hero-header h1 { font-size: 28px; }
    .user-panel { flex-wrap: wrap; justify-content: center; gap: 10px; }
    .user-avatar-big { width: 50px; height: 50px; }
    .nav-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .nav-card {
        padding: 15px 10px;
    }
    .nav-card .icon { font-size: 32px; }
    .nav-card .title { font-size: 16px; }
    .nav-card .desc { font-size: 12px; }

    /* Профиль */
    .inventory-layout {
        flex-direction: column;
    }
    .left-panel {
        flex: none;
        width: 100%;
    }
    .equip-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .bag-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    .top-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 10px 15px;
    }
    .top-bar .main-nav-btn {
        font-size: 13px;
        padding: 6px 12px;
    }
    .bottom-nav .nav-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    .user-info {
        flex-wrap: wrap;
        justify-content: center;
    }
    .mini-avatar { width: 36px; height: 36px; }
    .user-name { font-size: 16px; }
    .user-coins { font-size: 15px; padding: 4px 10px; }

    /* Магазин */
    .chest-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .avatar-chest-img { width: 80px; height: 80px; }
    .coins-display {
        font-size: 16px;
        padding: 6px 14px;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Коллекция */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .modal-content {
        grid-template-columns: 1fr;
        padding: 15px;
        max-height: 90vh;
    }
    .modal-image-wrap img { max-width: 200px; }
    .modal-details h2 { font-size: 22px; }
    .modal-stats { grid-template-columns: 1fr 1fr; }
    .modal-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
    .modal-nav-btn.prev { left: 0; }
    .modal-nav-btn.next { right: 0; }

    /* Истории */
    .story-container {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }
    .story-list {
        flex: none;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        max-height: 200px;
        overflow-y: auto;
        padding-right: 0;
        padding-bottom: 10px;
    }
    .story-content {
        padding: 10px 0;
        max-height: none;
    }
    .story-header-card h2 { font-size: 20px; }
    .story-header-card .story-desc { font-size: 14px; }
    .node-text {
        font-size: 16px;
        padding: 15px;
    }
    .choices .choice-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    .story-item {
        padding: 10px 12px;
    }
    .story-item .title { font-size: 13px; }

    /* Рейтинг подземелий */
    .rating-table th, .rating-table td {
        padding: 8px;
        font-size: 14px;
    }
    .rating-container h1 { font-size: 22px; }

    /* Список подземелий */
    .dungeon-card .title { font-size: 18px; }
    .dungeon-card .desc { font-size: 13px; }

    /* Другие элементы */
    .back-button {
        bottom: 15px;
        right: 15px;
        padding: 10px 18px;
        font-size: 14px;
    }
    .message-bar {
        font-size: 14px;
        padding: 10px 20px;
        max-width: 90%;
    }
    .filter-buttons {
        flex-wrap: wrap;
        gap: 4px;
    }
    .filter-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    .rarity-stats .rarity-pill {
        font-size: 11px;
        padding: 4px 10px;
    }
}

/* Для очень маленьких экранов (до 480px) */
@media (max-width: 480px) {
    .nav-grid {
        grid-template-columns: 1fr 1fr;
    }
    .deck-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .chest-grid {
        grid-template-columns: 1fr;
    }
    .bag-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .modal-stats {
        grid-template-columns: 1fr;
    }
    .hero-header h1 { font-size: 22px; }
    .equip-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .cards-grid {
        grid-template-columns: 1fr 1fr;
    }
    .dungeon-cards .dungeon-card {
        padding: 15px;
    }
}

/* ============================================================
   МОБИЛЬНЫЙ ЛОГ ДЛЯ BATTLE.PHP
   ============================================================ */

/* Кнопки лога скрыты на десктопе (ширина > 900px) */
@media (min-width: 901px) {
    .log-toggle-btn,
    .log-close-btn {
        display: none !important;
    }
}

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ДЛЯ BATTLE.PHP ===== */
@media (max-width: 900px) {
    body { padding: 4px; }
    .battle-screen {
        flex-direction: column;
        padding: 4px;
        height: 100vh;
        max-height: 100vh;
    }
    .battle-main {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .battle-scroll {
        flex: 1;
        overflow-y: auto;
        padding: 2px 4px;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    /* Лог (выезжающий) */
    .battle-log {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: 100% !important;
        z-index: 9998 !important;
        transition: top 0.3s ease !important;
        height: 70vh !important;
        background: rgba(10, 10, 20, 0.98) !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 20px 20px !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
        backdrop-filter: blur(10px) !important;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5) !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        flex: none !important;
        order: 0 !important;
        margin: 0 !important;
    }
    .battle-log.open { top: 30% !important; }
    .battle-log h3 { margin-top: 0 !important; padding-right: 40px !important; flex-shrink: 0 !important; }
    .battle-log .log-area { flex: 1 !important; overflow-y: auto !important; padding-bottom: 20px !important; }
    .battle-log .card-tooltip { display: none !important; }

    .log-toggle-btn {
    display: block !important;
    margin: 10px auto !important;
    width: fit-content !important;
    background: #3498db !important;
    border: none !important;
    color: #fff !important;
    padding: 14px 24px !important;
    border-radius: 50px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.5) !important;
    cursor: pointer !important;
    transition: 0.2s !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    pointer-events: auto !important;
}
    .log-close-btn {
        display: block !important;
        position: absolute !important;
        top: 12px !important;
        right: 15px !important;
        background: none !important;
        border: none !important;
        color: #fff !important;
        font-size: 28px !important;
        cursor: pointer !important;
        z-index: 10 !important;
        opacity: 0.8 !important;
        pointer-events: auto !important;
    }

    /* HP-бары (оба внутри потока) */
    .hp-container { padding: 2px 6px !important; gap: 6px !important; }
    .hp-container .hp-avatar { width: 28px !important; height: 28px !important; }
    .hp-container .hp-bar { height: 9px !important; }
    .hp-container .hp-label { font-size: 11px !important; }
    .hp-container .deck-count { font-size: 9px !important; }
    .hp-text { font-size: 9px !important; }
    .effect-icon { width: 16px !important; height: 16px !important; font-size: 10px !important; }

    /* Карты — увеличиваем до 54px */
    .hand { gap: 3px !important; padding: 2px 0 !important; }
    .hand .card {
        margin: 0 !important;
        width: 54px !important;
        height: 76px !important;
    }
    .card-front .card-name { font-size: 8px !important; padding: 2px 4px !important; }

    /* Центр боя */
    .battle-center { gap: 8px !important; padding: 2px 0 !important; }
    .center-card { min-width: 55px !important; padding: 4px 8px !important; font-size: 10px !important; }
    .center-card .center-name { font-size: 10px !important; }
    .status-msg { font-size: 12px !important; min-height: auto !important; padding: 2px 0 !important; }

    /* Конец боя */
    .game-over-container { padding: 12px 16px !important; min-width: auto !important; }
    .game-over-msg { font-size: 20px !important; }
    .btn { padding: 6px 14px !important; font-size: 11px !important; }
}

@media (min-width: 901px) {
    .log-toggle-btn, .log-close-btn { display: none !important; }
}

/* ===== Адаптация страниц входа/регистрации ===== */
@media (max-width: 768px) {
    .start-screen .menu {
        padding: 30px 20px;
        width: 95%;
        max-width: 400px;
        box-sizing: border-box;
    }
    .start-screen .menu .title {
        font-size: 28px;
        margin-bottom: 20px;
    }
    .start-screen .menu input[type="text"],
    .start-screen .menu input[type="password"] {
        display: block !important;
        margin: 12px auto !important;
        padding: 16px 18px !important;
        width: 90% !important;
        font-size: 18px !important;
        border-radius: 12px !important;
        border: 1px solid #555 !important;
        background: rgba(255,255,255,0.1) !important;
        color: #fff !important;
        box-sizing: border-box !important;
    }
    .start-screen .menu button {
        display: block !important;
        margin: 15px auto !important;
        padding: 16px 20px !important;
        width: 90% !important;
        font-size: 20px !important;
        border-radius: 30px !important;
        background: linear-gradient(135deg, #4CAF50, #2E7D32) !important;
        border: none !important;
        color: #fff !important;
        cursor: pointer !important;
        transition: 0.2s !important;
    }
    .start-screen .menu button:hover {
        transform: scale(1.02);
    }
    .start-screen .menu p {
        font-size: 16px;
        margin: 12px 0;
    }
    .start-screen .menu a {
        font-size: 16px;
        display: inline-block;
        padding: 8px 16px;
        color: #4CAF50;
        text-decoration: none;
    }
    .start-screen .menu a:hover {
        text-decoration: underline;
    }
}

/* Иконка монеты */
.coin-icon {
    height: 1.1em;
    width: auto;
    vertical-align: middle;
    margin: 0 2px;
    display: inline-block;
}
/* Выделение механик в описании карт */
.hl-provocation { color: #e74c3c; font-weight: bold; }   /* провокация — красный */
.hl-paralysis   { color: #f1c40f; font-weight: bold; }   /* паралич — жёлтый */
.hl-polymorph { color: #bb86fc; font-weight: bold; }
.hl-metamorph { color: #4dd0e1; font-weight: bold; }

/* ============================================================
   ССЫЛКА НА ВИЗИТКУ ИГРОКА (единый стиль)
============================================================ */
a.profile-link,
a.profile-link:link,
a.profile-link:visited,
a.profile-link:active,
a.profile-link:focus {
    color: inherit !important;
    text-decoration: none !important;
    transition: color 0.2s;
}

a.profile-link:hover {
    color: #f1c40f !important;
}
a.profile-link:hover .username,
a.profile-link:hover .rating-name {
    color: #f1c40f !important;
}

a.profile-link img {
    transition: border-color 0.2s, box-shadow 0.2s;
}
a.profile-link:hover img {
    border-color: #f1c40f !important;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.5);
}

/* Если вся строка — ссылка */
a.profile-row-link,
a.profile-row-link:link,
a.profile-row-link:visited,
a.profile-row-link:active,
a.profile-row-link:focus {
    color: inherit !important;
    text-decoration: none !important;
    display: flex;
    transition: background 0.2s, color 0.2s;
}

a.profile-row-link:hover {
    background: rgba(241, 196, 15, 0.06);
}
a.profile-row-link:hover .rating-name,
a.profile-row-link:hover .username {
    color: #f1c40f !important;
}
a.profile-row-link img {
    transition: border-color 0.2s, box-shadow 0.2s;
}
a.profile-row-link:hover img {
    border-color: #f1c40f !important;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.5);
}