/* =====================================
   CONFIGURAÇÕES GERAIS
===================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --page-background: #d8d8d8;
    --surface: #f6f6f6;
    --surface-dark: #252525;

    --border-color: #202020;
    --soft-border: #b9b9b9;

    --text-color: #1f1f1f;
    --muted-text: #707070;

    --summon-color: #a64db0;
    --spell-color: #4853d0;
    --grimoire-color: #7f9fc6;
    --small-deck-color: #ffc522;
    --main-deck-color: #f51c2b;
    --discard-color: #bdbdbd;
    --banishment-color: #111111;
}

html,
body {
    min-height: 100%;
}

body {
    min-height: 100vh;

    padding: 12px;

    background: var(--page-background);

    color: var(--text-color);

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    overflow-x: auto;
}

button,
textarea {
    font: inherit;
}


/* =====================================
   LAYOUT COMPLETO
===================================== */

.game-layout {
    width: 100%;
    max-width: 1280px;
    min-width: 1050px;

    min-height: calc(100vh - 24px);

    display: grid;

    grid-template-columns:
        190px
        minmax(690px, 1fr)
        190px;

    gap: 12px;

    align-items: stretch;

    margin: 0 auto;
}


/* =====================================
   PAINÉIS LATERAIS
===================================== */

.side-panel {
    min-width: 0;

    display: flex;
    flex-direction: column;

    background: var(--surface);

    border: 3px solid var(--border-color);

    overflow: hidden;
}

.panel-header {
    min-height: 40px;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 8px 10px;

    background: var(--surface-dark);

    color: #ffffff;

    border-bottom: 3px solid var(--border-color);
}

.panel-header h2 {
    font-size: 14px;
    text-align: center;
}


/* =====================================
   DISPLAY DA CARTA
===================================== */

.card-display {
    flex: 1;

    display: flex;
    flex-direction: column;

    gap: 12px;

    padding: 12px;
}

.card-preview {
    width: 126px;
    aspect-ratio: 0.72;

    display: flex;
    align-items: center;
    justify-content: center;

    align-self: center;

    padding: 10px;

    background:
        repeating-linear-gradient(
            45deg,
            #dddddd,
            #dddddd 9px,
            #e8e8e8 9px,
            #e8e8e8 18px
        );

    border: 3px solid var(--border-color);

    color: var(--muted-text);

    font-size: 11px;
    text-align: center;
    line-height: 1.35;
}

.card-information {
    display: flex;
    flex-direction: column;

    gap: 5px;
}

.selected-card-name {
    font-size: 16px;
}

.selected-card-type {
    color: var(--muted-text);

    font-size: 11px;
    font-weight: bold;
}

.selected-card-description {
    min-height: 110px;
    max-height: 180px;

    padding: 10px;

    background: #ffffff;

    border: 1px solid var(--soft-border);

    font-size: 12px;
    line-height: 1.4;

    overflow-y: auto;
}


/* =====================================
   CENTRO DO JOGO
===================================== */

.game-center {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 10px;
}

.game-header {
    min-height: 56px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    padding: 6px 14px;

    background: var(--surface);

    border: 3px solid var(--border-color);

    text-align: center;
}

.game-eyebrow {
    margin-bottom: 1px;

    color: var(--muted-text);

    font-size: 8px;
    font-weight: bold;

    letter-spacing: 2px;
    text-transform: uppercase;
}

.game-header h1 {
    font-size: 23px;
}


/* =====================================
   TABULEIRO
===================================== */

.game-board {
    flex: 1;

    min-height: 350px;

    display: grid;

    grid-template-columns:
        80px
        minmax(470px, 1fr)
        145px;

    gap: 25px;

    align-items: center;

    padding: 28px;

    background: var(--surface);

    border: 3px solid var(--border-color);
}


/* =====================================
   FORMATO DAS ZONAS
===================================== */

.card-zone {
    position: relative;

    width: 100%;
    aspect-ratio: 0.72;

    display: flex;
    justify-content: center;
    align-items: center;

    border: 4px solid var(--border-color);

    text-align: center;

    overflow: hidden;
}

.card-zone span {
    padding: 4px;

    color: #ffffff;

    font-size: 9px;
    font-weight: bold;

    line-height: 1.1;

    text-shadow:
        1px 1px 1px #000000,
        -1px -1px 1px #000000,
        1px -1px 1px #000000,
        -1px 1px 1px #000000;
}


/* =====================================
   ZONAS DO LADO ESQUERDO
===================================== */

.side-zones--left {
    display: flex;
    flex-direction: column;

    gap: 22px;
}


/* =====================================
   ZONAS CENTRAIS
===================================== */

.field-zones {
    display: flex;
    flex-direction: column;

    gap: 18px;
}

.zone-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(58px, 1fr));

    gap: 15px;
}


/* =====================================
   ZONAS DO LADO DIREITO
===================================== */

.side-zones--right {
    display: flex;
    flex-direction: column;

    align-items: center;

    gap: 12px;
}

.side-zones--right > .card-zone {
    width: 68px;
}

.deck-zones {
    width: 100%;

    display: grid;
    grid-template-columns: repeat(2, 1fr);

    gap: 8px;
}


/* =====================================
   CORES DAS ZONAS
===================================== */

.card-zone--banishment {
    background: var(--banishment-color);
}

.card-zone--discard {
    background: var(--discard-color);
}

.card-zone--summon {
    background: var(--summon-color);
}

.card-zone--spell {
    background: var(--spell-color);
}

.card-zone--grimoire {
    background: var(--grimoire-color);
}

.card-zone--small-deck {
    background: var(--small-deck-color);
}

.card-zone--main-deck {
    background: var(--main-deck-color);
}


/* =====================================
   ÁREA DA MÃO
===================================== */

.hand-area {
    min-height: 120px;
    max-height: 150px;

    display: flex;
    flex-direction: column;

    background: var(--surface);

    border: 3px solid var(--border-color);
}

.hand-header {
    min-height: 28px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 5px 10px;

    background: var(--surface-dark);

    color: #ffffff;
}

.hand-header h2 {
    font-size: 11px;
}

.hand-counter {
    font-size: 9px;
}

.hand-cards {
    flex: 1;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    padding: 10px;

    overflow-x: auto;
    overflow-y: hidden;
    align-items: flex-start;
}

.empty-hand-message {
    color: var(--muted-text);

    font-size: 10px;
}


/* =====================================
   CHAT
===================================== */

.chat-panel {
    max-height: calc(100vh - 24px);
}

.chat-messages {
    flex: 1;

    min-height: 0;

    padding: 10px;

    overflow-y: auto;
}

.system-message {
    padding: 9px;

    background: #e4e4e4;

    border-left: 3px solid var(--border-color);

    line-height: 1.35;
}

.system-message span {
    display: block;

    margin-bottom: 4px;

    font-size: 10px;
    font-weight: bold;
}

.system-message p {
    color: #555555;

    font-size: 10px;
}

.chat-form {
    display: flex;
    flex-direction: column;

    gap: 6px;

    padding: 8px;

    background: #e7e7e7;

    border-top: 2px solid var(--border-color);
}

.chat-form textarea {
    width: 100%;
    height: 58px;

    padding: 7px;

    resize: none;

    background: #ffffff;

    border: 1px solid var(--border-color);

    color: var(--text-color);

    font-size: 11px;
}

.chat-form button {
    padding: 7px;

    background: var(--surface-dark);

    border: 1px solid var(--border-color);

    color: #ffffff;

    font-size: 11px;
    font-weight: bold;

    cursor: not-allowed;

    opacity: 0.6;
}


/* =====================================
   ACESSIBILIDADE
===================================== */

.visually-hidden {
    position: absolute;

    width: 1px;
    height: 1px;

    padding: 0;
    margin: -1px;

    overflow: hidden;

    clip: rect(0, 0, 0, 0);

    white-space: nowrap;

    border: 0;
}


/* =====================================
   TELAS MAIS LARGAS
===================================== */

@media (min-width: 1500px) {
    .game-layout {
        max-width: 1360px;

        grid-template-columns:
            210px
            minmax(760px, 1fr)
            210px;

        gap: 14px;
    }

    .game-board {
        grid-template-columns:
            86px
            minmax(520px, 1fr)
            155px;

        gap: 28px;

        padding: 32px;
    }

    .zone-row {
        gap: 17px;
    }
}


/* =====================================
   TELAS MENORES
===================================== */

@media (max-width: 1100px) {
    body {
        padding: 8px;
    }

    .game-layout {
        justify-content: flex-start;
    }
}

/* =====================================
   CARTAS NA MÃO
===================================== */

.game-card {
    flex: 0 0 70px;

    aspect-ratio: 0.72;

    display: flex;
    flex-direction: column;

    background: #ffffff;

    border: 3px solid var(--border-color);

    overflow: hidden;
}

.game-card__image {
    flex: 1;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 5px;

    background:
        repeating-linear-gradient(
            45deg,
            #d8d8d8,
            #d8d8d8 6px,
            #e8e8e8 6px,
            #e8e8e8 12px
        );

    color: var(--muted-text);

    font-size: 8px;
    text-align: center;
}

.game-card__content {
    min-height: 35px;

    display: flex;
    flex-direction: column;

    justify-content: center;

    padding: 4px;

    background: #eeeeee;

    border-top: 2px solid var(--border-color);
}

.game-card__content strong {
    font-size: 8px;
    line-height: 1.1;
}

.game-card__content span {
    margin-top: 2px;

    color: var(--muted-text);

    font-size: 7px;
}

/* =====================================
   CONTADOR DOS BARALHOS
===================================== */

.card-zone--small-deck {
    cursor: pointer;
}

.card-zone--small-deck:hover {
    filter: brightness(1.08);
}

.deck-counter {
    position: absolute;

    right: 4px;
    bottom: 4px;

    min-width: 18px;
    min-height: 18px;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 3px;

    background: #ffffff;

    border: 2px solid var(--border-color);

    color: #111111;

    font-size: 9px;

    text-shadow: none;
}

.card-zone--empty {
    filter: grayscale(1);
    opacity: 0.55;
    cursor: default;
}

/* =====================================
   SELEÇÃO DE CARTAS
===================================== */

.game-card {
    cursor: pointer;

    transition:
        transform 0.12s ease,
        box-shadow 0.12s ease,
        border-color 0.12s ease;
}

.game-card:hover {
    transform: translateY(-3px);
}

.game-card--selected {
    border-color: #f1c40f;

    box-shadow:
        0 0 0 2px #111111,
        0 0 0 5px #f1c40f;

    transform: translateY(-5px);
}

.card-preview img {
    width: 100%;
    height: 100%;

    object-fit: cover;
}

/* =====================================
   CARTAS NAS ZONAS DO CAMPO
===================================== */

.card-zone--occupied {
    padding: 0;

    cursor: pointer;
}

.game-card--field {
    width: 100%;
    height: 100%;

    flex: none;

    border: none;

    aspect-ratio: auto;
}

.game-card--field:hover {
    transform: none;
}

.game-card--field.game-card--selected {
    border: 4px solid #f1c40f;

    box-shadow:
        inset 0 0 0 2px #111111;

    transform: none;
}


/* Zona vazia disponível */

.card-zone:not(.card-zone--occupied):hover {
    filter: brightness(1.08);
}


/* Mão como destino */

.hand-cards {
    cursor: default;

    overflow-x: auto;
    overflow-y: hidden;
}

.hand-cards:hover {
    background: #fafafa;
}