* {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    min-height: 100vh;
    margin: 0;

    font-family:
        "Comic Sans MS",
        "Comic Sans",
        Arial,
        sans-serif;

    color: #17275c;

    background:
        url("../../images/home/kcgbackground.png")
        center / cover fixed,
        #eef4ff;
}

button,
input,
select {
    font: inherit;
}

.page-header {
    padding: 28px 16px 12px;
    text-align: center;
}

.page-header h1 {
    margin: 0;
    color: #2358d5;
    font-size: clamp(34px, 6vw, 64px);
}

.page-header p {
    margin: 10px 0 0;
    color: #26355f;
    font-size: clamp(17px, 2.5vw, 24px);
    font-weight: bold;
}

main {
    width: min(1000px, calc(100% - 28px));
    margin: 0 auto;
    padding: 20px 0 50px;
}

.view-panel {
    padding: clamp(22px, 4vw, 42px);

    text-align: center;

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

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

    box-shadow:
        0 12px 30px
        rgba(30, 64, 175, 0.18);
}

.view-panel h2 {
    margin-top: 0;
    font-size: clamp(25px, 4vw, 40px);
}

.role-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
}

#role-selection-view .resource-guide {
    margin-top: 38px;
    padding-top: 34px;

    border-top: 3px solid #bfd2ff;
}

#role-selection-view
.resource-guide-heading {
    max-width: 800px;
    margin: 0 auto 28px;
}

#role-selection-view
.resource-guide-heading h2 {
    margin: 0 0 14px;

    color: #2358d5;

    font-size:
        clamp(25px, 3.4vw, 38px);
}

#role-selection-view
.resource-guide-heading p {
    margin: 0;

    color: #34466f;

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

    line-height: 1.6;
}

#role-selection-view
.resource-guide-grid {
    display: grid;

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

    gap: 18px;

    text-align: left;
}

#role-selection-view
.resource-guide-grid article {
    padding: 20px;

    background: #eef5ff;

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

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

#role-selection-view
.resource-guide-grid article:nth-child(3) {
    background: #ecfdf3;
    border-color: #9de5ba;
}

#role-selection-view
.resource-guide-grid h3 {
    margin: 0 0 12px;

    color: #17275c;

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

    text-align: center;
}

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

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

#role-selection-view
.resource-guide-grid ul,
#role-selection-view
.resource-guide-grid ol {
    margin: 0;
    padding-left: 23px;
}

#role-selection-view
.resource-guide-grid li + li {
    margin-top: 7px;
}

button {
    padding: 13px 24px;

    border: 3px solid transparent;
    border-radius: 14px;

    font-weight: bold;
    cursor: pointer;

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

button:hover {
    transform: translateY(-2px);

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

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 4px solid #ffd43b;
    outline-offset: 3px;
}

.primary-btn {
    color: white;
    background: #18a957;
    border-color: #0d7c3c;
}

.secondary-btn {
    color: white;
    background: #2f66e8;
    border-color: #21428f;
}

.back-btn {
    margin-top: 24px;

    color: #26355f;
    background: #e5e9f2;
    border-color: #9aa4b5;
}

#join-game-form {
    width: min(500px, 100%);
    margin: 0 auto;

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

    text-align: left;
}

#join-game-form label {
    margin-top: 8px;
    font-size: 18px;
    font-weight: bold;
}

#join-game-form input {
    width: 100%;
    padding: 13px;

    border: 3px solid #b9cffb;
    border-radius: 12px;

    background: white;
    font-size: 18px;
}

#room-code-input {
    text-transform: uppercase;
    letter-spacing: 5px;
    font-weight: bold;
}

#join-game-form button {
    margin-top: 12px;
}

.page-message {
    min-height: 28px;
    margin: 18px 0 0;

    text-align: center;
    font-size: 18px;
    font-weight: bold;
}

.page-message.error {
    color: #c62828;
}

.page-message.success {
    color: #12813e;
}

#teacher-setup-form {
    display: flex;
    flex-direction: column;
    gap: 22px;

    text-align: left;
}

.setup-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setup-control > label,
#game-settings > label,
#random-pool-count-control > label {
    font-size: 18px;
    font-weight: bold;
}

.setup-control input,
.setup-control select,
#game-settings select,
#random-pool-count-control select {
    width: 100%;
    padding: 12px;

    border: 3px solid #b9cffb;
    border-radius: 12px;

    color: #17275c;
    background: white;
}

#teacher-item-mode,
#game-settings {
    display: flex;
    flex-direction: column;
    gap: 14px;

    padding: 20px;

    border: 3px solid #b9cffb;
    border-radius: 16px;
}

#teacher-item-mode legend,
#game-settings legend {
    padding: 0 8px;

    color: #2358d5;
    font-size: 21px;
    font-weight: bold;
}

#teacher-item-mode > label,
#game-settings
label:has(input[type="checkbox"]) {
    width: fit-content;

    display: flex;
    align-items: center;
    gap: 10px;

    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
}

#teacher-item-mode
input[type="radio"],
#game-settings
input[type="checkbox"] {
    width: 21px;
    height: 21px;
    margin: 0;
}

#random-pool-count-control {
    display: flex;
    flex-direction: column;
    gap: 7px;

    margin-top: 5px;
}

#tags-container {
    max-height: 220px;
    padding: 12px;

    display: grid;
    grid-template-columns:
        repeat(
            auto-fill,
            minmax(130px, 1fr)
        );
    gap: 8px;

    overflow-y: auto;

    background: #f7f9ff;
    border: 2px solid #d5e2ff;
    border-radius: 14px;
}

#tags-container label {
    padding: 8px;

    display: flex;
    align-items: center;
    gap: 7px;

    background: white;
    border: 2px solid #d5e2ff;
    border-radius: 10px;

    cursor: pointer;
}

#specific-pool-controls {
    padding: 16px;

    background: #eef7ff;
    border: 2px solid #b9cffb;
    border-radius: 14px;
}

#specific-pool-controls p {
    margin-top: 0;
    font-weight: bold;
}

.selection-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.selection-buttons .back-btn {
    margin-top: 0;
}

#available-items-section {
    padding: 16px;

    background: #f7f9ff;
    border: 3px solid #b9cffb;
    border-radius: 16px;
}

#available-items-section h3 {
    margin-top: 0;
    text-align: center;
}

#available-items-list {
    max-height: 430px;
    padding: 10px;

    display: grid;
    grid-template-columns:
        repeat(
            auto-fill,
            minmax(125px, 1fr)
        );
    gap: 12px;

    overflow-y: auto;
}

.bingo-item-preview {
    position: relative;

    min-height: 150px;
    padding: 10px;

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

    color: #17275c;
    background: white;
    border: 3px solid #d5e2ff;
    border-radius: 14px;

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

.bingo-item-preview img {
    width: 90px;
    height: 90px;
    object-fit: contain;
}

.bingo-item-preview.selectable {
    width: 100%;
    cursor: pointer;
}

.bingo-item-preview.selected {
    background: #eafaf0;
    border-color: #18a957;
}

.bingo-item-preview.selected::after {
    content: "✓";

    position: absolute;
    top: 6px;
    right: 7px;

    width: 28px;
    height: 28px;

    display: grid;
    place-items: center;

    color: white;
    background: #18a957;
    border-radius: 50%;
}

#create-room-btn {
    width: min(420px, 100%);
    margin: 0 auto;

    font-size: 22px;
}

.picker {
    margin-top: 24px;
    padding: 24px;
    border: 3px solid #2f67e8;
    border-radius: 22px;
    background: white;
    text-align: center;
}

.picker-items {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fill,
            minmax(130px, 1fr)
        );
    gap: 12px;
    max-height: 45vh;
    margin-bottom: 20px;
    padding: 14px;
    overflow-y: auto;
    border: 2px solid #cfe0ff;
    border-radius: 16px;
    background: #f7faff;
}

.picker-item {
    min-height: 90px;
    padding: 12px;
    border: 3px solid transparent;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: bold;
    text-align: center;
    color: #14275e;
    overflow: hidden;

transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background-color 0.12s ease,
    box-shadow 0.12s ease;
}

.picker-item span {
    display: block;
    width: 100%;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.picker-item img {
    width: 100%;
    height: 80px;
    object-fit: contain;
}

/* Larger teacher item window with responsive cards */
#teacher-picker-items {
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(90px, 1fr)
        );

    min-height: 50vh;
    max-height: 65vh;
    gap: clamp(6px, 1vw, 12px);
    padding: clamp(8px, 1.5vw, 14px);
}

#teacher-picker-items .picker-item {
    min-height: clamp(75px, 11vh, 115px);
    padding: clamp(6px, 1vw, 10px);
    gap: 5px;
    font-size: clamp(11px, 1.4vw, 17px);
}

#teacher-picker-items .picker-item img {
    width: 100%;
    height: clamp(45px, 7vh, 80px);
    object-fit: contain;
}

.picker-item.picked {
    border-color: #999;
    background: #d8d8d8 !important;
    color: #666;
    opacity: 0.75;
}

.picker-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 25, 65, 0.82);
}

.picker-modal.hidden {
    display: none;
}

.picker-modal-content {
    position: relative;
    width: min(700px, 92vw);
    max-height: 90vh;
    padding: 40px 28px 28px;
    border: 5px solid #ffbf2f;
    border-radius: 26px;
    overflow-y: auto;
    background: white;
    text-align: center;
}

.picker-modal-close {
    position: absolute;
    top: 8px;
    right: 14px;
    border: none;
    background: transparent;
    color: #d93025;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

#picker-modal-item img {
    width: min(480px, 80vw);
    max-height: 55vh;
    object-fit: contain;
}

#picker-modal-item p {
    margin: 12px 0;
    font-size: clamp(30px, 5vw, 60px);
    font-weight: bold;
}

@media (max-width: 600px) {
    #teacher-item-mode,
    #game-settings,
    #available-items-section {
        padding: 14px;
    }

    #available-items-list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
        padding: 4px;
    }

    .bingo-item-preview {
        min-height: 130px;
        padding: 7px;
    }

    .bingo-item-preview img {
        width: 72px;
        height: 72px;
    }

    .selection-buttons {
        flex-direction: column;
    }

    .selection-buttons button {
        width: 100%;
    }
}

@media (max-width: 600px) {
    main {
        width:
            min(100% - 16px, 1000px);
    }

    .view-panel {
        padding: 20px 14px;
        border-radius: 18px;
    }

    .role-buttons {
        flex-direction: column;
    }

    .role-buttons button {
        width: 100%;
    }
}

.player-room-status {
    margin-bottom: 20px;
    padding: 14px;
    border: 2px solid #9fc0ff;
    border-radius: 14px;
    background: #eef5ff;
    font-weight: bold;
    text-align: center;
}

.player-card-builder {
    display: grid;
    gap: 24px;
}

.player-item-tray-section {
    padding: 18px;
    border: 3px solid #ffb52e;
    border-radius: 20px;
    background: #fff9e8;
    text-align: center;
}

.player-item-tray-section h3,
.player-item-tray-section p {
    margin: 0 0 12px;
}

.player-item-tray {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
    padding: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 2px solid #ffd276;
    border-radius: 14px;
    background: white;
    box-sizing: border-box;
}

.player-tray-item {

    flex: 0 0 120px;
    min-height: 90px;
    padding: 8px;
    border: 3px solid transparent;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #dff1ff;
    color: #14275e;
    font-weight: bold;
    cursor: grab;
}

.player-tray-item.selected {
    border-color: #ff9500;
    background: #fff0b8;
}

.player-tray-item.used {
    opacity: 0.35;
    cursor: not-allowed;
}

.player-tray-item img {
    width: 100%;
    height: 70px;
    object-fit: contain;
}

.player-bingo-grid {
    --bingo-grid-size: 5;

    width: min(760px, 94vw);
    margin: 0 auto;
    display: grid;
    grid-template-columns:
        repeat(
            var(--bingo-grid-size),
            1fr
        );
    gap: clamp(4px, 1vw, 10px);
}

.player-bingo-cell {
    aspect-ratio: 1;
    min-width: 0;
    padding: 6px;
    border: 3px dashed #8eb2ff;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: white;
    color: #14275e;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
}

.player-bingo-cell.marked {
    border-style: solid;
    border-color: #e5a800;
    background: #ffe95c;
    box-shadow:
        0 0 0 4px
        rgba(255, 213, 0, 0.22);
    transform: scale(0.97);
}

.player-bingo-cell img {
    width: 100%;
    height: 65%;
    object-fit: contain;
}

.player-bingo-cell.free {
    border-style: solid;
    border-color: #19a957;
    background: #bdf4ce;
    color: #087333;
}

.player-ready-controls {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

#player-game-view,
#player-game-content,
.player-card-builder,
.player-item-tray-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#player-game-view {
    overflow: hidden;
}

.player-item-tray {
    min-width: 0;
    max-width: 100%;
}

.bingo-celebration {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        rgba(22, 39, 94, 0.82);
}

.bingo-celebration.hidden {
    display: none;
}

.bingo-celebration-content {
    width: min(560px, 92vw);
    padding: 40px 24px;
    border: 6px solid #ffbd21;
    border-radius: 30px;
    background:
        linear-gradient(
            145deg,
            #fff8b8,
            #ffffff,
            #dff4ff
        );
    text-align: center;
    animation:
        bingo-celebration-pop
        0.55s ease-out;
}

.bingo-celebration-content h2 {
    margin: 10px 0;
    color: #e33d2e;
    font-size:
        clamp(58px, 12vw, 110px);
    line-height: 1;
}

.bingo-celebration-content p {
    font-size:
        clamp(20px, 4vw, 32px);
    font-weight: bold;
}

.bingo-stars {
    color: #ffae00;
    font-size:
        clamp(36px, 8vw, 70px);
    animation:
        bingo-stars-bounce
        0.8s ease-in-out infinite
        alternate;
}

.player-bingo-cell.winning {
    border-color: #ff8c00;
    background: #ffd43b;
    box-shadow:
        0 0 18px
        rgba(255, 150, 0, 0.75);
    animation:
        bingo-winning-cell
        0.75s ease-in-out infinite
        alternate;
}

@keyframes bingo-celebration-pop {
    from {
        opacity: 0;
        transform: scale(0.55)
            rotate(-5deg);
    }

    to {
        opacity: 1;
        transform: scale(1)
            rotate(0);
    }
}

@keyframes bingo-stars-bounce {
    from {
        transform: translateY(0)
            scale(1);
    }

    to {
        transform: translateY(-10px)
            scale(1.08);
    }
}

@keyframes bingo-winning-cell {
    from {
        transform: scale(0.96);
    }

    to {
        transform: scale(1.03);
    }
}

@media (max-width: 520px) {
 
    .player-bingo-cell {
        padding: 3px;
        border-width: 2px;
        border-radius: 9px;
        font-size: 11px;
    }
}

.host-finish-controls {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.host-finish-controls.hidden {
    display: none;
}


.host-winners-section {
    margin-top: 24px;
    padding: 20px;
    border: 3px solid #ffb52e;
    border-radius: 20px;
    background: #fff9e8;
}

.host-winners-section h3 {
    margin-top: 0;
}

#host-winners-list {
    display: grid;
    gap: 10px;
    max-height: 180px;
    padding-right: 6px;
    overflow-y: auto;
}

.host-winner-entry {
    padding: 12px 16px;
    border: 2px solid #ffc94f;
    border-radius: 12px;
    background: white;
    color: #14275e;
    font-weight: bold;
}

.host-live-leaders {
    margin-top: 24px;
    padding: 18px;
    border: 3px solid #ffb52e;
    border-radius: 18px;
    background: #fff9e8;
}

.host-live-leaders h3 {
    margin: 0 0 14px;
}

.host-live-leaders-list {
    display: grid;
    gap: 10px;
}

.host-live-leader {
    padding: 12px 16px;
    border: 2px solid;
    border-radius: 12px;
    background: white;
    font-weight: bold;
}

.host-live-leader.place-1 {
    border-color: #d69d00;
    background: #ffe26b;
}

.host-live-leader.place-2 {
    border-color: #9299a3;
    background: #e5e8ed;
}

.host-live-leader.place-3 {
    border-color: #b66b2f;
    background: #f1bd8f;
}

.host-final-results {
    margin-top: 24px;
    padding: clamp(24px, 5vw, 44px);
    border: 5px solid #ffb52e;
    border-radius: 28px;
    background:
        linear-gradient(
            145deg,
            #fff4b8,
            #ffffff,
            #e3f3ff
        );
    text-align: center;
}

.host-final-results h2 {
    margin: 0 0 10px;
    color: #1b3d91;
    font-size:
        clamp(32px, 6vw, 58px);
}

.host-final-message {
    margin-bottom: 24px;
    font-size:
        clamp(18px, 3vw, 28px);
    font-weight: bold;
}

.host-final-standings {
    display: grid;
    gap: 14px;
    width: min(680px, 100%);
    margin: 0 auto;
}

.final-standing {
    padding: 18px;
    border: 3px solid;
    border-radius: 18px;
    font-size:
        clamp(20px, 4vw, 34px);
    font-weight: bold;
}

.final-standing.place-1 {
    border-color: #d69d00;
    background: #ffe26b;
}

.final-standing.place-2 {
    border-color: #9299a3;
    background: #e5e8ed;
}

.final-standing.place-3 {
    border-color: #b66b2f;
    background: #f1bd8f;
}

.final-standing.no-wins {
    border-color: #8eb2ff;
    background: white;
}

.host-qr-container {
    width: fit-content;
    margin: 14px auto;
    padding: 10px;
    border: 3px solid #9dbdff;
    border-radius: 14px;
    background: white;
    cursor: pointer;
}

#host-room-qr {
    width: 96px;
    height: 96px;
    margin: 0 auto;
}

#host-room-qr img,
#host-room-qr canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.host-qr-instruction {
    margin: 6px 0 0;
    font-size: 12px;
    font-weight: bold;
}

.host-qr-container.enlarged {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 20px;
    border: none;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.96);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

.host-qr-container.enlarged #host-room-qr {
    width: min(70vw, 420px);
    height: min(70vw, 420px);
}

.host-qr-container.enlarged .host-qr-instruction {
    margin-top: 18px;
    font-size: clamp(16px, 3vw, 24px);
}

.delete-bingo-set-btn {
    width: fit-content;
    margin-top: 6px;
    color: white;
    background: #e53935;
    border-color: #a91f1c;
}

.delete-bingo-set-btn.hidden {
    display: none;
}

.saved-bingo-set-change-note {
    margin: 4px 0 0;
    padding: 12px;
    border: 2px solid #f0b429;
    border-radius: 10px;
    color: #5f4700;
    background: #fff7d6;
    font-size: 15px;
    font-weight: bold;
}

.saved-bingo-set-change-note.hidden {
    display: none;
}

.share-bingo-set-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 6px;
}

.share-bingo-set-controls.hidden,
.bingo-share-link-container.hidden {
    display: none;
}

.bingo-share-link-container {
    width: 100%;
    display: grid;
    gap: 10px;
}

#bingo-share-link {
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
}

#bingo-share-message {
    min-height: 1.2em;
    margin: 0;
    color: #16843f;
    font-weight: bold;
}

.picker-item-active {
    border-color: #facc15;
    background: #fef08a !important;
    box-shadow:
        0 0 0 4px rgba(250, 204, 21, 0.3);
    transform: scale(1.04);
}

.picker-item-selected {
    border-color: #16a34a;
    background: #bbf7d0 !important;
    box-shadow:
        0 0 0 6px rgba(22, 163, 74, 0.3);
    animation:
        picker-selected-bounce 0.4s ease;
}

@keyframes picker-selected-bounce {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.12);
    }

    100% {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .picker-item-selected {
        animation: none;
    }
}

#save-bingo-set-btn {
    color: white;
    background: #2f66e8;
    border-color: #21428f;
}

#save-bingo-set-btn:disabled {
    background: #9ca9c2;
    border-color: #7c879d;
    cursor: not-allowed;
    opacity: 0.75;
}

.student-privacy-note {
    max-width: 520px;
    margin: 14px auto;
    color: #475569;
    font-size: clamp(13px, 1.5vw, 16px);
    line-height: 1.5;
    text-align: center;
}

.student-privacy-note a {
    color: #1d4ed8;
    font-weight: bold;
}

.student-privacy-note a:hover {
    color: #15803d;
}