﻿/* Mobile Adaptation for Mission Card */
@media screen and (max-width: 600px),
body.force-mobile {
    .mission-card {
        flex-direction: column;
        /* Stack vertically on small screens */
        height: auto;
    }

    .mission-thumb {
        width: 100%;
        height: 140px;
    }

    .mission-info {
        padding: 15px;
    }

    .mission-action {
        width: 100%;
        justify-content: flex-end;
        /* Button to right */
        padding: 0 15px 15px 15px;
    }
}

/* ========== Mobile / Responsive Adaptations ========== */

/* Tablet & Mobile (max-width: 1024px) */
@media screen and (max-width: 1024px),
body.force-tablet,
body.force-mobile {
    body {
        padding: 10px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .container {
        width: 100%;
        max-width: 100%;
        padding-bottom: 50px;
    }

    h1 {
        font-size: 2em;
        margin-top: 40px;
        text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    }

    /* Vertical layout for game */
    .game-layout {
        flex-direction: column-reverse;
        /* Game board on top, Character below */
        align-items: center;
        gap: 20px;
    }

    /* Constrain board width, maintain aspect ratio */
    .game-container {
        width: 100%;
        max-width: 600px;
        aspect-ratio: 1 / 1;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0 auto;
    }

    #board {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        touch-action: none;
        object-fit: contain;
    }

    /* Character area adjustments - CSS Grid Layout */
    .character-wrapper {
        width: 100%;
        max-width: 450px;
        padding: 10px;
        height: auto;
        background: rgba(26, 26, 46, 0.8);
        border-radius: 12px;
        margin-bottom: 10px;

        display: grid;
        grid-template-columns: 70px 1fr;
        grid-template-rows: auto auto;
        column-gap: 15px;
        align-items: start;
    }

    .char-frame {
        width: 70px;
        height: 70px;
        margin: 0;
        border-radius: 50%;
        overflow: hidden;
        border: 2px solid rgba(255, 255, 255, 0.2);

        grid-row: 1 / 3;
        /* Span both rows */
        grid-column: 1;
        align-self: center;
    }

    .char-sprite {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center top;
        transform: scale(1.1);
    }

    .character-wrapper .char-name {
        text-align: left;
        margin: 0;
        padding-top: 5px;
        font-size: 1.1em;
        color: #a855f7;

        grid-row: 1;
        grid-column: 2;
    }

    .dialogue-box {
        margin-top: 5px;
        padding: 8px 10px;
        font-size: 0.95em;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 6px;
        width: 100%;
        min-height: 30px;
        line-height: 1.4;

        grid-row: 2;
        grid-column: 2;
    }

    /* Modal size adjustments */
    .modal-content,
    .rps-content,
    .winner-content,
    .mode-select-content,
    .mission-select-content {
        min-width: unset;
        width: 90%;
        max-width: 480px;
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        height: auto;
        max-height: 90vh;
        /* Prevent checking out of screen */
        overflow-y: auto;
    }

    /* Responsive Buttons in Modals */
    .story-mode-buttons,
    .free-mode-buttons {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .mode-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 15px;
    }

    /* Story HUD Adapts */
    .story-hud {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .story-hud-left,
    .story-hud-center,
    .story-hud-right {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 4px 0;
        text-align: center;
    }

    .story-hud-right {
        border-bottom: none;
    }
}

/* Phones (Portrait, max-width: 600px) */
@media screen and (max-width: 600px),
body.force-mobile {
    h1 {
        font-size: 1.5em;
        margin-top: 30px;
        margin-bottom: 15px;
    }

    .player-info {
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 10px;
    }

    .game-info {
        margin-bottom: 15px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 13px;
        flex: 1;
    }

    .controls {
        gap: 10px;
        width: 100%;
        margin-top: 15px;
        display: flex;
        flex-wrap: wrap;
    }

    /* Ensure board fits within screen width */
    .game-container {
        width: 100%;
        max-width: 100%;
    }

    /* Dialog text smaller on mobile */
    .dialogue-box p {
        font-size: 0.9em;
    }
}