/* maze.css */
body {
    margin: 0;
    background: #020617;
    color: white;
    font-family: "Segoe UI Emoji", "Noto Color Emoji", "Symbola", "DejaVu Sans", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    outline: none;
    touch-action: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.header-info {
    display: flex;
    justify-content: space-between;
    max-width: min(90vw, 600px);
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9rem;
    padding: 5px 10px;
}

.main-content {
    display: flex;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

.side-panel {
    width: 200px;
    padding: 10px;
    background: #1e293b;
    border-radius: 8px;
    margin: 10px;
    overflow-y: auto;
    display: none;
    /* По умолчанию скрыты */
}

.help-panel h3,
.table-panel h3 {
    margin-top: 0;
}

.table-panel table {
    width: 100%;
    border-collapse: collapse;
}

.table-panel th,
.table-panel td {
    border: 1px solid #334155;
    padding: 5px;
}

.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 5px;
}

.canvas-wrapper {
    border: 3px solid #1e293b;
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    line-height: 0;
    position: relative;
    overflow: hidden;
    margin-bottom: 15px;
}

canvas {
    max-width: min(90vw, 600px);
    background: #020617;
}

.lvl-text {
    color: #00d2ff;
}

.win-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #10b981;
    font-weight: bold;
    font-size: 2rem;
    display: none;
    text-shadow: 0 0 20px #10b981;
    z-index: 20;
    background: rgba(2, 6, 23, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #10b981;
}

/* Контейнер джойстика */
.controls-container {
    display: none;
    grid-template-columns: repeat(3, 70px);
    grid-template-rows: repeat(2, 70px);
    gap: 12px;
    justify-content: center;
}

.btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Эффект нажатия */
.btn:active {
    background: rgba(0, 210, 255, 0.4);
    border-color: #00d2ff;
    transform: scale(0.92);
}

/* Позиционирование кнопок в сетке */
.up {
    grid-column: 2;
    grid-row: 1;
}

.left {
    grid-column: 1;
    grid-row: 2;
}

.down {
    grid-column: 2;
    grid-row: 2;
}

.right {
    grid-column: 3;
    grid-row: 2;
}

.toggle-btn {
    cursor: pointer;
    margin-left: 10px;
    font-size: 1.2rem;
}

.hide-btn {
    margin-top: 10px;
    padding: 5px 10px;
    background: #334155;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 5px;
}

.hide-btn:hover {
    background: #475569;
}

/* Медиа-запросы */
@media (pointer: coarse) {
    .controls-container {
        display: grid;
        margin-top: 10px;
        margin-bottom: 10px;
    }

    canvas {
        max-height: 55vh;
    }

    .mobile-only {
        display: inline;
    }

    .desktop-only {
        display: none;
    }

    .desktop-visible {
        display: none !important;
    }

    .center-content {
        justify-content: flex-start;
        padding-top: 5px;
    }

    .header-info {
        margin-bottom: 3px;
        font-size: 0.8rem;
    }

    .panel-visible {
        display: block !important;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 100;
        width: 80vw;
        max-height: 80vh;
        overflow-y: auto;
    }
}

@media (pointer: fine) {
    canvas {
        max-height: 80vh;
    }

    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }

    .desktop-visible {
        display: block;
    }

    .center-expanded canvas {
        max-width: 90vw !important;
    }
}

@media (min-width: 768px) {
    .header-info {
        max-width: 90vw;
    }

    .side-panel {
        width: 250px;
    }
}

/* Диалоговые окна */
.dialog-box {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.dialog-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #00d2ff;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 210, 255, 0.3);
    animation: slideIn 0.3s ease-out;
}

.dialog-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.dialog-text {
    font-size: 1rem;
    color: #e2e8f0;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 60px;
}

.dialog-close {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 15px;
}

.story-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.story-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 3px solid #a855f7;
    border-radius: 15px;
    padding: 50px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 0 50px rgba(168, 85, 247, 0.4);
    animation: slideIn 0.4s ease-out;
}

.story-content h2 {
    font-size: 2rem;
    color: #a855f7;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.story-content p {
    font-size: 1.1rem;
    color: #e2e8f0;
    line-height: 1.8;
    margin-bottom: 30px;
}

.story-close {
    font-size: 0.9rem;
    color: #94a3b8;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.char-select-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.char-select-modal {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 3px solid #a855f7;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 0 50px rgba(168, 85, 247, 0.4);
}

.char-options {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 30px 0;
}

.char-card {
    width: 160px;
    background: rgba(255, 255, 255, 0.06);
    border: 3px solid rgba(168, 85, 247, 0.4);
    border-radius: 18px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.char-card:hover {
    transform: translateY(-12px) scale(1.05);
    border-color: #a855f7;
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.6);
}

.char-preview {
    width: 96px;
    height: 96px;
    margin: 0 auto 15px;
    background-repeat: no-repeat;
    background-position: 0 0;
    image-rendering: pixelated;
    border: 3px solid rgba(168, 85, 247, 0.5);
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.4);
    background-color: #0f172a;

    /* Анимация idle-превью (5 кадров горизонтально) */
    animation: previewIdle 1.2s steps(4) infinite;
}

@keyframes previewIdle {
    from {
        background-position-x: 0;
    }

    to {
        background-position-x: -400%;
    }

    /* -100% × (кол-во кадров - 1) */
}

/* При наведении — чуть быстрее и ярче */
.char-card:hover .char-preview {
    animation-duration: 0.9s;
    filter: brightness(1.15);
}

.char-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #e0f2fe;
}

.char-stats {
    font-size: 0.85rem;
    color: #67e8f9;
}

/* Кнопка закрытия */
.close-char-select {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 28px;
    cursor: pointer;
}

.joystick-wrapper {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid #00d2ff;
    border-radius: 50%;
    position: relative;
}

.joystick-knob {
    width: 50px;
    height: 50px;
    background: #00d2ff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px #00d2ff;
    transition: transform 0.05s;
}

@keyframes charIdle {
    from {
        background-position-x: 0;
    }

    to {
        background-position-x: -256px;
    }

    /* Смещение на всю ширину ряда */
}

/* Направления (ряды в спрайт-листе) */
.preview-down {
    background-position-y: 0;
}

/* Стили для главного меню */
.main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(10px);
}

.menu-content {
    text-align: center;
    padding: 40px;
    border-radius: 20px;
    background: rgba(2, 6, 23, 0.85);
    box-shadow: 0 0 50px rgba(0, 210, 255, 0.3),
                inset 0 0 30px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 210, 255, 0.4);
    max-width: 90vw;
    width: 400px;
}

.game-title {
    font-size: 3rem;
    color: #00d2ff;
    text-shadow: 0 0 20px rgba(0, 210, 255, 0.7),
                 0 0 40px rgba(0, 210, 255, 0.5);
    margin: 0 0 10px 0;
    letter-spacing: 3px;
    animation: titleGlow 3s infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 20px rgba(0, 210, 255, 0.7), 0 0 40px rgba(0, 210, 255, 0.5); }
    100% { text-shadow: 0 0 30px rgba(0, 210, 255, 0.9), 0 0 60px rgba(0, 210, 255, 0.7); }
}

.subtitle {
    font-size: 1.2rem;
    color: #a855f7;
    margin: 0 0 30px 0;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 25px;
}

.menu-button {
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border: 2px solid rgba(0, 210, 255, 0.4);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4),
                inset 0 2px 4px rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.menu-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 210, 255, 0.3), transparent);
    transition: left 0.8s;
}

.menu-button:hover::before {
    left: 100%;
}

.menu-button:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    border-color: #00d2ff;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.3),
                inset 0 2px 8px rgba(255, 255, 255, 0.2);
}

.menu-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(0, 210, 255, 0.2),
                inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.menu-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.5),
                0 8px 25px rgba(0, 210, 255, 0.3);
}

.menu-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.menu-footer button {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #cbd5e1;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.menu-footer button:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: #00d2ff;
    color: #00d2ff;
}

#version {
    color: #94a3b8;
    font-size: 0.9rem;
}

.preview-left {
    background-position-y: -64px;
}

.preview-right {
    background-position-y: -128px;
}

.preview-up {
    background-position-y: -192px;
}


.panel {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(0, 210, 255, 0.4);
    border-radius: 14px;
    padding: 12px 20px;
    width: 280px;
    height: 78px;
    color: white;
}

/* maze.css */
.header-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.menu-btn,
.debug-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid #334155;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.menu-btn:hover {
    background: #ef4444;
}

.debug-btn:hover {
    background: #a855f7;
}

#debug-panel {
    background: #1e293b;
    border-left: 2px solid #a855f7;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 2000;
    padding: 20px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.canvas-wrapper {
    margin-top: 60px;
    /* Создает отступ сверху для области HUD */
    position: relative;
}

.bottom-panels {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 110px;
  background: linear-gradient(to top, #020617, rgba(2,6,23,0.98));
  border-top: 3px solid #00d2ff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 300;
  padding: 0 20px;
  gap: 20px;
}

.panel {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(0,210,255,0.5);
  border-radius: 16px;
  padding: 14px 22px;
  width: 300px;
  height: 78px;
  color: white;
  font-size: 0.95rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

.joystick-wrapper {
  position: fixed;
  bottom: 140px;   /* выше нижних панелей */
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
}

.joystick-base { width: 110px; height: 110px; }   /* чуть меньше */
.joystick-knob { width: 46px; height: 46px; }