.game-area {
    position: relative;
    margin: 0 auto;
    padding: clamp(10px, 2vmin, 18px);
}

#siteHeader {
    position: relative;
    z-index: 1200;
}

#canvasDiv {
    position: relative;
    margin: 0 auto;
    --adjusted-width: 430px;
    border-radius: calc(var(--adjusted-width) * 0.014);
    overflow: hidden;
    box-shadow: 0 0 calc(var(--adjusted-width) * 0.028) rgba(0, 0, 0, 0.4);
}

#GameCanvas {
    outline: none;
}

.thisScore {
    display: block;
    position: relative;
    margin: 0;
    width: 100%;
    font-size: clamp(32px, calc(var(--adjusted-width) * 0.18), 78px);
    line-height: 1;
    text-align: center;
    color: #FFF;
    letter-spacing: 0;
}

#GameEndScoreScreen {
    display: none;
    position: absolute;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 900;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 999;
    box-sizing: border-box;
    text-align: center;
    overflow: hidden;
}

#GameEndScoreContent {
    position: absolute;
    display: flex;
    width: min(86%, calc(var(--adjusted-width) * 0.86));
    height: 100%;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: calc(var(--adjusted-width) * 0.385) clamp(7px, calc(var(--adjusted-width) * 0.06), 28px) 0;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
}

#GameEndScoreScreen .score-title {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 600;
    margin: calc(var(--adjusted-width) * 0.084) auto 0;
    padding-bottom: clamp(3px, calc(var(--adjusted-width) * 0.028), 11px);
    border-bottom: clamp(1px, calc(var(--adjusted-width) * 0.01), 5px) solid #FFF;
    color:#FFF;
    font-size: clamp(9px, calc(var(--adjusted-width) * 0.079), 34px);
    line-height: 1;
    width: min(64%, calc(var(--adjusted-width) * 0.44));
}

#GameEndScoreScreen .game-over-title {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 900;
    margin: 0;
    padding-bottom: 0;
    color:#fff;
    font-size: clamp(14px, calc(var(--adjusted-width) * 0.126), 54px);
    line-height: 1.06;
    white-space: nowrap;
}

#splash {
    position: absolute;
    inset: 3px;
    border-radius: clamp(1.5px, 0.7vmin, 12px);
    background-size: 100%;
	background-color: #FFD59D;
}

#NextFruitWrap {
    display: none;
    position: absolute;
    width: calc(var(--adjusted-width) * 0.27);
    height: calc(var(--adjusted-width) * 0.125);
    background-color: rgba(255,255,255,0.5);
    top: calc(var(--adjusted-width) * 0.233);
    left: 0;
    z-index: 900;
    border-radius: calc(var(--adjusted-width) * 0.058);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

#NextFruit {
    display: flex;
    padding: 0 calc(var(--adjusted-width) * 0.022);
    height: 100%;
    align-items: center;
    gap: calc(var(--adjusted-width) * 0.018);
}

#NextFruit::before {
    content: 'Next';
    font-size: calc(var(--adjusted-width) * 0.034);
    font-weight: 900;
    color: #506155;
    line-height: 1;
}

#NextFruit .next-item {
    width: calc(var(--adjusted-width) * 0.082);
    height: calc(var(--adjusted-width) * 0.082);
    flex: 0 0 auto;
}

#NextFruit img {
    display: block;
    width: 100%;
    height: auto;
}

#SwapFruitButton {
    display: none;
    position: absolute;
    /* Keep the visible peak glow below the game-over bar, including hover lift. */
    top: calc(var(--adjusted-width) * 0.276);
    /* Let the visible peak glow meet the canvas edge. */
    right: calc(var(--adjusted-width) * 0.042);
    z-index: 910;
    width: calc(var(--adjusted-width) * 0.16);
    height: calc(var(--adjusted-width) * 0.16);
    margin: 0;
    padding: 0;
    border: calc(var(--adjusted-width) * 0.007) solid rgba(255, 255, 255, 0.95);
    border-radius: calc(var(--adjusted-width) * 0.038);
    background: linear-gradient(145deg, rgba(255, 207, 57, 0.96), rgba(255, 177, 18, 0.94));
    box-shadow:
        0 calc(var(--adjusted-width) * 0.018) 0 rgba(191, 113, 0, 0.72),
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.6);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

#SwapFruitButton:hover {
    filter: brightness(1.05);
    transform: translateY(calc(var(--adjusted-width) * -0.004));
}

#SwapFruitButton::before {
    content: '';
    position: absolute;
    /* Anchor the inner edge at the rim; only the outer light expands. */
    inset: 0;
    z-index: -1;
    border-radius: calc(var(--adjusted-width) * 0.031);
    box-shadow: 0 0 calc(var(--adjusted-width) * var(--swap-glow-blur, 0.016)) calc(var(--adjusted-width) * var(--swap-glow-spread, 0.018)) #fff9e6;
    opacity: 0;
    pointer-events: none;
}

#SwapFruitButton.swap-fruit--available::before {
    opacity: var(--swap-glow-opacity, 0.10);
}

#SwapFruitButton:active {
    transform: translateY(calc(var(--adjusted-width) * 0.005)) scale(0.97);
    box-shadow:
        0 calc(var(--adjusted-width) * 0.008) 0 rgba(191, 113, 0, 0.72),
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.5);
}

/* Override both normal and pressed shadows while the glow is visible.
   Remove them immediately on activation so they never fade through the glow. */
#SwapFruitButton.swap-fruit--available {
    box-shadow: none;
    transition: transform 0.14s ease, filter 0.14s ease;
}

.swap-fruit-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 88%;
    height: 88%;
    object-fit: contain;
    pointer-events: none;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 calc(var(--adjusted-width) * 0.003) calc(var(--adjusted-width) * 0.006) rgba(0, 0, 0, 0.24));
}

.swap-popup__cta-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: calc(var(--adjusted-width) * 0.014) solid transparent;
    border-bottom: calc(var(--adjusted-width) * 0.014) solid transparent;
    border-left: calc(var(--adjusted-width) * 0.022) solid currentColor;
}

.swap-popup {
    position: absolute;
    inset: 0;
    z-index: 980;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--adjusted-width) * 0.05);
    box-sizing: border-box;
    background: radial-gradient(circle at top, rgba(255, 207, 57, 0.12), rgba(56, 32, 0, 0.04));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease;
    backdrop-filter: blur(calc(var(--adjusted-width) * 0.012)) saturate(112%);
    -webkit-backdrop-filter: blur(calc(var(--adjusted-width) * 0.012)) saturate(112%);
}

.swap-popup--visible {
    opacity: 1;
    pointer-events: auto;
}

.swap-popup__content {
    width: calc(var(--adjusted-width) * 0.88);
}

.swap-popup__panel {
    display: flex;
    min-height: calc(var(--adjusted-width) * 0.76);
    padding: calc(var(--adjusted-width) * 0.052) calc(var(--adjusted-width) * 0.065);
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: calc(var(--adjusted-width) * 0.012) solid rgba(255, 255, 255, 0.9);
    border-radius: calc(var(--adjusted-width) * 0.13);
    background: linear-gradient(180deg, #ffc400 0%, #ffb700 100%);
    box-shadow:
        0 calc(var(--adjusted-width) * 0.035) calc(var(--adjusted-width) * 0.055) rgba(96, 60, 0, 0.28),
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.48);
    color: #ffffff;
    font-family: 'Noto Sans JP', 'Outfit', sans-serif;
    text-align: center;
    backdrop-filter: blur(calc(var(--adjusted-width) * 0.016)) saturate(116%);
    -webkit-backdrop-filter: blur(calc(var(--adjusted-width) * 0.016)) saturate(116%);
}

.swap-popup__visual {
    position: relative;
    width: calc(var(--adjusted-width) * 0.46);
    aspect-ratio: 1 / 1;
    margin: 0 auto calc(var(--adjusted-width) * 0.006);
}

.swap-popup__icon {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 calc(var(--adjusted-width) * 0.005) calc(var(--adjusted-width) * 0.012) rgba(0, 0, 0, 0.24));
}

.swap-popup__copy {
    margin: calc(var(--adjusted-width) * 0.026) 0 calc(var(--adjusted-width) * 0.052);
    color: #ffffff;
    font-size: calc(var(--adjusted-width) * 0.046);
    font-weight: 800;
    line-height: 1.55;
    letter-spacing: 0;
    text-shadow: 0 calc(var(--adjusted-width) * 0.004) calc(var(--adjusted-width) * 0.006) rgba(128, 76, 0, 0.42);
}

.swap-popup__cta {
    display: inline-flex;
    position: relative;
    width: calc(var(--adjusted-width) * 0.68);
    min-height: calc(var(--adjusted-width) * 0.11);
    align-items: center;
    justify-content: center;
    border: calc(var(--adjusted-width) * 0.008) solid #ffffff;
    border-radius: calc(var(--adjusted-width) * 1);
    background: linear-gradient(180deg, #1686f4 0%, #0b72dd 100%);
    box-shadow:
        0 calc(var(--adjusted-width) * 0.014) 0 #0759b7,
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font: inherit;
    font-size: calc(var(--adjusted-width) * 0.047);
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.swap-popup__cta-label {
    display: block;
}

.swap-popup__cta-cooldown {
    display: none;
    position: absolute;
    top: 50%;
    right: calc(var(--adjusted-width) * 0.055);
    font-size: calc(var(--adjusted-width) * 0.041);
    font-weight: 900;
    line-height: 1;
    transform: translateY(-50%);
}

.swap-popup__cta-cooldown--visible {
    display: inline;
}

.swap-popup__cta:not(:disabled):hover {
    filter: brightness(1.06);
    transform: translateY(calc(var(--adjusted-width) * -0.003));
}

.swap-popup__cta:disabled {
    cursor: default;
    filter: saturate(0.82) brightness(0.94);
    transform: none;
}

.swap-popup__cta:not(:disabled):active {
    transform: translateY(calc(var(--adjusted-width) * 0.005)) scale(0.98);
    box-shadow:
        0 calc(var(--adjusted-width) * 0.003) 0 #0755bc,
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.3);
}

.swap-popup__cta-icon {
    position: absolute;
    top: 50%;
    left: calc(var(--adjusted-width) * 0.074);
    color: #ffffff;
    transform: translateY(-50%);
}

.swap-popup__close {
    position: relative;
    align-self: flex-start;
    width: calc(var(--adjusted-width) * 0.095);
    height: calc(var(--adjusted-width) * 0.095);
    margin: calc(var(--adjusted-width) * 0.035) 0 0 calc(var(--adjusted-width) * 0.012);
    padding: 0;
    border: calc(var(--adjusted-width) * 0.003) solid rgba(255, 255, 255, 0.65);
    border-radius: calc(var(--adjusted-width) * 0.032);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.24), rgba(201, 126, 0, 0.16));
    box-shadow:
        0 calc(var(--adjusted-width) * 0.01) calc(var(--adjusted-width) * 0.02) rgba(104, 63, 0, 0.18),
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.34);
    color: #ffffff;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.swap-popup__close:hover,
.swap-popup__close:focus-visible {
    transform: translateY(calc(var(--adjusted-width) * -0.003));
    border-color: rgba(255, 255, 255, 0.92);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(230, 150, 12, 0.24));
}

.swap-popup__close:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 calc(var(--adjusted-width) * 0.008) rgba(38, 108, 255, 0.25),
        0 calc(var(--adjusted-width) * 0.01) calc(var(--adjusted-width) * 0.02) rgba(104, 63, 0, 0.18),
        inset 0 calc(var(--adjusted-width) * 0.003) 0 rgba(255, 255, 255, 0.34);
}

.swap-popup__close:active {
    transform: translateY(calc(var(--adjusted-width) * 0.003)) scale(0.97);
}

.swap-popup__close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42%;
    height: 42%;
    transform: translate(-50%, -50%);
}

.swap-popup__close-icon::before,
.swap-popup__close-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    border-top: calc(var(--adjusted-width) * 0.006) solid currentColor;
    filter: drop-shadow(0 calc(var(--adjusted-width) * 0.003) 0 rgba(11, 99, 216, 0.55));
    transform-origin: center;
}

.swap-popup__close-icon::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.swap-popup__close-icon::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

#restartButton {
    display: inline-flex;
    position: relative;
    z-index: 999;
    margin: calc(var(--adjusted-width) * 0.174) auto 0;
    width: clamp(52px, calc(var(--adjusted-width) * 0.18), 78px);
    height: clamp(52px, calc(var(--adjusted-width) * 0.18), 78px);
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: clamp(2px, calc(var(--adjusted-width) * 0.008), 3px) solid rgba(255, 255, 255, 0.95);
    background: radial-gradient(circle at 30% 30%, #8be6ff 0%, #5ab3ff 45%, #3f86ea 100%);
    box-shadow:
        0 clamp(2px, calc(var(--adjusted-width) * 0.02), 8px) 0 #2d5ea8,
        0 clamp(5px, calc(var(--adjusted-width) * 0.04), 16px) clamp(6px, calc(var(--adjusted-width) * 0.052), 20px) rgba(0, 0, 0, 0.38);
    color: #fff;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

#restartButton:hover {
    filter: brightness(1.06);
    transform: translateY(calc(var(--adjusted-width) * -0.0048));
}

#restartButton:active {
    transition-duration: 0s;
    transform: translateY(calc(var(--adjusted-width) * 0.008)) scale(0.98);
    filter: brightness(0.92);
    box-shadow:
        0 clamp(1px, calc(var(--adjusted-width) * 0.003), 1.5px) 0 #2d5ea8,
        0 clamp(1px, calc(var(--adjusted-width) * 0.006), 3px) clamp(2px, calc(var(--adjusted-width) * 0.012), 5px) rgba(0, 0, 0, 0.3);
}

#restartButton .restart-icon {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    font-size: clamp(28px, calc(var(--adjusted-width) * 0.092), 40px);
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 clamp(0.5px, calc(var(--adjusted-width) * 0.005), 2px) clamp(0.75px, calc(var(--adjusted-width) * 0.007), 3px) rgba(0, 0, 0, 0.25);
}

#ThisGameScoreResult {
    display: flex;
    margin: calc(var(--adjusted-width) * 0.174) auto 0;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
}

#block-Box {
    display: block;
    width: 100%;
    height: 100%;
}

#loadingText {
    display: none;
    position: absolute;
    width: 100%;
    text-align: center;
    top: 45%;
    z-index: 2;
    font-size: clamp(20px, 7vmin, 76px);
    color:#506155;
}

#loadingImg {
    position: absolute;
    width: 100%;
    top: 45%;
}
