:root {
    --game-container-width: 120vmin;
    --game-container-height: 100vmin;
    --background-color: #F5ECDE;
    --text-on-felt: #F5ECDE;
    --felt-color: #1f6b3b;
    --felt-color-dark: #17542e;
    --button-color: #197278;
    --card-bg: #fffdf7;
    --card-red: #c0392b;
    --card-black: #1a1a1a;
    --font-size-small: 1.3vmin;
    --font-size-medium: 3vmin;
    --font-size-normal: 3vmin;
    --font-size-large: 5vmin;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 30%, var(--felt-color) 0%, var(--felt-color-dark) 100%);
    background-attachment: fixed;
    font-family: 'Montserrat', sans-serif;
    color: var(--text-on-felt);
}

*, *::before, *::after {
    text-decoration: none;
    box-sizing: border-box;
    list-style: none;
}

a {
    color: inherit;
}

.container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.game-container {
    width: var(--game-container-width);
    height: var(--game-container-height);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2vmin;

    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.board-container {
    position: relative;
    width: calc(0.7 * var(--game-container-width));
    height: var(--game-container-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2vmin;
}

/* Pyramid layout */
.pyramid {
    position: relative;
    width: 100%;
    height: 56vmin;
    flex: none;
}

/* Talon: stock + waste */
.talon {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6vmin;
    margin-top: auto;
    padding-bottom: 1vmin;
}

/* Cards */
.card {
    position: absolute;
    width: 9.5vmin;
    height: 13.5vmin;
    transform: translateX(-50%);
    background-color: var(--card-bg);
    border: 0.15em solid #333;
    border-radius: 1vmin;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0.3vmin 0.6vmin rgba(0, 0, 0, 0.35);
    cursor: default;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.card .rank {
    font-size: 4.2vmin;
    font-weight: 700;
}

.card .suit {
    font-size: 4vmin;
}

.card.red {
    color: var(--card-red);
}

.card.black {
    color: var(--card-black);
}

.card.free {
    cursor: pointer;
}

.card.free:hover {
    box-shadow: 0 0 0 0.4vmin rgba(255, 255, 255, 0.7), 0 0.3vmin 0.6vmin rgba(0, 0, 0, 0.35);
}

.card.selected {
    box-shadow: 0 0 0 0.5vmin #F9C74F, 0 0.4vmin 0.8vmin rgba(0, 0, 0, 0.45);
    transform: translateX(-50%) translateY(-0.8vmin);
}

/* Talon cards are not absolutely positioned within the pile */
.talon .card {
    position: relative;
    transform: none;
}

.talon .card.selected {
    transform: translateY(-0.8vmin);
}

/* Piles */
.pile {
    width: 9.5vmin;
    height: 13.5vmin;
    border-radius: 1vmin;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stock {
    border: 0.25em dashed rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
    font-size: 4vmin;
}

.stock.filled {
    background:
        repeating-linear-gradient(45deg, #2c3e8f, #2c3e8f 1.2vmin, #3b4fb0 1.2vmin, #3b4fb0 2.4vmin);
    border: 0.15em solid #1b245c;
    cursor: pointer;
    box-shadow: 0 0.3vmin 0.6vmin rgba(0, 0, 0, 0.35);
}

.stock.filled .count {
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border-radius: 1vmin;
    padding: 0.4vmin 1vmin;
    font-size: 2.6vmin;
}

.stock.recycle {
    cursor: pointer;
    border: 0.25em solid rgba(255, 255, 255, 0.7);
}

.stock.empty {
    border-style: dotted;
    opacity: 0.5;
}

.waste {
    border: 0.25em dashed rgba(255, 255, 255, 0.25);
}

/* Options panel */
.options-container {
    width: calc(0.3 * var(--game-container-width));
    height: var(--game-container-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1vmin;
}

.game-title,
.status,
.links,
.difficulty_text,
.text-div,
.generate_new_title {
    text-shadow: 0 0.15vmin 0.3vmin rgba(0, 0, 0, 0.55);
}

.game-title {
    font-size: var(--font-size-normal);
    text-align: center;
}

.status {
    font-size: var(--font-size-normal);
    text-align: center;
    margin-bottom: 2vmin;
}

.status-line {
    margin: 0.5vmin 0;
}

.links {
    font-size: var(--font-size-normal);
}

hr {
    width: var(--game-container-width);
    height: 0.3em;
    background-color: black;
    margin-top: 2em;
    border: none;
}

.generate_new {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3em;
}

.circles {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: fit-content;
}

.circle_content {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1vmin;
    width: calc(var(--game-container-width) / 5);
}

.generate_new_title {
    font-size: var(--font-size-large);
    margin: 1rem 1rem 3vmin;
    font-weight: bolder;
    text-align: center;
}

.button_new_puzzle {
    margin-left: 2vmin;
    margin-right: 2vmin;
    position: relative;
    width: 4vmin;
    height: 4vmin;
    border-radius: 50%;
    vertical-align: middle;
    border: 0.02em solid black;
}

.button_new_puzzle_easy { background-color: #90BE6D; }
.button_new_puzzle_medium { background-color: #F9C74F; }
.button_new_puzzle_hard { background-color: #F8961E; }

.difficulty_text {
    text-decoration: none;
    margin-top: 1vmin;
    font-size: var(--font-size-normal);
}

.text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3em;
}

.text-div {
    text-align: left;
    line-height: 1.6;
    font-size: var(--font-size-normal);
    width: var(--game-container-width);
}

/* Responsive: stack panel under board on narrow screens */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
        height: auto;
        width: 100%;
    }
    .board-container {
        width: 96%;
        height: auto;
    }
    .options-container {
        width: 96%;
        height: auto;
        margin-top: 2vmin;
    }
    .pyramid {
        height: 62vmin;
    }
}

/* modal */
.modal {
    font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, ubuntu, roboto, noto, segoe ui, arial, sans-serif;
}

.modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal__container {
    background-color: #fff;
    padding: 30px;
    max-width: 120vmin;
    max-height: 100vh;
    border-radius: 4px;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__title {
    margin: 0;
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.25;
    color: #00449e;
}

.modal__content {
    margin-top: 2rem;
    margin-bottom: 2rem;
    line-height: 1.5;
    color: rgba(0, 0, 0, .8);
}

.modal__btn {
    text-decoration: none;
    font-size: .875rem;
    padding: .5rem 1rem;
    color: rgba(0, 0, 0, .8);
    border-radius: .25rem;
    border: 0.02em solid black;
    cursor: pointer;
    margin: 1vmin;
    transition: transform .25s ease-out;
}

.modal__btn:focus, .modal__btn:hover {
    transform: scale(1.05);
}

@keyframes mmfadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes mmfadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes mmslideIn { from { transform: translateY(15%); } to { transform: translateY(0); } }
@keyframes mmslideOut { from { transform: translateY(0); } to { transform: translateY(-10%); } }

.micromodal-slide { display: none; }
.micromodal-slide.is-open { display: block; }
.micromodal-slide[aria-hidden="false"] .modal__overlay { animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1); }
.micromodal-slide[aria-hidden="false"] .modal__container { animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1); }
.micromodal-slide[aria-hidden="true"] .modal__overlay { animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1); }
.micromodal-slide[aria-hidden="true"] .modal__container { animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1); }
.micromodal-slide .modal__container, .micromodal-slide .modal__overlay { will-change: transform; }
