/* ═══════════════════════════════════════
   HEXAGON — стили
   ═══════════════════════════════════════ */

/* ── Обёртка ── */
.ihx-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: #1a1a1a;
    border-radius: 24px;
    padding: 20px 18px 24px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    overflow: hidden;
}

/* ── Оверлеи ── */
.ihx-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}
.ihx-overlay.ihx-visible { display: flex; }

.ihx-modal {
    background: #242424;
    border-radius: 20px;
    padding: 28px 24px;
    width: 88%;
    max-width: 320px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}
.ihx-modal h2 {
    color: #fff;
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.ihx-modal input {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border-radius: 12px;
    border: 2px solid #3a3a3a;
    background: #1a1a1a;
    color: #fff;
    font-size: 15px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
}
.ihx-modal input:focus { border-color: #4f8aff; outline: none; }

.ihx-lb-modal { text-align: left; max-height: 75vh; overflow-y: auto; }
.ihx-lb-modal h3 { color: #fff; text-align: center; font-size: 20px; font-weight: 800; margin: 0 0 12px; }
.ihx-lb-modal ol { padding-left: 20px; color: #fff; margin: 0 0 16px; font-size: 14px; }
.ihx-lb-modal li { padding: 8px 0; border-bottom: 1px solid #333; display: flex; justify-content: space-between; }
.ihx-lb-modal li:last-child { border-bottom: none; }
.ihx-lb-modal li.ihg-current-player { color: #f4b24e; font-weight: 700; }

/* ── Кнопки ── */
.ihx-btn {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    font-family: inherit;
    box-sizing: border-box;
    text-align: center;
    transition: transform 0.1s, opacity 0.15s;
    line-height: 1.4;
}
.ihx-btn:active { transform: scale(0.96); }
.ihx-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ihx-btn-primary   { background: linear-gradient(90deg, #4c5fc5, #2c9782); box-shadow: 0 4px 14px rgba(44,151,130,0.3); }
.ihx-btn-secondary { background: #3a3a3a; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.ihx-btn-link {
    background: transparent; color: #888; box-shadow: none;
    font-size: 14px; padding: 8px 16px; font-weight: 600;
}
.ihx-btn-link:hover { color: #ccc; }

#ihx-auth-buttons { display: flex; flex-direction: column; gap: 10px; }
#ihx-auth-form    { display: none; flex-direction: column; gap: 0; }

/* ── Панель управления ── */
.ihx-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ihx-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ihx-label {
    color: #888;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* Сегментные переключатели */
.ihx-seg {
    display: flex;
    gap: 4px;
    background: #111;
    border-radius: 12px;
    padding: 4px;
}
.ihx-seg-btn {
    padding: 7px 14px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #888;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ihx-seg-btn.active {
    background: #2c2c2c;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.ihx-seg-btn:hover:not(.active) { color: #ccc; }

.ihx-new-btn {
    padding: 12px;
    border-radius: 14px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

/* ── Статус-бар ── */
.ihx-status {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #111;
    border-radius: 16px;
    padding: 10px 16px;
    box-sizing: border-box;
}
.ihx-player-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    transition: opacity 0.2s;
    opacity: 0.45;
}
.ihx-badge-right { flex-direction: row-reverse; justify-content: flex-start; }
.ihx-player-badge.ihx-active-badge { opacity: 1; }

.ihx-color-dot {
    width: 20px; height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.ihx-dot-black { background: #111; border: 2px solid #555; }
.ihx-dot-white { background: #f0f0f0; border: 2px solid #999; }

.ihx-badge-name {
    font-size: 13px;
    font-weight: 700;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}
.ihx-badge-wins {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
    min-width: 18px;
    text-align: center;
}

.ihx-turn-indicator {
    text-align: center;
    flex-shrink: 0;
}
#ihx-turn-text {
    font-size: 13px;
    font-weight: 700;
    color: #aaa;
    white-space: nowrap;
}

/* ── Игровое поле ── */
.ihx-board-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.ihx-svg {
    max-width: 100%;
    overflow: visible;
    display: block;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
}

/* Гексы */
.ihx-hex {
    cursor: pointer;
    transition: fill 0.12s ease;
}
.ihx-hex:hover { }

/* Анимация размещения */
.ihx-placed {
    animation: ihxPlace 0.35s ease-out;
}
@keyframes ihxPlace {
    0%   { transform: scale(0.6); opacity: 0.5; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Победная подсветка фишек */
.ihx-win-piece {
    animation: ihxWinPiece 0.7s ease-in-out infinite alternate;
}
@keyframes ihxWinPiece {
    0%   { filter: drop-shadow(0 0 2px rgba(241,196,15,0.4)); transform: scale(1); }
    100% { filter: drop-shadow(0 0 10px #f1c40f); transform: scale(1.12); }
}

/* ── Toast ── */
.ihx-toast {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -30%);
    background: #1e1e1e;
    color: #fff;
    padding: 16px 22px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 15px;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    text-align: center;
    line-height: 1.6;
    max-width: 85%;
    width: max-content;
    box-sizing: border-box;
    transition: opacity 0.3s cubic-bezier(0.175,0.885,0.32,1.275),
                transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
    border: 1px solid #333;
}
.ihx-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}
.ihx-toast-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 18px;
    background: linear-gradient(90deg, #4c5fc5, #2c9782);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

/* ── Легенда ── */
.ihx-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}
.ihx-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #888;
    font-size: 12px;
    font-weight: 600;
}

/* ── Fullscreen кнопка ── */
.ihx-fs-btn {
    position: absolute;
    top: 10px; right: 10px;
    width: 36px; height: 36px;
    border: none; background: transparent;
    cursor: pointer; z-index: 100; padding: 0;
    display: none;
    align-items: center; justify-content: center;
}
.ihx-fs-btn i { font-size: 20px; color: #555; transition: color 0.2s; }
.ihx-fs-btn:hover i { color: #aaa; }

@media (max-width: 768px) {
    .ihx-fs-btn { display: flex; }
}

/* ── Адаптивность ── */
@media (max-width: 480px) {
    .ihx-wrapper { padding: 14px 12px 18px; border-radius: 18px; gap: 10px; }
    .ihx-controls-row { gap: 7px; }
    .ihx-seg-btn { padding: 6px 10px; font-size: 12px; }
    .ihx-badge-name { max-width: 60px; font-size: 12px; }
}
@media (max-width: 360px) {
    .ihx-seg-btn { padding: 5px 8px; font-size: 11px; }
}

/* ── Полноэкранный режим ── */
.ihx-wrapper.ihx-fullscreen,
.ihx-wrapper:fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
    margin: 0 !important;
    padding: 16px !important;
    overflow-y: auto;
    justify-content: center;
}

/* ════════════════════════════════════════
   ОНЛАЙН-ЛОББИ
   ════════════════════════════════════════ */

.ihx-online-modal {
    max-width: 340px;
}
.ihx-online-modal h2 {
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.ihx-online-modal h2 i {
    color: #4f8aff;
}
.ihx-modal-hint {
    color: #888;
    font-size: 13px;
    margin: 0 0 6px;
    line-height: 1.5;
}

/* Код комнаты */
.ihx-room-code-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #111;
    border-radius: 16px;
    padding: 14px 20px;
    margin: 4px 0;
}
.ihx-room-code {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 6px;
    color: #4f8aff;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 20px rgba(79,138,255,0.4);
}
.ihx-btn-icon {
    background: #2a2a2a;
    border: none;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #888;
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.ihx-btn-icon:hover { background: #333; color: #fff; }

/* Спиннер ожидания */
.ihx-wait-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #888;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 0;
}
.ihx-wait-spinner i {
    color: #4f8aff;
    font-size: 18px;
}

/* Кнопка «Сдаться» */
.ihx-btn-danger {
    background: #3d1010;
    color: #ff6b6b;
    box-shadow: none;
    font-size: 14px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 12px;
    width: 100%;
    border: 1px solid #5a1a1a;
    transition: background 0.15s;
}
.ihx-btn-danger:hover { background: #5a1a1a; }

/* Инпут кода комнаты */
#ihx-join-code-input {
    font-size: 22px !important;
    text-align: center;
    letter-spacing: 4px;
    text-transform: uppercase;
    padding: 14px !important;
    background: #111 !important;
    border-color: #333 !important;
    color: #4f8aff !important;
    font-weight: 800;
    font-family: 'Courier New', monospace;
}
#ihx-join-code-input:focus {
    border-color: #4f8aff !important;
}

/* Онлайн-индикатор в статусе */
.ihx-online-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #4f8aff;
    font-weight: 700;
    background: rgba(79,138,255,0.1);
    padding: 3px 8px;
    border-radius: 8px;
}
.ihx-online-indicator::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4f8aff;
    animation: ihxPing 1.2s ease-in-out infinite;
}
@keyframes ihxPing {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(1.3); }
}
