* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: linear-gradient(180deg, #87CEEB 0%, #98D89A 60%, #7ab87a 100%);
    font-family: 'Segoe UI', sans-serif;
    user-select: none;
    cursor: none;
    /*touch-action: none;*/
}

#hammerCursor {
    position: fixed;
    width: var(--hammer-size, 56px);
    height: var(--hammer-size, 56px);
    pointer-events: none;
    z-index: 9999;
    transform: translate(
        calc(var(--hammer-size, 56px) * -0.14),
        calc(var(--hammer-size, 56px) * -0.14)
    );
    transition: transform 0.08s;
    display: block !important;
    visibility: visible !important;
}

#hammerCursor.hitting {
    transform: translate(
        calc(var(--hammer-size, 56px) * -0.14),
        calc(var(--hammer-size, 56px) * 0.22)
    ) rotate(35deg);
}

/* ===== スタート画面 ===== */
#startScreen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #87CEEB 0%, #b8e8b8 100%);
    z-index: 100;
    touch-action: manipulation;
}

#startScreen h1 {
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    color: #5a3a1a;
    text-shadow: 0 3px 0 rgba(200,150,80,0.4);
    margin-bottom: 0.4rem;
}

#startScreen .sub {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: #7a5a3a;
    margin-bottom: 2rem;
}

.settings-box {
    background: rgba(255,255,255,0.55);
    border-radius: 24px;
    padding: 1.8rem 2.8rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(100,150,80,0.2);
    margin-bottom: 1.8rem;
    min-width: 340px;
}

.settings-box h2 {
    font-size: 1.05rem;
    color: #5a7a3a;
    margin-bottom: 1.2rem;
    text-align: center;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

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

.setting-row label {
    font-size: 0.95rem;
    color: #5a4a2a;
    white-space: nowrap;
}

.setting-btns {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn,
.size-btn {
    padding: 0.5rem 1.1rem;
    font-size: 0.95rem;
    border: 2.5px solid #aad080;
    border-radius: 30px;
    background: rgba(255,255,255,0.6);
    color: #4a7a2a;
    cursor: none;
    transition: all 0.15s;
    font-weight: bold;
    touch-action: manipulation;
}

.diff-btn:hover,
.size-btn:hover {
    background: rgba(180,230,120,0.6);
}

.diff-btn.active,
.size-btn.active {
    background: linear-gradient(135deg, #aadf60, #77cc33);
    color: #fff;
    border-color: #77cc33;
    box-shadow: 0 3px 12px rgba(100,200,50,0.4);
}

.start-btn {
    padding: 0.9rem 3.2rem;
    font-size: clamp(1.2rem, 3vw, 1.7rem);
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #ffcc44, #ff9922);
    color: #fff;
    cursor: none;
    box-shadow: 0 4px 20px rgba(255,160,40,0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.1em;
    font-weight: bold;
    touch-action: manipulation;
}

.start-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(255,160,40,0.6);
}

/* ===== ゲーム中UI ===== */
#gameUI {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    pointer-events: none;
}

#topBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 12px rgba(100,150,80,0.2);
    touch-action: manipulation;
}

#backInGame {
    pointer-events: auto;
    padding: 0.35rem 1rem;
    font-size: 0.95rem;
    font-weight: bold;
    border: 2.5px solid #aad080;
    border-radius: 30px;
    background: rgba(255,255,255,0.7);
    color: #4a6a2a;
    cursor: none;
    transition: background 0.15s;
    touch-action: manipulation;
}

#backInGame:hover {
    background: rgba(200,240,160,0.85);
}

#timerDisplay {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: bold;
    color: #4a6a2a;
    background: rgba(255,255,255,0.6);
    padding: 0.3rem 1.2rem;
    border-radius: 30px;
    min-width: 80px;
    text-align: center;
}

#timerDisplay.warning {
    color: #e05555;
    animation: pulse 0.8s infinite;
}

@keyframes pulse {
    0%,100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.12);
    }
}

#rightGroup {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    pointer-events: auto;
    touch-action: manipulation;
}

#scoreDisplay {
    font-size: clamp(1rem, 3vw, 1.6rem);
    color: #4a6a2a;
    background: rgba(255,255,255,0.6);
    padding: 0.3rem 1.2rem;
    border-radius: 30px;
}

#scoreDisplay span {
    font-weight: bold;
    font-size: 1.2em;
    color: #1a5f1a;
}

#audioCtrl {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.6);
    padding: 0.3rem 0.9rem;
    border-radius: 30px;
    touch-action: manipulation;
}

#muteBtn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: none;
    padding: 0;
    min-width: 1.6rem;
    touch-action: manipulation;
}

#volumeSlider {
    width: 80px;
    accent-color: #77cc33;
    cursor: none;
    touch-action: manipulation;
}

/* ===== ゲームエリア ===== */
#gameArea {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding-top: 65px;
    touch-action: none;
}

#grid {
    display: grid;
    gap: clamp(16px, 3vw, 32px);
}

.cell {
    position: relative;
    cursor: none;
}

.hole-shadow {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: rgba(0,0,0,0.18);
    filter: blur(6px);
    z-index: 1;
    pointer-events: none;
}

.hole-back {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse at 45% 40%,
        #3d2008 0%, #200e02 60%, #100701 100%);
    z-index: 2;
    pointer-events: none;
}

.mole-wrap {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    pointer-events: none;
}

.mole {
    position: relative;
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(.36,1.6,.6,1);
    pointer-events: none;
}

.mole.up {
    transform: translateY(0%);
}

.mole.hit {
    transform: translateY(0%) scale(0.88) rotate(-6deg);
    filter: brightness(1.5) saturate(1.3);
    transition: transform 0.06s;
}

.hole-rim {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    z-index: 4;
    pointer-events: none;
    overflow: hidden;
}

.hole-rim::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58%;
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
    background: linear-gradient(180deg,
        #3d2008 0%, #200e02 55%, #100701 100%);
}

.hit-zone {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    cursor: none;
    border-radius: 50% 50% 0 0;
}

.star-effect {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    pointer-events: none;
    z-index: 10;
    animation: starPop 0.55s ease-out forwards;
}

@keyframes starPop {
    0% {
        transform: translateX(-50%) scale(0) translateY(0);
        opacity: 1;
    }
    55% {
        transform: translateX(-50%) scale(1.5) translateY(-28px);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) scale(1) translateY(-55px);
        opacity: 0;
    }
}

/* ===== 終了パネル ===== */
#endScreen {
    display: none;
    position: fixed;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    background: rgba(100,180,80,0.15);
    backdrop-filter: blur(3px);
    touch-action: manipulation;
}

.end-panel {
    background: rgba(255,255,255,0.9);
    border-radius: 28px;
    padding: 2.5rem 3.5rem;
    text-align: center;
    box-shadow: 0 8px 40px rgba(80,150,40,0.25);
    animation: popIn 0.45s cubic-bezier(.36,2,.6,1) forwards;
}

.end-panel h2 {
    font-size: clamp(2.5rem,8vw,5rem);
    color: #4a7a1a;
    margin-bottom: 0.5rem;
}

#endScore,#endHitRate {
    font-size: clamp(1.4rem,4vw,2.2rem);
    color: #3a5a1a;
    margin-bottom: 0.4rem;
}

#endScore span,#endHitRate span {
    font-size: 1.4em;
    font-weight: bold;
    color: #e07020;
}

#endMessage {
    font-size: clamp(1rem,2.5vw,1.5rem);
    color: #5a8a2a;
    margin-bottom: 1.6rem;
}

.end-btns {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.end-btn {
    padding: 0.7rem 2rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 50px;
    cursor: none;
    font-weight: bold;
    transition: transform 0.15s;
    touch-action: manipulation;
}

#retryBtnEnd {
    background: linear-gradient(135deg,#ffcc44,#ff9922);
    color:#fff;
    box-shadow:0 3px 12px rgba(255,160,40,0.4);
}

#backBtnEnd {
    background: rgba(200,230,160,0.8);
    color: #4a6a2a;
    border: 2px solid #aad080;
}

.end-btn:hover {
    transform: scale(1.06);
}

@keyframes popIn {
    0% {
        transform:scale(0.3);
        opacity:0;
    }
    100% {
        transform:scale(1);
        opacity:1;
    }
}

/* 草エリア */
#grassBar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55px;
    z-index: 5;
    background: linear-gradient(180deg, #7ab87a 0%, #5a9a5a 100%);
    pointer-events: none;
}

#grassBar::before {
    content: '';
    position: absolute;
    top: -16px;
    left: 0;
    right: 0;
    height: 20px;
    background: #7ab87a;
    clip-path: polygon(
        0% 100%, 1.5% 0%, 3% 100%, 4.5% 0%, 6% 100%, 7.5% 0%, 9% 100%,
        10.5% 0%, 12% 100%, 13.5% 0%, 15% 100%, 16.5% 0%, 18% 100%,
        19.5% 0%, 21% 100%, 22.5% 0%, 24% 100%, 25.5% 0%, 27% 100%,
        28.5% 0%, 30% 100%, 31.5% 0%, 33% 100%, 34.5% 0%, 36% 100%,
        37.5% 0%, 39% 100%, 40.5% 0%, 42% 100%, 43.5% 0%, 45% 100%,
        46.5% 0%, 48% 100%, 49.5% 0%, 51% 100%, 52.5% 0%, 54% 100%,
        55.5% 0%, 57% 100%, 58.5% 0%, 60% 100%, 61.5% 0%, 63% 100%,
        64.5% 0%, 66% 100%, 67.5% 0%, 69% 100%, 70.5% 0%, 72% 100%,
        73.5% 0%, 75% 100%, 76.5% 0%, 78% 100%, 79.5% 0%, 81% 100%,
        82.5% 0%, 84% 100%, 85.5% 0%, 87% 100%, 88.5% 0%, 90% 100%,
        91.5% 0%, 93% 100%, 94.5% 0%, 96% 100%, 97.5% 0%, 100% 100%
    );
}