@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

.ggb-app {
    --gg-blue: #6781c3;
    --gg-blue-dark: #445e9e;
    --gg-orange: #c96b3c;
    --gg-cream: #f5ead8;
    --gg-paper: #fffaf1;
    --gg-ink: #34323a;
    --gg-sage: #9eaa7d;
    --gg-gold: #d7a84d;
    --gg-shadow: rgba(49, 44, 58, 0.18);
    position: relative;
    width: 100%;
    max-width: 1040px;
    margin: 24px auto;
    color: var(--gg-ink);
    font-family: 'Poppins', sans-serif;
}

.ggb-app * { box-sizing: border-box; }

.ggb-shell {
    position: relative;
    overflow: hidden;
    padding: clamp(18px, 4vw, 38px);
    background:
        radial-gradient(circle at 18% 10%, rgba(201,107,60,.10), transparent 27%),
        radial-gradient(circle at 88% 16%, rgba(103,129,195,.14), transparent 28%),
        linear-gradient(180deg, #fffaf1 0%, #f5ead8 100%);
    border: 3px solid var(--gg-blue);
    border-radius: 28px;
    box-shadow: 0 18px 42px var(--gg-shadow), inset 0 0 0 7px rgba(255,255,255,.48);
}

.ggb-shell::before,
.ggb-shell::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 18px;
    opacity: .9;
    background: repeating-linear-gradient(90deg,
        var(--gg-blue) 0 26px,
        var(--gg-orange) 26px 52px,
        var(--gg-gold) 52px 78px,
        var(--gg-sage) 78px 104px
    );
    transform: rotate(-7deg);
    pointer-events: none;
}
.ggb-shell::before { top: 18px; left: -55px; }
.ggb-shell::after { right: -55px; bottom: 22px; transform: rotate(-7deg); }

.ggb-header {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
}

.ggb-logo {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: conic-gradient(from -40deg, var(--gg-orange), var(--gg-gold), var(--gg-sage), var(--gg-blue), var(--gg-orange));
    border: 5px solid var(--gg-paper);
    box-shadow: 0 5px 0 rgba(68,94,158,.22), 0 9px 18px rgba(52,50,58,.15);
}
.ggb-logo span {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--gg-paper);
    color: var(--gg-blue-dark);
    font-family: 'Fredoka', sans-serif;
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -1px;
}

.ggb-kicker {
    margin: 0 0 3px;
    color: var(--gg-orange);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.ggb-title {
    margin: 0;
    color: var(--gg-blue-dark);
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(30px, 5vw, 52px);
    line-height: 1;
    letter-spacing: -.025em;
}
.ggb-subtitle { margin: 7px 0 0; font-size: 15px; color: #5b5863; }

.ggb-set-badge {
    max-width: 180px;
    padding: 9px 13px;
    color: #fffaf3;
    background: var(--gg-orange);
    border-radius: 9px;
    box-shadow: 3px 3px 0 rgba(91,55,36,.15);
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    text-align: center;
    transform: rotate(1deg);
}

.ggb-instructions {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 15px;
    padding: 10px 14px;
    background: rgba(255,255,255,.58);
    border: 1px dashed rgba(68,94,158,.42);
    border-radius: 12px;
    font-size: 13px;
}

.ggb-board-wrap {
    position: relative;
    z-index: 1;
    padding: clamp(9px, 2vw, 16px);
    background: rgba(255,255,255,.74);
    border: 2px solid rgba(68,94,158,.44);
    border-radius: 21px;
    box-shadow: inset 0 0 0 5px rgba(103,129,195,.08);
}

.ggb-letter-row,
.ggb-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(5px, 1vw, 10px);
}
.ggb-letter-row { margin-bottom: 8px; }
.ggb-letter-row span {
    display: grid;
    place-items: center;
    min-height: 42px;
    border-radius: 10px;
    color: var(--gg-paper);
    background: var(--gg-blue-dark);
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(22px, 3.5vw, 36px);
    font-weight: 700;
    box-shadow: 0 4px 0 rgba(49,44,58,.17);
}
.ggb-letter-row span:nth-child(2) { background: var(--gg-orange); }
.ggb-letter-row span:nth-child(3) { background: var(--gg-gold); color: #4a3a17; }
.ggb-letter-row span:nth-child(4) { background: var(--gg-sage); color: #27301d; }
.ggb-letter-row span:nth-child(5) { background: var(--gg-blue); }

.ggb-square {
    position: relative;
    display: grid;
    align-items: center;
    justify-items: stretch;
    min-height: clamp(82px, 13vw, 132px);
    padding: clamp(7px, 1.4vw, 13px);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(68,94,158,.54);
    border-radius: 13px;
    background: #fffaf1;
    color: var(--gg-ink);
    box-shadow: 0 4px 0 rgba(68,94,158,.14);
    font-family: 'Poppins', sans-serif;
    font-size: clamp(10px, 1.55vw, 15px);
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    transition: transform .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.ggb-square:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(68,94,158,.18); }
.ggb-square:focus-visible { outline: 4px solid rgba(201,107,60,.35); outline-offset: 2px; }
.ggb-square:nth-child(4n+2) { background: #eef2fb; }
.ggb-square:nth-child(4n+3) { background: #f7e7dc; }
.ggb-square:nth-child(4n+4) { background: #f0f1df; }

.ggb-square.is-marked {
    color: #fffaf3;
    background: var(--gg-blue-dark);
    border-color: var(--gg-blue-dark);
    box-shadow: inset 0 0 0 3px rgba(255,255,255,.22), 0 4px 0 rgba(49,44,58,.20);
    transform: scale(.985);
}
.ggb-square.is-marked::after {
    content: '★';
    position: absolute;
    right: 7px;
    top: 4px;
    color: var(--gg-gold);
    font-size: 18px;
}
.ggb-square.is-free {
    color: #fffaf3;
    background:
        radial-gradient(circle at 30% 25%, rgba(255,255,255,.26), transparent 24%),
        var(--gg-orange);
    border-color: #a94e26;
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(12px, 1.8vw, 17px);
    white-space: pre-line;
}
.ggb-square.is-winning {
    animation: ggbWinning 1s ease-in-out infinite alternate;
    box-shadow: 0 0 0 4px var(--gg-gold), 0 0 24px rgba(215,168,77,.55);
}

.ggb-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}
.ggb-button {
    appearance: none;
    border: 2px solid var(--gg-blue);
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
    color: var(--gg-blue-dark);
    background: var(--gg-paper);
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    box-shadow: 0 4px 0 rgba(68,94,158,.18);
    transition: transform .13s ease, box-shadow .13s ease;
}
.ggb-button:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(68,94,158,.18); }
.ggb-button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(68,94,158,.18); }
.ggb-button-primary { color: #fffaf3; background: var(--gg-orange); border-color: #a95029; }

.ggb-status { margin: 12px 0 0; text-align: center; color: #696571; font-size: 13px; }
.ggb-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 17px;
    padding-top: 13px;
    border-top: 1px dashed rgba(68,94,158,.35);
    color: #696571;
    font-size: 12px;
}

.ggb-celebration {
    position: fixed;
    z-index: 999999;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(35,31,44,.55);
    backdrop-filter: blur(5px);
}
.ggb-celebration[hidden] { display: none; }
.ggb-modal {
    position: relative;
    width: min(440px, 94vw);
    padding: 32px 28px 28px;
    overflow: hidden;
    text-align: center;
    background: var(--gg-paper);
    border: 4px solid var(--gg-blue);
    border-radius: 28px;
    box-shadow: 0 22px 70px rgba(0,0,0,.28), inset 0 0 0 7px rgba(201,107,60,.12);
    animation: ggbModalIn .35s cubic-bezier(.2,.9,.25,1.2);
}
.ggb-modal h3 {
    margin: 0;
    color: var(--gg-orange);
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(54px, 13vw, 86px);
    line-height: .95;
    text-shadow: 3px 3px 0 rgba(68,94,158,.18);
}
.ggb-modal p { margin: 12px 0 20px; font-weight: 600; }
.ggb-modal-stars { color: var(--gg-gold); font-size: 26px; letter-spacing: 10px; }
.ggb-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ggb-confetti i { position: absolute; top: -10vh; width: 10px; height: 18px; animation: ggbFall linear forwards; }

.ggb-error { padding: 16px; border-left: 5px solid #c96b3c; background: #fff4ee; }

@keyframes ggbWinning { from { transform: scale(.98); } to { transform: scale(1.03); } }
@keyframes ggbModalIn { from { opacity: 0; transform: scale(.75) rotate(-2deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes ggbFall { to { transform: translate3d(var(--drift), 115vh, 0) rotate(740deg); } }

@media (max-width: 760px) {
    .ggb-app { margin: 10px auto; }
    .ggb-shell { padding: 16px 10px 20px; border-radius: 20px; }
    .ggb-header { grid-template-columns: auto 1fr; gap: 10px; }
    .ggb-logo { width: 60px; height: 60px; border-width: 4px; }
    .ggb-logo span { width: 42px; height: 42px; font-size: 20px; }
    .ggb-set-badge { grid-column: 1 / -1; justify-self: start; max-width: none; font-size: 12px; padding: 6px 10px; }
    .ggb-kicker { font-size: 9px; }
    .ggb-title { font-size: clamp(27px, 8vw, 40px); }
    .ggb-subtitle { font-size: 12px; }
    .ggb-instructions { display: block; font-size: 11px; }
    .ggb-instructions span { display: block; }
    .ggb-board-wrap { padding: 6px; border-radius: 14px; }
    .ggb-letter-row, .ggb-board { gap: 4px; }
    .ggb-letter-row { margin-bottom: 4px; }
    .ggb-letter-row span { min-height: 32px; border-radius: 7px; font-size: 21px; }
    .ggb-square { min-height: 76px; padding: 5px 3px; border-radius: 8px; border-width: 1px; font-size: clamp(8px, 2.55vw, 11px); }
    .ggb-square.is-free { font-size: 10px; }
    .ggb-actions { gap: 7px; }
    .ggb-button { padding: 9px 12px; font-size: 12px; }
    .ggb-footer { display: block; text-align: center; }
    .ggb-footer span { display: block; }
}

@media (prefers-reduced-motion: reduce) {
    .ggb-app *, .ggb-app *::before, .ggb-app *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Version 1.1 polish */
.ggb-header {
    display: block;
    margin-bottom: 18px;
}
.ggb-header-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(42, 45, 57, .16);
}
.ggb-header-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 12px;
}
.ggb-header-details .ggb-subtitle {
    margin: 0;
}
.ggb-header-details .ggb-set-badge {
    flex: 0 0 auto;
    transform: none;
}
.ggb-square {
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    white-space: normal !important;
    text-wrap: balance;
}
.ggb-square.is-long {
    font-size: clamp(9px, 1.35vw, 13px);
    line-height: 1.2;
}
.ggb-square.is-very-long {
    font-size: clamp(8px, 1.15vw, 11px);
    line-height: 1.15;
}

@media (max-width: 760px) {
    .ggb-header { display: block; }
    .ggb-header-image { border-radius: 10px; }
    .ggb-header-details { align-items: flex-start; margin-top: 9px; }
    .ggb-header-details .ggb-subtitle { font-size: 11px; }
    .ggb-header-details .ggb-set-badge { grid-column: auto; justify-self: auto; font-size: 10px; }
    .ggb-square.is-long { font-size: clamp(7.5px, 2.2vw, 9.5px); }
    .ggb-square.is-very-long { font-size: clamp(7px, 2vw, 8.5px); }
}


/* Version 1.2 compact header and tighter app layout */
.ggb-app {
    margin: 12px auto;
}

.ggb-shell {
    padding: clamp(14px, 2.5vw, 24px);
}

.ggb-header {
    margin-bottom: 10px;
}

/* The uploaded artwork includes generous canvas space. This crops it to the banner itself. */
.ggb-header-image {
    width: 100%;
    aspect-ratio: 5.15 / 1;
    height: auto;
    object-fit: cover;
    object-position: center 54%;
    border-radius: 12px;
    box-shadow: 0 5px 14px rgba(42, 45, 57, .14);
}

.ggb-header-details {
    margin-top: 8px;
}

.ggb-instructions {
    margin-bottom: 10px;
    padding: 8px 12px;
}

.ggb-board-wrap {
    padding: clamp(8px, 1.5vw, 12px);
}

.ggb-actions {
    margin-top: 12px;
}

.ggb-footer {
    margin-top: 12px;
    padding-top: 10px;
}

@media (max-width: 760px) {
    .ggb-app { margin: 6px auto; }
    .ggb-shell { padding: 10px; border-radius: 18px; }
    .ggb-header-image {
        aspect-ratio: 4.35 / 1;
        object-position: center 54%;
        border-radius: 8px;
    }
    .ggb-header-details {
        margin-top: 6px;
        gap: 8px;
    }
    .ggb-instructions {
        margin-bottom: 8px;
        padding: 7px 9px;
    }
}

/* Version 1.3: compact app layout with the artwork outside the card */
.ggb-app {
    max-width: 1040px;
    margin: 10px auto 22px;
}

.ggb-header {
    display: block;
    width: min(100%, 980px);
    margin: 0 auto 10px;
    padding: 0;
}

.ggb-header-image {
    display: block;
    width: 100%;
    aspect-ratio: 4.25 / 1;
    object-fit: cover;
    object-position: center 50%;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 5px 14px rgba(42, 45, 57, .13);
}

.ggb-shell {
    padding: clamp(12px, 2vw, 20px);
    border-radius: 22px;
}

.ggb-shell::before,
.ggb-shell::after {
    width: 150px;
    height: 12px;
    opacity: .72;
}

.ggb-shell::before { top: 10px; left: -42px; }
.ggb-shell::after { right: -42px; bottom: 12px; }

.ggb-header-details {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 9px;
}

.ggb-header-details .ggb-subtitle {
    margin: 0;
    font-size: 14px;
}

.ggb-header-details .ggb-set-badge {
    max-width: 190px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 13px;
    transform: none;
}

.ggb-instructions {
    margin: 0 0 9px;
    padding: 8px 12px;
}

.ggb-board-wrap {
    padding: clamp(7px, 1.25vw, 11px);
}

.ggb-actions { margin-top: 11px; }
.ggb-status { margin-top: 9px; }
.ggb-footer { margin-top: 10px; padding-top: 9px; }

@media (max-width: 760px) {
    .ggb-app { margin: 6px auto 14px; }
    .ggb-header { width: 100%; margin-bottom: 7px; }
    .ggb-header-image {
        aspect-ratio: 4.15 / 1;
        object-position: center 50%;
        border-radius: 8px;
    }
    .ggb-shell { padding: 9px; border-radius: 17px; }
    .ggb-header-details {
        margin-bottom: 7px;
        gap: 7px;
        align-items: center;
    }
    .ggb-header-details .ggb-subtitle { font-size: 10.5px; line-height: 1.25; }
    .ggb-header-details .ggb-set-badge {
        max-width: 135px;
        padding: 5px 7px;
        font-size: 9.5px;
        line-height: 1.2;
    }
    .ggb-instructions { padding: 6px 8px; margin-bottom: 7px; }
}
