body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Source Sans Pro", sans-serif;
    background-color: #fff;
    border-width: 0;

    /* Prevents the bouncing/rubber-band effect globally on iOS and Android */
    overscroll-behavior: none; 
    /* Required for iOS Safari to fully respect overscroll-behavior */
    overflow: hidden; 
}

button,
input,
select,
textarea {
    font-family: inherit;
}

input {
    caret-color: auto;
}

.game-header {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 9999;
    width: 380px;
    max-width: calc(100vw - 10px);
    height: 60px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 0;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 19px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
    touch-action: none;
}
.game-header.hidden {
    display: none;
}

.game-header__inner {
    height: 60px;
    display: flex;
    align-items: center;
}

.game-header__back {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    border-right: 1px solid #eee;
    color: #333;
    text-decoration: none;
}

.game-header__back-icon {
    display: block;
    width: auto;
    height: 24px;
    fill: #222;
}

.game-header__logo {
    height: 40px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding-left: 12px;
    margin: 0;
    text-decoration: none;
}

.game-header__logo-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 40px;
}
.game-header__description {
    height: 28px;
    margin-left: 12px;
    padding-left: 12px;
    margin-right: 12px;
    border-left: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 10px;
    line-height: 11px;
    color: #777;
    white-space: nowrap;
}

.game-header__description span:first-child {
    font-weight: 600;
    color: #444;
}

.game-header__description span:last-child {
    font-weight: 400;
    color: #888;
}


#menu {
    margin: 0;
    position: fixed;
    left: 5px;
    top: 70px;
    color: #333;
    z-index: 10;
    width: max-content;
    max-width: 336px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    touch-action: pan-y;
}
div#menu.hidden {
    top: 5px;
}
#show {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid #e2e2e2;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    color: #333;
    cursor: pointer;
}
#show:hover {
    background: #e5e5e5;
    border-color: #c5c5c5;
}
#show[hidden] {
    display: none;
}

#show svg {
    display: block;
    width: 20px;
    height: auto;
    fill: #333;
}
#organize {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid #e2e2e2;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    color: #333;
    cursor: pointer;
}
#organize:hover {
    background: #e5e5e5;
    border-color: #c5c5c5;
}
#organize[hidden] {
    display: none;
}

#organize svg {
    display: block;
    width: 20px;
    height: auto;
    fill: #333;
}
#download {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid #e2e2e2;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    color: #333;
    cursor: pointer;
}
#download:hover {
    background: #e5e5e5;
    border-color: #c5c5c5;
}
#download[hidden] {
    display: none;
}

#download svg {
    display: block;
    width: 20px;
    height: auto;
    fill: #333;
}


#controls {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 9px 15px;
    height: 38px;
    box-sizing: border-box;
    background: #333;
    color: #fff;
    border: 0;
    border-radius: 100px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
#controls svg {
    width: 16px;
    height: 16px;
    fill: #f4f4f4;
    flex-shrink: 0;
    margin-right: 5px;
    transition: fill 0.15s ease;
}

#controls:hover {
    background: #1a1a1a;
}
#show[hidden] + #controls {
    margin-right: 0;
}

#showhide {
    background-color: rgb(255 255 255);
    border-radius: 19px;
    border: 1px solid #eee;
    padding: 10px 20px 12px 20px;
    position: relative;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    width: 336px;
    max-width: 100%;
    box-sizing: border-box;
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    overflow-y: auto;
    cursor: default;
    touch-action: pan-y;
    overscroll-behavior-y: none; 
    scrollbar-width: none;
}
#showhide::-webkit-scrollbar {
    display: none;
}
#showhide hr{
    border: 0;
    border-top: 1px solid #eee;
    margin: 18px 0;
}
#menu.hidden #showhide {
    display: none;
}
.menu-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: inherit;
    line-height: 0;
    z-index: 10;
}

.menu-close svg {
    width: 16px;
    height: 16px;
    fill: #777;
    display: block;
}

.menu-close:hover {
    opacity: 0.7;
}

#help {
    position: absolute;
    left: 0px;
    top: 0px;
    width: 59px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 0 0 100%;
    background: #3399FF;
    color: #fff;
    cursor: pointer;
    box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.18);
}

#help svg {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    margin-bottom: 5px;
    display: block;
    fill: currentColor;
}

#help:hover {
    background: #1a8af0;
}

/* ================================
DOMINANT GAME TIMER
================================ */
#timer {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 0px 22px;
    color: #222; 
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 1px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* small "TIME" label above the number */
#timer::before {
    content: var(--timer-label, "TIME");
    display: block;
    margin-bottom: 6px;
    color: #929292;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
}

.shared-puzzle-best {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: -14px;
    margin-bottom: 20px;
    padding-bottom: 0px;
    text-transform: uppercase;
    color: #929292;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
}
.shared-puzzle-best[hidden] {
    display: none;
}

.shared-puzzle-trophy {
    width: 19px;
    height: 21px;
}

.shared-puzzle-best-time {
    margin-left: 2px;
    color: #555;
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .3px;
}

.image-upload {
    width: 100%;
    margin-bottom: 30px;
}

#load {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 22px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    background: radial-gradient(circle, #f8f8f8 0%, #ececec 100%);
    border: 1px solid #d3dbe2;
    border-radius: 3px;
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
}
#load svg {
    display: block;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    fill: currentColor;
}

#load:hover {
    background: #f0f0f0;
}

#filename {
    position: relative;
    width: 100%;
    min-height: 32px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 12px 38px 12px 12px;
    color: #777;
    border-bottom: 1px dotted #d3dbe2;
    border-radius: 0px;
    font-size: 14px;
}
.filename-icon {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    margin-right: 7px;
    fill: #555;
}
.filename-share-icon {
    display: none;
}

#filename.is-shared .filename-image-icon {
    display: none;
}

#filename.is-shared .filename-share-icon {
    display: block;
    fill: #3399ff;
}
#filename.is-shared .shared-label{
    color: #3399ff;
    font-weight: 600;
}
#filenameText {
    display: block;
    min-width: 0;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#default {
    position: absolute;
    top: 50%;
    right: 5px;
    width: 26px;
    height: 26px;
    padding: 5px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #555;
    cursor: pointer;
}
#default:disabled {
    display: none;
}

#default svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

#default:hover {
    background: #e9e9e9;
    color: #333;
}
.puzzle-options {
    display: flex;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.puzzle-option {
    flex: 1;
    min-width: 0;
}

.puzzle-option label {
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
    font-weight: 600;
    color: #6d6d6d;
}

.puzzle-option select {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    height: 46px;
    margin: 0;
    border-radius: 3px;
    background: transparent;
    color: #505050;
    border: none;
    outline: none;
    display: inline-block;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    max-width: 100%;
    border: 1px solid #d3dbe2;
    white-space: nowrap;
    font-size: 16px;

    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23aaa' d='M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L224 286.102l154.706-155.578c9.373-9.373 24.569-9.373 33.941 0l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.373-24.569 9.373-33.941 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 10px;
    background-position: right 11px center;
}
.rotation-option {
    flex: 0 0 70px;
}

.game-actions {
    margin-bottom: 12px;
}
#start,
#stop {
    width: 100%;
    height: 46px;
    padding: 0 20px;
    border: 1px solid #333;
    border-radius: 100px;
    background: #333;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: 0.2px;
}
#start:hover,
#stop:hover {
    background-color: #1a1a1a;
    border-color: #1a1a1a;
}
.game-share {
    margin-bottom: 12px;
    border: 1px solid #777;
    border-radius: 23px;
    overflow: hidden;
    position: relative;
}

.game-share.is-expanded {
    border: 1px solid #d3dbe2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
}

.share-toggle{
    width: 100%;
    height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 22px 22px 0 0;
    background: #ffffff;
    color: #333;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease,color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.2px;
}

.share-toggle:hover {
    border-color: #333;
    color: #1a1a1a;
}

#helpshare {
    width: 23px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #3399ff;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.18);
    position: absolute;
    top: 11px;
    right: 11px;
}

#helpshare:hover {
    background: #1a8af0;
}

/* Enlarge clickable area without changing appearance */
#helpshare::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 100px;
}
.share-content{
    padding: 16px 20px 16px 20px;
}

.share-settings {
    margin-bottom: 16px;
}

.share-setting {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.share-setting:last-child {
    margin-bottom: 0;
}


/* Share checkboxes */

.share-setting input {
    appearance: none;
    -webkit-appearance: none;

    width: 18px;
    height: 18px;
    margin: 0;

    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;

    cursor: pointer;
}

.share-setting input:checked {
    background: #3399FF;
    border-color: #3399FF;
}

.share-setting input:checked::after {
    content: "";
    display: block;

    width: 5px;
    height: 9px;
    margin: 1px 0 0 5px;

    border: solid #fff;
    border-width: 0 2px 2px 0;

    transform: rotate(45deg);
}

.share-setting label {
    font-size: 16px;
    color: #333;
    cursor: pointer;
}

.share-setting input:disabled {
    opacity: 0.6;
    cursor: default;
}

.share-setting input:disabled + label {
    opacity: 0.6;
    cursor: default;
}
#createShare {
    width: 100%;
    height: 46px;
    padding: 0 20px;
    border: 1px solid #333;
    border-radius: 100px;
    background: #333;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}
#createShare:hover {
    background-color: #1a1a1a;
    border-color: #1a1a1a;
}
#createShare.enhanced {
    font-size: 0;
}

#createShare.enhanced::after {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4 4L19 7.5' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
#createShare:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#shareResult {
    position: relative;

    width: 100%;
    box-sizing: border-box;

    margin-top: 16px;
    padding: 18px 42px 18px 18px;

    background: #f4f6f7;
    border: 1px dashed #aab2ba;
    border-radius: 10px;

    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.06),
        inset 0 -1px 2px rgba(255, 255, 255, 0.8);

    cursor: pointer;

    transition:
        background-color .15s ease,
        border-color .15s ease;
}

#shareResult:hover {
    background: #fafaf8;
    border-color: #bdbdb9;
}


/* URL */

.share-url {
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: .02em;
    color: #333;

    /*
     * Allows long URLs to wrap instead of overflowing.
     */
    overflow-wrap: anywhere;
    word-break: break-word;

    /*
     * Makes the URL selectable even though
     * the surrounding box is clickable.
     */
    user-select: text;
    -webkit-user-select: text;

    cursor: text;
}


/* Copy button */

#copyShare {
    position: absolute;
    top: 9px;
    right: 9px;

    width: 24px;
    height: 24px;
    padding: 0;

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

    border: 0;
    background: transparent;

    color: #2995F5;
    cursor: pointer;
}


/* Icons */

.share-copy-icon,
.share-check-icon {
    position: absolute;

    width: 17px;
    height: 18px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;

    transition:
        opacity .15s ease,
        transform .15s ease;
}

.share-copy-icon {
    opacity: 1;
    transform: scale(1);
}

.share-check-icon {
    opacity: 0;
    transform: scale(.8);
}


/* Copied state */

#copyShare.is-copied .share-copy-icon {
    opacity: 0;
    transform: scale(.8);
}

#copyShare.is-copied .share-check-icon {
    opacity: 1;
    transform: scale(1);
}

/* Help Privacy */

.privacy-link {
    text-align: center;
    margin-top: 11px;
    margin-bottom: -5px;
}

.privacy-link button {
    padding: 4px 8px;
    border: 0;
    background: none;
    color: #3399ff;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.privacy-link button:hover {
    text-decoration: underline;
}


/* Save / restore area */
.game-storage hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 16px 0 12px !important;
}
.storage-toggle {
    width: 100%;
    height: 34px;
    padding-left: 10px;
    padding-right: 0;

    border: 0;
    background: transparent;

    color: #777;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;

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

    cursor: pointer;
    position: relative;
}

.storage-toggle::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 12px;
    border-right: 1.5px solid #aaa;
    border-bottom: 1.5px solid #aaa;
    transform: translateY(-2px) rotate(45deg); 
    transform-origin: center center;
    transition: transform 0.2s ease;
}

.storage-toggle[aria-expanded="true"]::after {
    transform: translateY(2px) rotate(225deg);
}

.storage-toggle:hover {
    color: #444;
}

.storage-toggle:hover::after {
    border-color: #777;
}
.storage-content{
    padding-top: 12px;
    border-top: 1px solid #e5e8eb;
}

/* Storage / File heading */
.storage-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}
/* Small help buttons beside Storage / File */
.storage-title button {
    width: 23px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #3399ff;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.18);
    position: relative;
}

.storage-title button:hover {
    background: #1a8af0;
}

/* Enlarge clickable area without changing appearance */
.storage-title button::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 100px;
}
/* Save / restore buttons */
.storage-buttons {
    display: flex;
    gap: 8px;
}
.storage-buttons button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d3dbe2;
    border-radius: 100px;
    background: radial-gradient(circle, #f9f9fd 0%, #f4f4f4 100%);
    color: #333;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.storage-buttons button:hover {
    background: #eee;
    border-color: #ccc;
}
.storage-buttons button:disabled {
    opacity: 0.4;
    cursor: default;
}
/* Save name */
.save-name {
    display: block;
    margin-top: 12px;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}
.save-name-input {
    display: flex;
    align-items: center;
    height: 40px;
    margin-top: 7px;
    border: 1px solid #d3dbe2;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}
.save-name-input input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 10px;
    border: 0;
    outline: none;
    background: transparent;
    color: #333;
    font-size: 15px;
}
.save-name-input input:focus {
    box-shadow: inset 0 0 0 1px #3399FF;
    border-radius: 6px 0 0 6px;
}
#saveext {
    padding-right: 10px;
    color: #999;
    font-size: 15px;
}
#menu .center {
    text-align: center;
}
.storage-check {
    display: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #06cbad;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.storage-buttons button.enhanced {
    background: #d2f6f0;
    border-color: #06cbad;
    color: #06cbad;
}
.storage-buttons button.enhanced .storage-label {
    display: none;
}

.storage-buttons button.enhanced .storage-check {
    display: inline-block;
}

#forPuzzle {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;

    width: 100dvw;
    height: 100dvh;
    background: linear-gradient(135deg, #e9e7e1, #dcdad4);
    overflow: hidden;
    cursor: pointer;
}

.moving {
    transition-property: top, left, width, height;
    transition-duration: 1s;
}

.win-shine {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.win-shine::after {
    content: "";
    position: absolute;

    top: -100%;
    left: -80%;

    width: 45%;
    height: 300%;

    background: linear-gradient(
        105deg,
        transparent 15%,
        rgba(255, 255, 255, .08) 35%,
        rgba(255, 255, 255, .85) 50%,
        rgba(255, 255, 255, .08) 65%,
        transparent 85%
    );

    filter: blur(14px);
    transform: rotate(18deg);

    opacity: 0;
}

.win-shine.active::after {
    animation: win-shine 1.5s ease-in-out forwards;
}

@keyframes win-shine {
    from {
        left: -80%;
        opacity: 0;
    }

    20% {
        opacity: .2;
    }

    50% {
        opacity: 0.6;
    }

    80% {
        opacity: .2;
    }

    to {
        left: 140%;
        opacity: 0;
    }
}
/* Soft premium glow + bloom */
img.win-glow {
    box-shadow:
        0 18px 45px rgba(0,0,0,.18),
        0 0 70px rgba(255,248,232,.32),
        0 0 140px rgba(255,255,255,.14);

    animation: win-bloom 1.5s ease-out forwards;
}
@keyframes win-bloom {
    0%, 20% {
        filter: brightness(1) saturate(1);
    }

    50% {
        filter: brightness(1.34) saturate(1.28);
    }

    80% {
        filter: brightness(1.10) saturate(1.08);
    }

    100% {
        filter: brightness(1.035) saturate(1.02);
    }
}

.showimage {
    position: absolute;
    inset: 0;
    z-index: 100;
    /*above #menu */
    display: none;
    background-color: #ffffee99;
    touch-action: none;
}

.showimage img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.puzzle-hidden-image {
    position: absolute;
    inset: 0;

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

    box-sizing: border-box;
    padding: 32px;

    text-align: center;
    color: #555;
    user-select: none;
}

.puzzle-hidden-image-icon {
    width: 64px;
    height: 64px;

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

    margin-bottom: 18px;

    color: #777;
    opacity: 0.55;
}

.puzzle-hidden-image-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.puzzle-hidden-image-title {
    margin: 0 0 7px;

    font-size: 23px;
    line-height: 1.25;
    font-weight: 600;
    color: #444;
}

.puzzle-hidden-image-text {
    max-width: 320px;

    margin: 0;

    font-size: 16px;
    line-height: 1.5;
    color: #777;
}

.puzzle-loading {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px;
    color: #777;
    user-select: none;
}

.puzzle-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #ccc;
    border-top-color: #777;
    border-radius: 50%;
    animation: puzzle-loading-spin 0.8s linear infinite;
}

.puzzle-loading-text {
    font-size: 16px;
    line-height: 1.4;
    font-weight: 500;
}

@keyframes puzzle-loading-spin {
    to { transform: rotate(360deg); }
}

.game-option, .image-upload {
    transition: opacity 0.15s ease;
}

.game-option.is-disabled {
    /*opacity: 0.6;*/
}
.image-upload.is-disabled,
.game-option.is-disabled input,
.game-option.is-disabled select,
.game-option.is-disabled button,
.game-option.is-disabled label {
    cursor: default;
    opacity: 0.6;
}
.image-upload.is-disabled #load{
    cursor: default;
}
.modal {
    width: min(90vw, 500px);
    max-height: 90vh;
    max-height: 90dvh;
    box-sizing: border-box;
    margin: auto;
    padding: 24px;
    border: 1px solid #d3dbe2;
    border-radius: 19px;
    background: #fff;
    color: #333;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    touch-action: pan-y;
    outline: none;
    overscroll-behavior-y: none;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.35);
}
.modal-title {
    font-weight: bold;
    font-size: 1.2em;
    text-align: center;
}
.modal-section {
    font-weight: bold;
    margin-top: 1em;
}
.modal p {
    margin: 0 0 14px;
    line-height: 1.5;
}
.modal p.modal-title {
    margin: 0 0 24px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 22px !important;
    margin-bottom: 0 !important;
}

.modal-buttons button {
    min-width: 125px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid #d3dbe2;
    border-radius: 100px;
    background: radial-gradient(circle, #f9f9fd 0%, #f4f4f4 100%);
    color: #333;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}

.modal-buttons button:hover {
    background: #eee;
    border-color: #ccc;
}
.modal-pause {
    text-align: center;
}
.modal-buttons button.modal-danger {
    background: #fff;
    border-color: #fd456b;
    color: #fd456b;
}

.modal-buttons button.modal-danger:hover {
    background: #fd456b;
    border-color: #fd456b;
    color: #fff;
}

/* =========================================================
WIN POPUP
Same visual language as the normal Modal
========================================================= */

.win-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;

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

    padding: 20px;
    box-sizing: border-box;

    background: rgba(0, 0, 0, 0.35);

    opacity: 0;
    transition: opacity 180ms ease;
    touch-action: pan-y;
}

.win-overlay.active {
    opacity: 1;
}

.win-card {
    width: min(90vw, 500px);
    max-height: 90vh;
    max-height: 90dvh;
    box-sizing: border-box;

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

    padding: 24px;

    border: 1px solid #d3dbe2;
    border-radius: 19px;

    background: #fff;
    color: #121f38;

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

    transform: scale(.85);
    opacity: 0;
    position: relative;
    overflow-y: auto;
    touch-action: pan-y;
    scrollbar-width: none;
    overscroll-behavior-y: none;
}

.win-card::-webkit-scrollbar {
    display: none;
}

.win-overlay.active .win-card {
    animation: win-pop 360ms ease-out forwards;
}
@keyframes win-pop {
    0% {
        transform: scale(.85);
        opacity: 0;
    }

    70% {
        transform: scale(1.03);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}
.win-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: inherit;
    line-height: 0;
    z-index: 10;
}
.win-close svg {
    width: 16px;
    height: 16px;
    fill: #777;
    display: block;
}
.win-celebration {
    position: relative;
    width: 100%;
    max-width: 260px;
    height: 70px;
    flex: 0 0 70px;
    margin: 0 auto;
    margin-bottom: 10px;
}


/* =========================
GREEN CHECK
========================= */

.win-check {
    position: absolute;
    width: 78px;
    height: 78px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.win-check svg {
    width: 100%;
    height: 100%;
    animation: win-check-pop .36s ease-out both;
}


.win-check path {
    fill: none;
    stroke: white;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 70;
}


/* =========================
6 RAYS
========================= */

.ray {
position: absolute;
left: 50%;
top: 50%;
width: 14px;
height: 4px;
margin-left: -7px;
margin-top: -2px;
border-radius: 5px;
background: #7bd8a5;
z-index: 2;
opacity: 0;
animation: ray-pop 0.36s cubic-bezier(0, 0, 0, 1) forwards;
}

.r1 { --r: 0deg;   --d: 51px; }
.r2 { --r: -38deg; --d: 51px; }
.r3 { --r: 38deg;  --d: 51px; }
.r4 { --r: 180deg; --d: 51px; }
.r5 { --r: 142deg; --d: 51px; }
.r6 { --r: -142deg; --d: 51px; }

.confetti {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 11px;
    height: 6px;
    margin: -3px 0 0 -5.5px;
    border-radius: 1px;
    z-index: 4;

    opacity: 0;
    animation: confetti-pop 2.66s cubic-bezier(0, 0, 0, 0.98) forwards;
}

.c1  { --r: -173deg; --spin: -39deg; --d: 141px; background: #4d8cff; width: 11px; height: 5px; }
.c2  { --r: -160deg; --spin: 10deg;  --d: 116px; background: #ffd22e; width: 11px; height: 6px; }
.c3  { --r: -169deg; --spin: -44deg; --d: 76px;  background: #55c98a; width: 11px; height: 6px; }
.c4  { --r: 7deg;   --spin: -32deg;  --d: 94px;  background: #ff7180; width: 11px; height: 5px; }
.c5  { --r: 165deg;  --spin: -40deg; --d: 150px; background: #ffd22e; width: 11px; height: 5px; }
.c6  { --r: 150deg;  --spin: 62deg;  --d: 140px; background: #46b8fc; width: 11px; height: 5px; }
.c7  { --r: 28deg;   --spin: -64deg; --d: 147px; background: #ffd22e; width: 10px; height: 5px; }
.c8  { --r: 172deg;  --spin: 48deg;  --d: 109px; background: #ff7180; width: 12px; height: 6px; }
.c9  { --r: 8deg;    --spin: 41deg;  --d: 144px; background: #55c98a; width: 12px; height: 6px; }
.c10 { --r: 27deg;   --spin: 13deg;   --d: 103px; background: #568bfe; width: 10px; height: 6px; }
.c11 { --r: -24deg;  --spin: -7deg;  --d: 93px; background: #46b8fc; width: 9px;  height: 4px; }
.c12 { --r: -7deg;   --spin: -23deg; --d: 120px; background: #ffd22e; width: 11px; height: 6px; }

/* =========================
ANIMATION
========================= */


@keyframes win-check-pop {
    0% {
        transform: scale(.85);
        opacity: 0;
    }

    70% {
        transform: scale(1.03);
        opacity: 1;
    }

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

@keyframes ray-pop {
    0% {
        opacity: 0;
        transform: rotate(var(--r)) translateX(0) scaleX(0);
    }

    100% {
        opacity: 1;
        transform: rotate(var(--r)) translateX(var(--d)) scaleX(1);
    }
}
@keyframes confetti-pop {
    0% {
        opacity: 0;
        transform: rotate(var(--r)) translateX(0) rotate(-360deg) scale(.2);
    }
    15% {
        opacity: 1;
    }

    100% {
        opacity: 1;
        transform: rotate(var(--r)) translateX(var(--d)) rotate(var(--spin)) scale(1);
    }
}

/* Timer */

.win-time {
    width: 100%;
    padding-bottom: 6px;
    text-align: center;
}

.win-time span {
    display: block;
    margin-top: 6px;

    color: #929292;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
}

.win-time strong {
    display: block;
    color: #121f38;
    font-size: 46px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}
.win-deco {
    width: 25px;
    height: 25px;

    flex: 0 0 auto;

    fill: #f2c94c;
}
/* Title */
.win-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    margin-bottom: 10px;
}
.win-title {
    font-size: 25px;
    letter-spacing: -0.4px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
}

.win-success-text{
    color: #606f8b;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.win-share {
    width: 100%;
    position: relative;
    max-width: 294px;
    margin-bottom: 22px;
    border-radius: 23px;
    border: 1px solid #98e9c1;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
}
.win-share.is-expanded {
    border: 1px solid #d3dbe2;
}

.win-share-toggle {
    width: 100%;
    min-height: 44px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 0;
    border-radius: 100px;
    background: linear-gradient(182deg, #1fc86d, #04ab62);
    color: #FFFFFF;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-align: center;
    cursor: pointer;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.win-share-toggle[aria-expanded="true"] {
    background: #ffffff;
    color: #282b32;
    box-shadow: none;
}

.win-share-champion {
    width: 21px;
    height: 21px;
    flex: 0 0 21px;
}

.win-share-toggle span {
    flex: 1;
}

.win-share-arrow {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    transition: transform .2s ease;
}

.win-share-toggle:hover .win-share-arrow {
    transform: translateX(3px);
}

.win-share-toggle[aria-expanded="true"] .win-share-arrow {
    transform: rotate(90deg);
}

.win-share-toggle:focus-visible {
    outline: 3px solid rgba(41, 149, 245, .35);
    outline-offset: 3px;
}

.win-share-content{
    padding: 16px 20px 16px 20px;
}

.win-share-settings {
    margin-bottom: 16px;
}

.win-share-setting {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.win-share-setting:last-child {
    margin-bottom: 0;
}

/* WIN-Share checkboxes */

.win-share-setting input {
    appearance: none;
    -webkit-appearance: none;

    width: 18px;
    height: 18px;
    margin: 0;

    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;

    cursor: pointer;
}

.win-share-setting input:checked {
    background: #3399FF;
    border-color: #3399FF;
}

.win-share-setting input:checked::after {
    content: "";
    display: block;

    width: 5px;
    height: 9px;
    margin: 1px 0 0 5px;

    border: solid #fff;
    border-width: 0 2px 2px 0;

    transform: rotate(45deg);
}

.win-share-setting label {
    font-size: 16px;
    color: #333;
    cursor: pointer;
}

.win-share-setting input:disabled {
    opacity: 0.6;
    cursor: default;
}

.win-share-setting input:disabled + label {
    opacity: 0.6;
    cursor: default;
}
#winCreateShare {
    width: 100%;
    height: 46px;
    padding: 0 20px;
    border: 1px solid #282b32;
    border-radius: 100px;
    background: #282b32;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}
#winCreateShare:hover {
    background-color: #1a1a1a;
    border-color: #1a1a1a;
}
#winCreateShare.enhanced {
    font-size: 0;
}

#winCreateShare.enhanced::after {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4 4L19 7.5' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
#winCreateShare:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#winShareResult {
    position: relative;

    width: 100%;
    box-sizing: border-box;

    margin-top: 16px;
    padding: 18px 42px 18px 18px;

    border: 1px dashed #aab2ba;
    background: #f4f6f7;
    border-radius: 10px;

    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.06),
        inset 0 -1px 2px rgba(255, 255, 255, 0.8);

    cursor: pointer;

    transition:
        background-color .15s ease,
        border-color .15s ease;
}

#winShareResult:hover {
    background: #fafaf8;
    border-color: #bdbdb9;
}


/* win-URL */

.win-share-url {
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: .02em;
    color: #333;

    /*
     * Allows long URLs to wrap instead of overflowing.
     */
    overflow-wrap: anywhere;
    word-break: break-word;

    /*
     * Makes the URL selectable even though
     * the surrounding box is clickable.
     */
    user-select: text;
    -webkit-user-select: text;

    cursor: text;
}


/* win-Copy button */

#winCopyShare {
    position: absolute;
    top: 9px;
    right: 9px;

    width: 24px;
    height: 24px;
    padding: 0;

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

    border: 0;
    background: transparent;

    color: #2995F5;
    cursor: pointer;
}

/* win-Copied state */

#winCopyShare.is-copied .share-copy-icon {
    opacity: 0;
    transform: scale(.8);
}

#winCopyShare.is-copied .share-check-icon {
    opacity: 1;
    transform: scale(1);
}

.win-or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 300px;
    margin-bottom: 16px;
    color: #7a87a9;
    font-size: 14px;
    height: 14px;
    font-weight: 600;
}

.win-or-divider span {
    flex: 1;
    border-bottom: 1px solid #e3e7f6;
}

.win-or-divider b {
    font-weight: 600;
}

.win-message {
    margin: 0;
    color: #2b3859;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}
/* coupon */
.win-coupon {
    width: 100%;
    max-width: 356px;
    margin: 12px 0 0px;
    padding: 14px 18px;
    border: 1px dashed #c9bff9;
    border-radius: 10px;
    text-align: center;
    box-sizing: border-box;
    background: linear-gradient(135deg, #FFFFFF 0%, #F2F6FF 55%, #EAF1FD 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /*box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06), inset 0 -1px 2px rgba(255, 255, 255, 0.8);
    background: #f7f6ff;*/
}

.win-coupon:hover {
    box-shadow:
        inset 0 1px 2px rgba(23, 47, 88, 0.025),
        0 4px 12px rgba(36, 75, 181, 0.12);
}

.win-coupon:active {
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.045),
        0 2px 8px rgba(0, 0, 0, 0.06);
}
.win-coupon-content {
    position: relative;
    width: 165px;
    padding-left: 88px;
    flex: 0 0 165px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}
.win-coupon-icon {
    position: absolute;
    width: 74px;
    height: 74px;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    overflow: visible;
    pointer-events: none;
}
.win-coupon-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    color: #7b86ab;
}
.win-coupon-discount {
    font-size: 28px;
    line-height: 28px;
    margin-bottom: 4px;
    font-weight: 700;
    color: #081941;
}
.win-coupon-code {
    position:relative;
    padding: 4.5px 14px;
    background: #fff;
    border: 1px solid #dbd8fe;
    color: #081941;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    min-height: 1.3em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.win-coupon-copy,
.win-coupon-check {
    position: absolute;
    top: 0;
    left: calc(100% + 14px);
    width: 17px;
    height: 18px;
    fill: none;
    stroke: #6a4fee;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .15s ease;
}

.win-coupon-copy {
    opacity: 1;
    transform: scale(1);
}

.win-coupon-check {
    opacity: 0;
    transform: scale(.8);
}

.win-coupon-code.is-copied .win-coupon-copy {
    opacity: 0;
    transform: scale(.8);
}

.win-coupon-code.is-copied .win-coupon-check {
    opacity: 1;
    transform: scale(1);
}

/* Buttons */

.win-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 22px;
}

.win-buttons button {
    min-width: 125px;
    height: 40px;
    padding: 0 16px;

    border-radius: 100px;

    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;

    cursor: pointer;
}

/* Primary */

.win-primary {
    border: 1px solid #282b32;
    background: #282b32;
    color: #fff;
}

.win-primary:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
}


/* Secondary */

.win-secondary {
    border: 1px solid #d3dbe2;
    background: radial-gradient(circle, #f9f9fd 0%, #f9fafc 100%);
    color: #4c5a78;
}

.win-secondary:hover {
    background: #eee;
    border-color: #ccc;
}

@media (max-width: 600px) {
    .game-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: none;
        height: 60px;
        padding: 0;
        box-sizing: border-box;
        border-radius: 0;
        border-top: 0;
        border-left: 0;
        border-right: 0;
        z-index: 9999;
    }
    
    #menu {
        top: 65px;
    }
    #help {
        width: 54px;
    }
    #help svg {
        margin-right: 6px;
    }
}