/* =========================================================
   RESONANCE BINGO — v4
   legacy red/green + new supernatural cards
   ========================================================= */

.res-bingo-source {
    display: none;
}

.res-bingo-card {
    --bingo-blue: #4f879a;
    --bingo-accent: #ca8462;
    --bingo-paper: #fffaf6;
    --bingo-text: #66534a;

    position: relative;
    isolation: isolate;
    width: min(600px, 100%);
    margin: 24px auto;
    padding: 24px 22px 20px;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 28px;

    background:
        radial-gradient(circle at 18% 10%, rgba(255,255,255,.30), transparent 28%),
        linear-gradient(135deg, #eaded3 0%, #f1e6dc 50%, #eadfd5 100%);

    box-shadow:
        0 15px 35px rgba(77,58,44,.16),
        0 4px 10px rgba(77,58,44,.08),
        inset 0 0 0 1px rgba(255,255,255,.45);

    color: var(--bingo-text);
}

.res-bingo-red       { --bingo-accent: #ca8462; }
.res-bingo-green     { --bingo-accent: #7f978a; }
.res-bingo-vampire   { --bingo-accent: #9f5e59; }
.res-bingo-werewolf  { --bingo-accent: #8a745f; }
.res-bingo-god       { --bingo-accent: #b28c51; }
.res-bingo-witch     { --bingo-accent: #897792; }
.res-bingo-hunter    { --bingo-accent: #667f91; }
.res-bingo-possessed { --bingo-accent: #687775; }

.res-bingo-card *,
.res-bingo-card *::before,
.res-bingo-card *::after {
    box-sizing: border-box;
}

/* noise */
.res-bingo-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    opacity: .13;
    mix-blend-mode: multiply;
    border-radius: inherit;

    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.34'/%3E%3C/svg%3E");
}

/* decor */
.res-bingo-blob {
    position: absolute;
    width: 110px;
    height: 105px;
    top: -58px;
    right: -17px;
    z-index: 0;
    border: 9px solid rgba(255,255,255,.88);
    border-radius: 43% 57% 48% 52% / 56% 44% 56% 44%;
    transform: rotate(14deg);
    pointer-events: none;
}

.res-bingo-lines {
    position: absolute;
    z-index: 0;
    border: 2px solid rgba(201,139,99,.58);
    border-radius: 50%;
    pointer-events: none;
}

.res-bingo-lines::before,
.res-bingo-lines::after {
    content: "";
    position: absolute;
    border: 2px solid rgba(201,139,99,.58);
    border-radius: 50%;
}

.res-bingo-lines.top {
    width: 310px;
    height: 310px;
    top: -235px;
    left: 250px;
}

.res-bingo-lines.top::before { inset: 18px; }
.res-bingo-lines.top::after  { inset: 36px; }

.res-bingo-lines.right {
    width: 360px;
    height: 360px;
    top: 130px;
    right: -287px;
}

.res-bingo-lines.right::before { inset: 18px; }
.res-bingo-lines.right::after  { inset: 36px; }

.res-bingo-triangles {
    position: absolute;
    width: 80px;
    height: 100px;
    top: 18px;
    left: 26px;
    z-index: 1;
    pointer-events: none;
}

.res-bingo-triangles::before {
    content: "";
    position: absolute;
    top: 0;
    left: 17px;
    width: 0;
    height: 0;
    border-left: 24px solid transparent;
    border-right: 24px solid transparent;
    border-bottom: 55px solid #cf946d;
    transform: rotate(35deg);
}

.res-bingo-triangles::after {
    content: "";
    position: absolute;
    top: 54px;
    left: 5px;
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-bottom: 40px solid #cf946d;
    transform: rotate(82deg);
}

/* header */
.res-bingo-head {
    position: relative;
    z-index: 3;
    width: 89%;
    min-height: 108px;
    margin: 3px auto 28px;
    padding: 20px 35px;
    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(135deg, rgba(255,255,255,.99), rgba(255,252,248,.96));

    border-radius: 48% 52% 48% 52% / 47% 44% 56% 53%;
    box-shadow: 0 6px 16px rgba(90,68,50,.07);
}

.res-bingo-head::after {
    content: "";
    position: absolute;
    inset: 9px;
    border: 1.5px dashed var(--bingo-blue);
    border-radius: inherit;
    pointer-events: none;
}

.res-bingo-title {
    position: relative;
    z-index: 2;
    margin: 0;
    font-family: var(--font-accent);
    font-size: 42px;
    font-weight: normal;
    line-height: 1;
    text-align: center;
    text-transform: none;
    color: var(--bingo-accent);
}

/* grid */
.res-bingo-grid {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    overflow: hidden;
    border: 1.5px solid var(--bingo-blue);
    border-radius: 18px;
    background: var(--bingo-paper);

    box-shadow:
        0 7px 18px rgba(74,61,52,.08),
        inset 0 0 0 1px rgba(255,255,255,.55);
}

.res-bingo-card .res-bingo-cell {
    appearance: none;
    position: relative;
    width: 100%;
    min-width: 0;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 14px 10px;

    border: 0 !important;
    border-right: 1.5px solid var(--bingo-blue) !important;
    border-bottom: 1.5px solid var(--bingo-blue) !important;
    border-radius: 0 !important;
    outline: 0;

    background:
        linear-gradient(135deg, rgba(255,255,255,.72), rgba(255,250,246,.94)) !important;

    color: var(--bingo-text) !important;
    text-align: center;
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: none !important;

    transition:
        background .15s ease,
        color .15s ease;
}

.res-bingo-card .res-bingo-cell:nth-child(4n) {
    border-right: 0 !important;
}

.res-bingo-card .res-bingo-cell:nth-child(n+13) {
    border-bottom: 0 !important;
}

.res-bingo-card .res-bingo-cell:hover {
    background:
        linear-gradient(135deg, #fbf1ea, #f8eee7) !important;
}

.res-bingo-card .res-bingo-cell span {
    position: relative;
    z-index: 3;
}

/* marker */
.res-bingo-card .res-bingo-cell:not(.is-free)::before {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 15px;
    height: 15px;
    z-index: 5;
    border: 1.5px solid var(--bingo-accent) !important;
    border-radius: 50%;
    background: #fffaf6 !important;
    box-shadow: 0 1px 3px rgba(83,61,46,.10) !important;
}

/* selected */
.res-bingo-card .res-bingo-cell.is-selected:not(.is-free) {
    background:
        linear-gradient(135deg, #f9efe9, #f5e7de) !important;
    color: #604d45 !important;
}

.res-bingo-card .res-bingo-cell.is-selected:not(.is-free)::before {
    background: var(--bingo-accent) !important;
    border-color: var(--bingo-accent) !important;
    box-shadow:
        inset 0 0 0 3px #f8eee8,
        0 1px 4px rgba(99,64,46,.14) !important;
}

/* hand-drawn double oval */
.res-bingo-card .res-bingo-cell.is-selected:not(.is-free) span {
    display: inline-block;
    position: relative;
    z-index: 4;
    padding: 8px 10px;
}

.res-bingo-card .res-bingo-cell.is-selected:not(.is-free) span::before,
.res-bingo-card .res-bingo-cell.is-selected:not(.is-free) span::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    pointer-events: none;
    z-index: -1;
}

.res-bingo-card .res-bingo-cell.is-selected:not(.is-free) span::before {
    width: calc(100% + 18px);
    height: calc(100% + 14px);
    transform: translate(-50%, -50%) rotate(-7deg);
    border: 2px solid var(--bingo-accent);
    border-radius: 58% 42% 55% 45% / 46% 58% 42% 54%;
    opacity: .78;
}

.res-bingo-card .res-bingo-cell.is-selected:not(.is-free) span::after {
    width: calc(100% + 24px);
    height: calc(100% + 18px);
    transform: translate(-50%, -50%) rotate(6deg);
    border: 1.5px solid var(--bingo-accent);
    border-radius: 46% 54% 43% 57% / 57% 41% 59% 43%;
    opacity: .48;
}

/* legacy FREE */
.res-bingo-card .res-bingo-cell.is-free {
    cursor: default;

    background:
        radial-gradient(circle at center, rgba(202,132,98,.11), rgba(255,250,246,1) 70%) !important;

    color: var(--bingo-accent) !important;
}

.res-bingo-card .res-bingo-cell.is-free span {
    display: block;
    font-family: var(--font-accent) !important;
    font-size: 36px !important;
    font-weight: normal !important;
    line-height: 1 !important;
    text-transform: uppercase;
    white-space: nowrap;
    color: inherit !important;
    transform: rotate(-10deg);
}

/* controls */
.res-bingo-controls {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.res-bingo-count {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #786a60;
}

.res-bingo-actions {
    display: flex;
    gap: 7px;
}

.res-bingo-button {
    appearance: none;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid var(--bingo-blue);
    border-radius: 18px;
    background: rgba(255,255,255,.88);
    color: var(--bingo-blue);
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: normal;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(72,58,48,.07);

    transition:
        background .15s ease,
        color .15s ease,
        transform .15s ease,
        box-shadow .15s ease;
}

.res-bingo-button:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 5px 10px rgba(72,58,48,.10);
}

.res-bingo-button.publish {
    background: var(--bingo-blue);
    color: #fff;
}

/* switcher */
.res-bingo-switcher {
    width: min(600px, 100%);
    margin: 0 auto 11px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.res-bingo-switcher-btn {
    --switch-accent: #8e796c;
    appearance: none;
    padding: 7px 15px;
    border: 1px solid var(--switch-accent);
    border-radius: 17px;
    background: rgba(255,255,255,.90);
    color: var(--switch-accent);
    font-family: var(--font-accent);
    font-size: 13px;
    font-weight: normal;
    cursor: pointer;
    box-shadow: 0 3px 7px rgba(72,58,48,.06);

    transition:
        background .15s ease,
        color .15s ease,
        border-color .15s ease,
        transform .15s ease;
}

.res-bingo-switcher-btn[data-bingo-type="red"]       { --switch-accent: #ca8462; }
.res-bingo-switcher-btn[data-bingo-type="green"]     { --switch-accent: #7f978a; }
.res-bingo-switcher-btn[data-bingo-type="vampire"]   { --switch-accent: #9f5e59; }
.res-bingo-switcher-btn[data-bingo-type="werewolf"]  { --switch-accent: #8a745f; }
.res-bingo-switcher-btn[data-bingo-type="god"]       { --switch-accent: #b28c51; }
.res-bingo-switcher-btn[data-bingo-type="witch"]     { --switch-accent: #897792; }
.res-bingo-switcher-btn[data-bingo-type="hunter"]    { --switch-accent: #667f91; }
.res-bingo-switcher-btn[data-bingo-type="possessed"] { --switch-accent: #687775; }

.res-bingo-switcher-btn:hover {
    background: #fff;
    transform: translateY(-1px);
}

.res-bingo-switcher-btn.active {
    background: var(--switch-accent);
    border-color: var(--switch-accent);
    color: #fff;
}

.res-bingo-card.is-hidden {
    display: none !important;
}

/* published result */
.res-bingo-card.is-result {
    margin-top: 18px;
    margin-bottom: 18px;
}

.res-bingo-card.is-result .res-bingo-cell {
    cursor: default;
}

.res-bingo-card.is-result .res-bingo-controls {
    display: none !important;
}

@media (max-width: 620px) {
    .res-bingo-card {
        width: 100%;
        padding: 18px 10px 15px;
        border-radius: 20px;
    }

    .res-bingo-head {
        width: 94%;
        min-height: 86px;
        margin-bottom: 18px;
        padding: 15px 20px;
    }

    .res-bingo-title {
        font-size: 31px;
    }

    .res-bingo-grid {
        border-radius: 13px;
    }

    .res-bingo-card .res-bingo-cell {
        padding: 7px 5px;
        font-size: 9px;
        line-height: 1.12;
    }

    .res-bingo-card .res-bingo-cell:not(.is-free)::before {
        width: 11px;
        height: 11px;
        top: 5px;
        right: 5px;
    }

    .res-bingo-card .res-bingo-cell.is-free span {
        font-size: 25px !important;
    }

    .res-bingo-card .res-bingo-cell.is-selected:not(.is-free) span {
        padding: 4px 5px;
    }

    .res-bingo-controls {
        flex-direction: column;
    }
}

/* =========================================================
   LONG WORDS / HASHTAGS FIX
   ========================================================= */

.res-bingo-card .res-bingo-cell {
    min-width: 0;
}

.res-bingo-card .res-bingo-cell span {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

