:root {
    --board-columns: 6;
    --board-rows: 8;

    --page-background: #dce4ff;
    --panel-background: rgba(247, 249, 255, 0.72);
    --panel-border: rgba(123, 145, 221, 0.35);

    --board-background: rgba(168, 185, 235, 0.42);
    --cell-background: rgba(241, 244, 255, 0.72);
    --cell-border: rgba(255, 255, 255, 0.88);

    --blue: #0799e7;
    --blue-light: #66e7ff;
    --blue-dark: #185fbd;

    --red: #ef4e5e;
    --red-light: #ff9aa5;
    --red-dark: #bc354d;

    --text: #183271;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

button {
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
}

body {
    font-family: Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.95), transparent 40%),
        linear-gradient(160deg, #e9edff 0%, var(--page-background) 100%);
    user-select: none;
    touch-action: manipulation;
}

.game {
    width: 100%;
    height: 100dvh;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.game-shell {
    width: 100%;
    max-width: 560px;
    height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
        "top"
        "players"
        "board"
        "bonuses";
    gap: 8px;
    padding: 8px;
    border: 2px solid rgba(112, 137, 218, 0.46);
    border-radius: 24px;
    background: rgba(202, 214, 250, 0.42);
    box-shadow:
        0 14px 40px rgba(49, 68, 134, 0.17),
        inset 0 0 25px rgba(255, 255, 255, 0.44);
}

/* Horný panel */

.top-bar {
    grid-area: top;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 10px;
}

.icon-button {
    width: 42px;
    height: 42px;
    position: relative;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 13px;
    background: rgba(247, 249, 255, 0.82);
    box-shadow:
        0 4px 8px rgba(57, 74, 138, 0.16),
        inset 0 1px 3px rgba(255, 255, 255, 0.9);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.icon-button:active {
    transform: scale(0.95);
}

/* Šípka späť */

.back-icon {
    width: 20px;
    height: 3px;
    position: relative;
    border-radius: 3px;
    background: var(--text);
}

.back-icon::before {
    content: "";
    width: 11px;
    height: 11px;
    position: absolute;
    left: 0;
    top: 50%;
    border-left: 3px solid var(--text);
    border-bottom: 3px solid var(--text);
    transform: translateY(-50%) rotate(45deg);
}

/* Pauza */

.pause-icon {
    width: 16px;
    height: 21px;
    position: relative;
    border-left: 5px solid var(--text);
    border-right: 5px solid var(--text);
    border-radius: 2px;
}

/* Stav ťahu */

.turn-panel {
    min-width: 0;
    text-align: center;
}

.turn-label {
    margin-bottom: 5px;
    overflow: hidden;
    color: var(--text);
    font-size: clamp(13px, 3.7vw, 17px);
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.turn-progress {
    width: 92%;
    height: 7px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid rgba(88, 116, 193, 0.38);
    border-radius: 999px;
    background: rgba(102, 122, 184, 0.25);
    box-shadow: inset 0 2px 4px rgba(31, 50, 105, 0.12);
}

.turn-progress-value {
    width: 64%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
    box-shadow: 0 0 10px rgba(62, 215, 255, 0.65);
    transition: width 0.2s linear;
}

/* Hráči */

.players {
    grid-area: players;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.player-card {
    min-width: 0;
    height: 58px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 43px;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    border: 2px solid transparent;
    border-radius: 14px;
    background: var(--panel-background);
    box-shadow:
        0 4px 9px rgba(54, 72, 137, 0.14),
        inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

.player-card--blue {
    background: linear-gradient(110deg, rgba(209, 247, 255, 0.88), rgba(246, 249, 255, 0.8));
}

.player-card--red {
    background: linear-gradient(110deg, rgba(255, 231, 235, 0.88), rgba(246, 249, 255, 0.8));
}

.player-card--active.player-card--blue {
    border-color: rgba(39, 192, 244, 0.72);
    box-shadow:
        0 0 12px rgba(45, 210, 255, 0.28),
        inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.player-card--active.player-card--red {
    border-color: rgba(242, 82, 101, 0.72);
    box-shadow:
        0 0 12px rgba(242, 82, 101, 0.26),
        inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.player-avatar {
    width: 38px;
    aspect-ratio: 1;
    border: 4px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

.player-avatar--blue {
    background: radial-gradient(circle at 38% 30%, #a9f7ff 0%, var(--blue) 35%, var(--blue-dark) 72%);
    box-shadow: 0 0 8px rgba(38, 194, 247, 0.42);
}

.player-avatar--red {
    background: radial-gradient(circle at 38% 30%, #ffd1d5 0%, var(--red) 35%, var(--red-dark) 72%);
    box-shadow: 0 0 8px rgba(239, 78, 94, 0.36);
}

.player-name {
    min-width: 0;
    overflow: hidden;
    font-size: clamp(11px, 3.2vw, 15px);
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.level-badge {
    width: 43px;
    height: 48px;
    position: relative;
    display: grid;
    place-items: center;
    clip-path: polygon(50% 0, 92% 18%, 86% 72%, 50% 100%, 14% 72%, 8% 18%);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    filter: drop-shadow(0 3px 4px rgba(28, 45, 105, 0.2));
}

.level-badge::before {
    content: "";
    position: absolute;
    inset: 4px;
    clip-path: inherit;
    border: 1px solid rgba(255, 255, 255, 0.72);
}

.level-badge span {
    position: relative;
    z-index: 1;
}

.level-badge--blue {
    background: linear-gradient(145deg, #75eaff, #1674db 70%);
}

.level-badge--red {
    background: linear-gradient(145deg, #ff9ba6, #db3d54 70%);
}

/* Hracia plocha */

.board-stage {
    grid-area: board;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(var(--board-columns), minmax(0, 1fr));
    grid-template-rows: repeat(var(--board-rows), minmax(0, 1fr));
    width: min(100%, calc((100dvh - 245px) * 0.75), 500px);
    aspect-ratio: var(--board-columns) / var(--board-rows);
    padding: 6px;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    background: var(--board-background);
    box-shadow:
        0 8px 20px rgba(48, 68, 135, 0.18),
        inset 0 0 16px rgba(255, 255, 255, 0.32);
}

.game-cell {
    min-width: 0;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cell-border);
    border-radius: 9px;
    background: var(--cell-background);
    box-shadow:
        0 2px 4px rgba(61, 78, 143, 0.13),
        inset 0 1px 4px rgba(255, 255, 255, 0.72);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.game-cell:active {
    transform: scale(0.95);
}

.game-cell--player-1 {
    border-color: rgba(239, 78, 94, 0.55);
    background: rgba(255, 217, 224, 0.82);
}

.game-cell--player-2 {
    border-color: rgba(7, 153, 231, 0.55);
    background: rgba(206, 244, 255, 0.82);
}

.game-cell--disabled {
    visibility: hidden;
    pointer-events: none;
}

.game-board--finished .game-cell {
    cursor: default;
    pointer-events: none;
}

/* Atómy */

.atom-container {
    width: 58%;
    height: 58%;
    position: relative;
}

.atom {
    width: 42%;
    position: absolute;
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.game-cell--player-1 .atom {
    color: var(--red);
    background: radial-gradient(circle at 35% 30%, #ffd2d6, var(--red) 42%, var(--red-dark));
    box-shadow: 0 0 8px currentColor;
}

.game-cell--player-2 .atom {
    color: var(--blue);
    background: radial-gradient(circle at 35% 30%, #b5f7ff, var(--blue) 42%, var(--blue-dark));
    box-shadow: 0 0 8px currentColor;
}

.atom-count-1 .atom:nth-child(1) {
    left: 50%;
    top: 50%;
}

.atom-count-2 .atom:nth-child(1) {
    left: 34%;
    top: 50%;
}

.atom-count-2 .atom:nth-child(2) {
    left: 66%;
    top: 50%;
}

.atom-count-3 .atom:nth-child(1) {
    left: 50%;
    top: 28%;
}

.atom-count-3 .atom:nth-child(2) {
    left: 31%;
    top: 67%;
}

.atom-count-3 .atom:nth-child(3) {
    left: 69%;
    top: 67%;
}

.atom-count-4 .atom:nth-child(1) {
    left: 32%;
    top: 32%;
}

.atom-count-4 .atom:nth-child(2) {
    left: 68%;
    top: 32%;
}

.atom-count-4 .atom:nth-child(3) {
    left: 32%;
    top: 68%;
}

.atom-count-4 .atom:nth-child(4) {
    left: 68%;
    top: 68%;
}

/* Bonusy */

.bonus-bar {
    grid-area: bonuses;
    width: 82%;
    max-width: 360px;
    justify-self: center;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.bonus-card {
    min-width: 0;
    height: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 2px solid transparent;
    border-radius: 14px;
    background: rgba(247, 249, 255, 0.8);
    box-shadow: 0 4px 9px rgba(49, 68, 134, 0.15);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.bonus-card:active {
    transform: scale(0.96);
}

.bonus-card--selected {
    border-color: rgba(87, 231, 255, 0.9);
    box-shadow:
        0 0 13px rgba(75, 224, 255, 0.46),
        inset 0 0 9px rgba(255, 255, 255, 0.7);
}

.bonus-icon {
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    font-size: 29px;
    font-weight: 700;
    line-height: 1;
}

.bonus-icon--charge {
    background: linear-gradient(145deg, #21c3ff, #087edc);
}

.bonus-icon--diagonal {
    background: linear-gradient(145deg, #b068ff, #7338de);
}

.bonus-icon--shield {
    position: relative;
    background: linear-gradient(145deg, #ffbd55, #ed7b14);
}

.bonus-icon--shield::before {
    content: "";
    width: 19px;
    height: 23px;
    border: 3px solid #fff;
    border-radius: 11px 11px 14px 14px;
    clip-path: polygon(50% 0, 100% 18%, 86% 74%, 50% 100%, 14% 74%, 0 18%);
}

.bonus-name {
    width: 100%;
    overflow: hidden;
    font-size: clamp(9px, 2.8vw, 12px);
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Menšie telefóny */

@media (max-height: 720px) {
    .game-shell {
        gap: 6px;
        padding: 7px;
    }

    .game-board {
        width: min(100%, calc((100dvh - 215px) * 0.75));
    }

    .bonus-bar {
        width: 78%;
        gap: 8px;
    }

    .bonus-card {
        height: 68px;
    }

    .bonus-icon {
        width: 34px;
        height: 34px;
        font-size: 25px;
    }

    .bonus-icon--shield::before {
        width: 17px;
        height: 20px;
    }
}
