.hidden {
    display: none !important;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0 0 50px;

    font-family:
        "Comic Sans MS",
        "Comic Sans",
        cursive;

    color: #172b63;

    background-color: #f5f8ff;
    background-image:
        url("../../images/home/kcgbackground.png");
    background-repeat: repeat;
    background-size: 420px;
}

#setup-page header {
    width: min(900px, 92vw);
    margin: 0 auto 24px;
    padding: 24px;

    text-align: center;

    border: 4px solid #2f66e8;
    border-radius: 24px;

    background:
        rgba(255, 255, 255, 0.96);

    box-shadow:
        0 10px 24px
        rgba(47, 102, 232, 0.15);
}

#setup-page header h1 {
    margin: 0 0 8px;

    color: #2f66e8;

    font-size:
        clamp(30px, 5vw, 52px);
}

#setup-page header p {
    margin: 0;

    color: #172b63;

    font-size:
        clamp(17px, 2vw, 22px);

    font-weight: bold;
}

.controls {
    width: min(900px, 92vw);
    margin: 24px auto;
    padding: clamp(20px, 4vw, 36px);

    display: flex;
    flex-direction: column;
    gap: 22px;

    border: 4px solid #2f66e8;
    border-radius: 24px;

    background:
        rgba(255, 255, 255, 0.96);

    box-shadow:
        0 10px 24px
        rgba(47, 102, 232, 0.15);
}

.controls > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.controls label,
.controls h3,
.controls legend {
    margin: 0;

    color: #172b63;

    font-size:
        clamp(18px, 2vw, 24px);

    font-weight: bold;
}

.controls select {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;

    border: 3px solid #b8d0ff;
    border-radius: 14px;

    background: white;
    color: #172b63;

    font: inherit;
}

.controls select:focus {
    outline: 3px solid
        rgba(47, 102, 232, 0.2);

    border-color: #2f66e8;
}

.btn-container {
    width: min(900px, 92vw);
    margin: 24px auto;

    display: flex;
    justify-content: center;
}

#start-btn {
    width: min(420px, 100%);
    min-height: 64px;

    padding: 14px 24px;

    border: none;
    border-radius: 16px;

    color: white;
    background: #16a85a;

    font: inherit;
    font-size:
        clamp(20px, 2.5vw, 28px);

    font-weight: bold;

    cursor: pointer;

    box-shadow:
        0 6px 0
        rgba(0, 0, 0, 0.18);

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

#start-btn:hover {
    transform: translateY(-2px);

    box-shadow:
        0 8px 0
        rgba(0, 0, 0, 0.18);
}

#start-btn:active {
    transform: translateY(3px);

    box-shadow:
        0 3px 0
        rgba(0, 0, 0, 0.18);
}

#image-wrapper{
    position:relative;
    width:100%;
    max-width: 400px;
    aspect-ratio: 4/3;
    margin:auto;
}

#quiz-image{
    width:100%;
    height:100%;
    object-fit:contain;
}

#cover-grid{
    position:absolute;
    inset:0;

    display:grid;
    grid-template-columns:repeat(6,1fr);
    grid-template-rows:repeat(6,1fr);
}

.cover-cell{
    padding: 0;
    appearance: none;
    background:green;
    border:1px solid white;
    cursor:pointer;
    transition: opacity 0.3s;
}

.hidden{
    display: none;
}

.cover-hidden{
    
    opacity: 0;
    pointer-events: none;
    
}

#game-area{
    text-align:center;
    margin-top:30px;
}

#answer-buttons{
    display:flex;
    gap:20px;
    justify-content:center;
    margin-top:20px;
}

.answer-btn{
    padding:15px 25px;
    font-size:20px;
    cursor:pointer;

    transition:
    transform .3s,
    box-shadow .3s;
}

.correct{

    transform:scale(1.5);

    box-shadow:
    0 0 15px yellow,
    0 0 30px yellow,
    0 0 50px gold;
}

.wrong{
    opacity:.8;
}

#selectedItemsList {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fill,
            minmax(100px, 1fr)
        );
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;

}

.preview-item {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    border-radius: 8px;

}

.preview-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto 5px;

}

.selectable-preview-item {
    position: relative;
    width: 100%;
    font: inherit;
    color: inherit;
    cursor: pointer;
    background: white;
    transition:
        border-color 0.2s,
        background-color 0.2s,
        transform 0.2s;
}

.selectable-preview-item:hover {
    border-color: #2f66e8;
    transform: translateY(-2px);
}

.selectable-preview-item.selected-item {
    border: 3px solid #18a957;
    background: #eafaf0;
}

.selectable-preview-item.selected-item::after {
    content: "✓";
    position: absolute;
    top: 6px;
    right: 8px;
    color: white;
    background: #18a957;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: bold;
}

#specific-selection-controls {
    margin-bottom: 16px;

    text-align: center;
}

#specific-selection-controls p {
    margin: 0 0 14px;

    color: #172b63;

    font-size:
        clamp(16px, 1.8vw, 20px);

    font-weight: bold;
}

.specific-selection-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.specific-selection-buttons button {
    min-width: 150px;
    padding: 10px 18px;

    border: none;
    border-radius: 12px;

    color: white;

    font: inherit;
    font-size: 17px;
    font-weight: bold;

    cursor: pointer;
}

#select-all-items-btn {
    background: #2563eb;
}

#clear-selected-items-btn {
    background: #ef4444;
}

.specific-selection-buttons button:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
}

@media (max-width: 768px){

    .controls{

        flex-direction:column;

        gap:15px;

    }

}

@media (max-width:768px){

    #start-btn{

        width:100%;

        font-size:24px;

    }

    .btn-container{

        flex-direction:column;

        gap:10px;

    }

}

@media (max-width:768px){

    #answer-buttons{

        flex-direction:column;

        align-items:center;

    }

    .answer-btn{

        width:90%;

    }

}

@media (max-width:768px){

    .preview-item img{

        width:60px;

        height:60px;

    }

}

.selected{
    background: #4caf50;
    color: white;
}

#tagsContainer {

    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(120px, 1fr)
        );

    gap: 8px;

    padding: 10px;

    border: 1px solid #ddd;

    border-radius: 8px;

    background: #f9f9f9;

    max-height: 200px;

    overflow-y: auto;

}

#tagsContainer label {

    display: flex;

    align-items: center;

    gap: 6px;

    padding: 6px;

    border: 1px solid #ddd;

    border-radius: 6px;

    background: white;

    cursor: pointer;

}

#tagsContainer label:hover {

    background: #eef7ff;

    border-color: #4da3ff;

}

#play-again-btn{

    margin-top:20px;

    padding:12px 25px;

    font-size:22px;

    background:#4CAF50;

    color:white;

    border:none;

    border-radius:8px;

    cursor:pointer;

}

#play-again-btn:hover{

    background:#388E3C;

}

.answer-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(40%);
}

.answer-btn:not(:disabled) {
    cursor: pointer;
}

.answer-btn {
    min-width: 180px;
    padding: 15px 25px;
    border: 3px solid transparent;
    border-radius: 14px;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;

    box-shadow:
        0 5px 0 rgba(0, 0, 0, 0.2);

    transition:
        transform 0.2s,
        box-shadow 0.2s,
        background-color 0.2s;
}

.answer-btn:nth-child(1) {
    background: #2f66e8;
}

.answer-btn:nth-child(2) {
    background: #8b4de8;
}

.answer-btn:nth-child(3) {
    background: #f47b20;
}

.answer-btn:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 0 rgba(0, 0, 0, 0.2);
}

.answer-btn.correct {
    background: #18a957;
    border-color: #0d7c3c;
    transform: scale(1.08);

    box-shadow:
        0 0 15px #8cffad,
        0 0 30px #18a957;
}

.answer-btn.wrong {
    background: #e63c3c;
    border-color: #ad2020;
    opacity: 0.85;
}

#item-selection-mode-control {
    margin: 0;
    padding: 20px;

    display: flex;
    flex-direction: column;
    gap: 14px;

    border: 3px solid #b8d0ff;
    border-radius: 16px;

    background: #f5f9ff;
}

#item-selection-mode-control legend {
    padding: 0 10px;

    color: #172b63;

    font-size:
        clamp(19px, 2.2vw, 26px);

    font-weight: bold;
}

#item-selection-mode-control > label {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: fit-content;
    cursor: pointer;
}

#item-selection-mode-control
input[type="radio"] {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0;
}

#item-selection-mode-control > label {
    padding: 10px 12px;

    border: 2px solid #d7e4ff;
    border-radius: 12px;

    background: white;
}

#item-selection-mode-control > label:hover {
    border-color: #2f66e8;
    background: #eef5ff;
}

#random-item-count-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 5px;
}

#selectedItemsContainer {
    width: min(900px, 92vw);
    margin: 24px auto;
    padding: clamp(18px, 3vw, 28px);

    border: 4px solid #ffae2b;
    border-radius: 24px;

    background:
        rgba(255, 249, 232, 0.97);

    box-shadow:
        0 10px 24px
        rgba(255, 174, 43, 0.16);
}

#selectedItemsContainer > h3 {
    margin: 0 0 16px;

    color: #172b63;

    text-align: center;

    font-size:
        clamp(20px, 2.5vw, 28px);
}

.preview-item {
    min-width: 0;
    padding: 10px;

    border: 3px solid #b8d0ff;
    border-radius: 14px;

    background: #eef5ff;

    color: #172b63;

    text-align: center;
    font-weight: bold;

    overflow-wrap: anywhere;
}

.preview-item img {
    width: 80px;
    height: 80px;

    object-fit: contain;

    display: block;

    margin: 0 auto 7px;

    border-radius: 8px;

    background: white;
}

body.play-mode .resource-guide {
    display: none;
}

#setup-page .resource-guide {
    width: min(1100px, 92vw);

    margin: 44px auto 0;
    padding: clamp(24px, 4vw, 40px);

    color: #172b63;
    background:
        rgba(255, 255, 255, 0.96);

    border: 4px solid #2f66e8;
    border-radius: 24px;

    box-sizing: border-box;

    box-shadow:
        0 10px 24px
        rgba(47, 102, 232, 0.15);
}

#setup-page .resource-guide-heading {
    max-width: 820px;
    margin: 0 auto 28px;

    text-align: center;
}

#setup-page .resource-guide-heading h2 {
    margin: 0 0 14px;

    color: #2f66e8;

    font-size:
        clamp(26px, 3.4vw, 42px);
}

#setup-page .resource-guide-heading p {
    margin: 0;

    color: #34466f;

    font-size:
        clamp(17px, 1.8vw, 21px);

    line-height: 1.65;
}

#setup-page .resource-guide-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 20px;
}

#setup-page .resource-guide-grid article {
    padding: 22px;

    background: #eef5ff;

    border: 3px solid #b8d0ff;
    border-radius: 18px;
}

#setup-page
.resource-guide-grid article:nth-child(2) {
    background: #fff9e8;
    border-color: #ffd27a;
}

#setup-page .resource-guide-grid h3 {
    margin: 0 0 12px;

    color: #172b63;

    font-size:
        clamp(20px, 2vw, 25px);
}

#setup-page .resource-guide-grid p,
#setup-page .resource-guide-grid li {
    color: #405176;

    font-size: 17px;
    line-height: 1.55;
}

#setup-page .resource-guide-grid ul,
#setup-page .resource-guide-grid ol {
    margin: 0;
    padding-left: 24px;
}

#setup-page .resource-guide-grid li + li {
    margin-top: 8px;
}

@media (max-width: 700px) {
    #setup-page .resource-guide-grid {
        grid-template-columns: 1fr;
    }
}

body.play-mode {
    min-height: 100vh;
    margin: 0;
    background-attachment: fixed;
}

.play-mode #game-area {
    min-height: 100vh;
    margin: 0;
    padding: clamp(12px, 2vw, 30px);
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(12px, 2vh, 24px);
}

.play-mode .mode-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.play-mode .mode-buttons h3 {
    width: 100%;
    margin: 0;
}

.play-mode .mode-buttons button,
.play-mode #start-play-btn {
    padding: 12px 24px;
    border: 2px solid #21428f;
    border-radius: 12px;
    color: white;
    background: #2f66e8;
    font-size: clamp(16px, 2vw, 22px);
    font-weight: bold;
    cursor: pointer;
}

.play-mode .mode-buttons button {
    color: white;
    background: #888f9b;
    border-color: #656b75;
}

.play-mode .mode-buttons button.selected {
    background: #2f66e8;
    border-color: #21428f;
}

.play-mode #start-play-btn {
    background: #18a957;
    border-color: #0d7c3c;
}

.play-mode #image-wrapper {
    width: min(90vw, 900px);
    height: min(58vh, 650px);
    max-width: none;
    margin: 0;
    aspect-ratio: auto;
}

.play-mode #answer-buttons {
    width: min(90vw, 900px);
    margin: 0;
    flex-wrap: wrap;
}

.play-mode #score-display {
    margin: 0;
    font-size: clamp(24px, 4vw, 42px);
    font-weight: bold;
}

.play-mode #start-play-btn.reset-game {
    background: #e63c3c;
    border-color: #ad2020;
}

.start-game-message {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    color: #17275c;
    background: rgba(255, 255, 255, 0.92);
    border: 4px solid #2f66e8;
    border-radius: 18px;
}

.start-game-message h2,
.start-game-message p {
    margin: 8px 0;
}

.image-error-message {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    color: #7a2020;
    background: #fff1f1;
    border: 4px solid #e63c3c;
    border-radius: 18px;
}

.play-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.play-mode #close-game-btn {
    padding: 12px 24px;
    border: 2px solid #555b65;
    border-radius: 12px;
    color: white;
    background: #777e89;
    font-size: clamp(16px, 2vw, 22px);
    font-weight: bold;
    cursor: pointer;
}

.cover-cell:focus-visible,
.answer-btn:focus-visible,
.mode-buttons button:focus-visible,
.play-controls button:focus-visible {
    outline: 4px solid #ffd43b;
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .play-mode #image-wrapper {
        width: 94vw;
        height: 48vh;
    }

    .play-mode #answer-buttons {
        width: 94vw;
        gap: 10px;
    }

    .play-mode .answer-btn {
        width: 100%;
        min-width: 0;
    }
}