*,
*::before,
*::after {
    box-sizing: border-box;
}

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

    font-family: Arial, Helvetica, sans-serif;
        

    color: #172b63;

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

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);
}

header h1 {
    margin: 0 0 8px;

    color: #2f66e8;

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

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 {
    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;
}

.controls .hidden,
.hidden {
  display: none;
}


#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;

}



#selectedItemsList {
    display: grid;

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

    gap: 12px;

    max-height: 280px;
    overflow-y: auto;

    padding: 14px;

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

    background: white;
}

.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;
}

@media (max-width: 768px){
  
    .preview-item img{

        width:60px;
        height:60px;

    }
}

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

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.btn {
    width: min(420px, 100%);
    min-height: 60px;

    padding: 14px 24px;

    border: none;
    border-radius: 16px;

    color: white;

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

    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;
}

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

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

.btn:active {
    transform: translateY(3px);

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

#generateBtn {
    background: #16a85a;
}

#resetBtn {
    background: #ef4444;
}

#downloadPdfBtn{
  color:white;
  background-color: green;
}

#downloadPdfBtn.downloading{

    background:#888;

    cursor:not-allowed;

    opacity:.8;

}

.flash-card{

    width:100%;
    height: 100%;
    border:2px solid #333;
    border-radius:12px;
    background:white;
    display:flex;
    flex-direction:column;
    justify-content:flex-start;
    align-items:center;
    overflow:hidden;

}

.flash-card img {
    width: 100%;
    height: 0;
    flex: 1;
    object-fit: contain;
    padding: var(--image-padding);
    min-height: 0;
    
}

.flash-card p{

    width:100%;
    margin:0;
    padding:var(--text-padding);
    border-top:2px solid #333;
    text-align:center;
    font-size:var(--text-size);
    font-weight:bold;
    flex-shrink: 0;

}

.flash-card.text-only{

    justify-content:center;

}

.flash-card.text-only p{

    width:90%;

    border-top:none;

    padding:0;

    margin:0;

    text-align:center;

    font-size:var(--word-only-size);

    line-height:1.1;

}

#previewPages{

    display:flex;

    flex-wrap:wrap;

    gap:20px;

    justify-content:center;

}


.preview-page{

    background:white;
    border:1px solid #bbb;
    padding:20px;
    display:grid;
    overflow:hidden;
    box-shadow:0 6px 18px rgba(0,0,0,.15);

}

.preview-page.portrait{

    aspect-ratio:210 / 297;

}

.preview-page.landscape{

    aspect-ratio:297 / 210;

}


.preview-page.layout-1{

    grid-template-columns:1fr;

    grid-template-rows:1fr;

    gap:10mm;

    --text-size:32px;

    --word-only-size:72px;


    --text-padding:16px;

    --image-padding: 18px;

    
}

.preview-page.layout-2{

    grid-template-columns:1fr 1fr;

    grid-template-rows:1fr;

    gap:8mm;

    --text-size:24px;

    --word-only-size:54px;

    --text-padding:12px;

    --image-padding: 14px;


}

.preview-page.layout-4{

    grid-template-columns:1fr 1fr;

    grid-template-rows:1fr 1fr;

    gap:6mm;

    --text-size:18px;

    --word-only-size:42px;


    --text-padding:10px;

    --image-padding: 10px;


}

.preview-page.layout-8{

    grid-template-columns:1fr 1fr;

    grid-template-rows:repeat(4,1fr);

    gap:4mm;

    --text-size:14px;

    --word-only-size:28px;

    --text-padding:8px;

    --image-padding: 6px;


}

.preview-page.layout-16{

    grid-template-columns:repeat(4,1fr);

    grid-template-rows:repeat(4,1fr);

    gap:2mm;

    --text-size:10px;

    --word-only-size:18px;

    --text-padding:4px;

    --image-padding: 2px;
}


.preview-page-group {
    width: min(900px, 95vw);
    margin: 30px auto;
}

.preview-page-group .preview-page {
    width: 100%;
    margin: 0;
}

.preview-page-label {
    margin: 0 0 8px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    color: #555;
}

#twoSidedLoginMessage {
    margin: 8px 0 0;
    padding: 10px 12px;
    color: #7c2d12;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    background: #fff7ed;
    border: 2px solid #fdba74;
    border-radius: 10px;
}

#twoSidedLoginMessage a {
    color: #1d4ed8;
    font-weight: bold;
}

#twoSidedLoginMessage a:hover {
    text-decoration: none;
}

#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);
}

#generatedCardsContainer {
    width: min(1100px, 96vw);
    margin: 30px auto;
    padding: clamp(18px, 3vw, 30px);

    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);
}

#generatedCardsContainer > h3 {
    margin: 0 0 18px;

    color: #172b63;

    text-align: center;

    font-size:
        clamp(22px, 3vw, 32px);
}

#downloadPdfBtn {
    display: block;

    width: min(420px, 100%);
    min-height: 60px;

    margin: 0 auto 24px;
    padding: 14px 24px;

    border: none;
    border-radius: 16px;

    color: white;
    background: #2563eb;

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

    font-weight: bold;

    cursor: pointer;

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

#downloadPdfBtn:hover {
    transform: translateY(-2px);
}

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

    margin: 48px auto;
    padding: clamp(24px, 4vw, 42px);

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

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

    box-sizing: border-box;

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

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

    text-align: center;
}

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

    color: #d97706;

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

.resource-guide-heading p {
    margin: 0;

    color: #34466f;

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

    line-height: 1.65;
}

.resource-guide-grid {
    display: grid;

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

    gap: 20px;
}

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

    background: #fff9e8;

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

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

    color: #172b63;

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

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

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

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

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

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

@media print {
    .resource-guide {
        display: none;
    }
}