body {
margin: 0;
overflow: hidden;
background: #d0f0ff;
font-family: -apple-system, BlinkMacSystemFont, "Pretendard Variable", Pretendard, "Pretendard JP Variable", "Pretendard JP", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", sans-serif;
touch-action: none;
width: 100vw;
height: 100vh;
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
-webkit-user-drag: none;
}

/* Unified UI Layout Applied */
/* Modern Premium HUD Layout */
#hud {
position: fixed;
top: calc(12px + env(safe-area-inset-top));
left: calc(16px + env(safe-area-inset-left));
right: calc(16px + env(safe-area-inset-right));
display: none;
align-items: center;
justify-content: space-between;
z-index: 100;
pointer-events: none;
}

/* @media (orientation: portrait) {
#hud {
    top: calc(12px + env(safe-area-inset-top));
}
} */

#timer-item {
display: none;
padding: 0px 16px;
font-size: 24px;
font-weight: 800;
letter-spacing: -1px;
color: #fff;
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
font-variant-numeric: tabular-nums;
pointer-events: none;
font-family: -apple-system, BlinkMacSystemFont, "Pretendard Variable", Pretendard, "Pretendard JP Variable", "Pretendard JP", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", sans-serif;
}

/* Speedline Effect for Penguin Sliding ✨ */
#speed-lines {
position: fixed;
top: 0; left: 0; width: 100vw; height: 100vh;
pointer-events: none; z-index: 5; display: none;
overflow: hidden;
}
#slide-corner-glow {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
pointer-events: none;
z-index: 4;
opacity: 0;
transition: opacity 0.2s ease-out;
background:
    radial-gradient(58vw 58vw at 0% 0%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 56%),
    radial-gradient(58vw 58vw at 100% 0%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 56%),
    radial-gradient(58vw 58vw at 0% 100%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 56%),
    radial-gradient(58vw 58vw at 100% 100%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 56%);
}
#slide-corner-glow.active {
opacity: 0.75;
}
.speed-line {
position: absolute;
top: 50%; left: 50%;
width: 1000px; height: 2px;
background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0) 100%);
transform-origin: 0% 50%;
animation: speedline-move 0.15s infinite linear;
}
@keyframes speedline-move {
0% { transform: rotate(var(--angle)) translateX(0) scaleX(0.1); opacity: 0; }
50% { transform: rotate(var(--angle)) translateX(200px) scaleX(1.5); opacity: 1; }
100% { transform: rotate(var(--angle)) translateX(500px) scaleX(0.1); opacity: 0; }
}

#debug-info {
display: none;
margin-left: 12px;
background: rgba(0, 0, 0, 0.5);
color: #00ff00;
font-family: monospace;
font-size: 12px;
padding: 4px 8px;
border-radius: 8px;
backdrop-filter: blur(4px);
pointer-events: none;
}

/* Stat Row: Left side */
.stat-row {
width: 150px;
display: flex; flex-direction: column; gap: 6px;
padding: 10px 14px;
background: rgba(255, 255, 255, 0.1);
border-radius: 16px;
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.gauge-item { display: flex; align-items: center; gap: 10px; width: 100%; }
.gauge-label {
width: 14px; display: flex; justify-content: center; align-items: center;
filter: drop-shadow(0 0 2px rgba(0,0,0,0.2));
}

.gauge-container {
flex-grow: 1; height: 5px; background: rgba(255,255,255,0.1);
border-radius: 10px; overflow: hidden; position: relative;
transform: translateZ(0);
}

.gauge-fill {
height: 100%; width: 100%; transition: none !important;
border-radius: 10px;
}

#hp-fill { background: #ff5252; }
#gauge-fill { background: #ffe066; }
#oxygen-fill { background: #00e5ff; }
#oxygen-item { display: none; }

/* Right HUD: Score + Pause */
#right-hud {
display: flex; align-items: center; gap: 0px;
pointer-events: auto;
}

#ui {
display: flex; align-items: center;
padding: 6px 16px; border-radius: 18px;
pointer-events: none;
user-select: none;
-webkit-user-select: none;
-webkit-user-drag: none;
}

.score-box {
font-size: 24px; font-weight: 800; letter-spacing: -1px;
color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.2);
font-variant-numeric: tabular-nums;
pointer-events: none;
user-select: none;
-webkit-user-select: none;
-webkit-user-drag: none;
}

/* Collection Feedback */
@keyframes gauge-pulse {
0% { transform: scale(1); filter: brightness(1); }
50% { transform: scale(1.05); filter: brightness(1.5); }
100% { transform: scale(1); filter: brightness(1); }
}
.gauge-item.collect-flash { animation: gauge-pulse 0.4s ease-out; }

/* HP Segments */
.segments {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
display: flex; pointer-events: none;
}
.segment-line { flex: 1; border-right: 1px solid rgba(255,255,255,0.4); }
.segment-line:last-child { border-right: none; }

/* Missile Warning */
#missile-warning {
display: none;
position: fixed;
width: 50px;
height: 50px;
background: rgba(255, 0, 0, 0.8);
border-radius: 50%;
z-index: 110;
justify-content: center;
align-items: center;
color: white;
font-weight: 900;
font-size: 30px;
animation: blink 0.3s infinite;
border: 3px solid white;
box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
pointer-events: none;
transform: translate(-50%, -50%); /* Center on the calculated point */
}

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

/* Pause Button Styles */
#pause-btn {
width: 32px; height: 32px;
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex; justify-content: center; align-items: center;
cursor: pointer; pointer-events: auto;
transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
touch-action: none;
user-select: none;
-webkit-user-select: none;
-webkit-user-drag: none;
}
#pause-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.25); }

.pause-icon {
width: 14px; height: 14px;
display: flex; justify-content: space-between;
}
.pause-bar {
width: 4px; height: 100%;
background: white; border-radius: 4px;
}

#menu {
position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
text-align: center; z-index: 20; width: 100%; max-width: 500px;
user-select: none; -webkit-user-select: none;
}

#menu h1 {
font-size: 80px; margin: 0; font-weight: 900; letter-spacing: -4px;
line-height: 0.95;
color: white;
text-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

#menu p {
font-size: 16px; color: rgba(255,255,255,0.7); margin-bottom: 60px;
letter-spacing: 4px; font-weight: 500;
}

.menu-btns {
display: flex; flex-direction: column; align-items: center; gap: 20px;
width: 100%;
}

/* Mode Switcher Pill */
.mode-selection {
display: flex; background: rgba(255,255,255,0.1); padding: 4px; 
border-radius: 100px; backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.1);
margin-bottom: 5px;
}
.mode-opt {
padding: 8px 24px; border-radius: 100px; font-size: 13px; font-weight: 800;
color: rgba(255,255,255,0.5); cursor: pointer; transition: all 0.3s;
letter-spacing: 1px;
}
.mode-opt.active {
background: white; color: black; box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Character Selection Cards */
.char-grid {
display: flex; gap: 16px; width: 100%; justify-content: center;
}
.char-card {
width: 150px; aspect-ratio: 0.85;
background: rgba(255,255,255,0.1); border-radius: 30px;
backdrop-filter: blur(15px); border: 1px solid rgba(255,255,255,0.15);
display: flex; flex-direction: column; align-items: center; justify-content: center;
cursor: pointer; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
position: relative; overflow: hidden;
}

/* Tab change animation */
.char-card.tab-switching {
    animation: tab-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes tab-pop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.92); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

#card-penguin {
    background: linear-gradient(180deg, #b3e5fc 0%, #ffffff 100%);
    border-color: #81d4fa;
    position: relative;
    overflow: hidden;
}
#card-penguin::before {
    content: ''; position: absolute; top: -50px; left: 10%; width: 8px; height: 8px; background: white; border-radius: 50%; opacity: 0.8; 
    animation: snow-fall 4s linear infinite;
    box-shadow: 40px 20px 0 -2px white, 80px 50px 0 -1px white, -20px 40px 0 -3px white, 110px 10px 0 -2px white;
    filter: blur(1px);
}
#card-penguin::after {
    content: ''; position: absolute; top: -80px; left: 20%; width: 6px; height: 6px; background: white; border-radius: 50%; opacity: 0.6; 
    animation: snow-fall 6s linear infinite 2s;
    box-shadow: 50px 30px 0 -1px white, 10px 70px 0 -2px white, -30px 90px 0 -3px white, 90px 20px 0 -1px white;
    filter: blur(1px);
}

#card-croc {
    background: linear-gradient(180deg, #00acc1 0%, #002f33 100%);
    border-color: #00838f;
    position: relative;
    overflow: hidden;
}
#card-croc::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 20px, transparent 20px, transparent 40px);
    background-size: 56.57px 56.57px; /* Diagonal repeat period: 40px * sqrt(2) */
    pointer-events: none;
    animation: water-flow 3s ease-in-out infinite alternate;
}
#card-croc::after {
    content: ''; position: absolute; bottom: -20px; left: 20%; width: 12px; height: 12px; 
    border: 1.5px solid rgba(255,255,255,0.4); border-radius: 50%; opacity: 0; 
    animation: bubble-rise 8s linear infinite;
    box-shadow: 
        inset -2px -2px 4px rgba(255,255,255,0.2), 
        30px 40px 0 -2px rgba(255,255,255,0.3), 
        -15px 80px 0 -4px rgba(255,255,255,0.2), 
        50px 120px 0 -1px rgba(255,255,255,0.4),
        10px 170px 0 -3px rgba(255,255,255,0.3),
        -25px 220px 0 -2px rgba(255,255,255,0.2),
        40px 270px 0 -4px rgba(255,255,255,0.3);
}

@keyframes water-flow {
    0% { background-position: 0 0; }
    100% { background-position: 28.28px 0; } /* Half a period for smooth oscillation */
}

@keyframes snow-fall {
    0% { transform: translateY(0) translateX(0); }
    100% { transform: translateY(250px) translateX(20px); }
}
@keyframes bubble-rise {
    0% { transform: translateY(0); opacity: 0; }
    5% { opacity: 0.6; }
    95% { opacity: 0.6; }
    100% { transform: translateY(-300px); opacity: 0; }
}

.char-emoji { display: none; }

.char-card:hover { transform: translateY(-8px); box-shadow: 0 10px 25px rgba(0,0,0,0.15); }
.char-card:active { transform: scale(0.95); }

.char-emoji { font-size: 44px; margin-bottom: 8px; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.2)); }
.char-name { font-size: 16px; font-weight: 900; letter-spacing: 1px; color: white; margin-bottom: 2px; }
.char-stat { font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.5); display: flex; align-items: center; gap: 4px; }

.char-medal-icon { position: absolute; top: 12px; right: 12px; font-size: 18px; }

button {
padding: 14px 40px; font-size: 18px; cursor: pointer; border-radius: 20px;
border: 1px solid rgba(255,255,255,0.15);
transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
font-weight: 700; letter-spacing: 1px; width: 220px;
backdrop-filter: blur(10px);
display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.btn-time {
width: 100px; padding: 12px 0;
background: rgba(255, 255, 255, 0.1);
color: white;
}
.btn-time:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-3px); }

.btn-penguin {
background: rgba(255, 255, 255, 0.9); color: #000;
border: none; box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.btn-penguin:hover {
transform: translateY(-5px); background: #fff;
box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

.btn-crocodile {
background: rgba(0, 0, 0, 0.3); color: rgba(255,255,255,0.8);
border: 1px solid rgba(255,255,255,0.1);
}
.btn-crocodile:hover {
background: rgba(76, 175, 80, 0.2); color: #4caf50;
border-color: rgba(76, 175, 80, 0.4); transform: scale(1.02);
}

/* Menu Utility Buttons */
#menu-utils { display: block; }
.menu-util-btn {
position: fixed;
width: 44px;
height: 44px;
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 12px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
font-size: 20px;
z-index: 150; /* Above everything */
transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
pointer-events: auto;
}
.menu-util-btn:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.25); }
#menu-utils svg { opacity: 0.8; }
#btn-settings:hover svg { transform: rotate(45deg); }
#btn-settings svg { transition: transform 0.4s ease; }

#btn-shop { top: calc(16px + env(safe-area-inset-top)); left: calc(16px + env(safe-area-inset-left)); }
#btn-achievements { top: calc(16px + env(safe-area-inset-top)); left: calc(72px + env(safe-area-inset-left)); }
#btn-settings { top: calc(16px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right)); }

#game-over-screen {
display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
z-index: 30; width: 95%; max-width: 680px;
justify-content: center; align-items: center; gap: 20px;
pointer-events: none;
}

#over-ad {
width: 340px; height: 290px;
background: #000; border-radius: 24px;
display: flex; align-items: center; justify-content: center;
color: rgba(255,255,255,0.2); font-size: 12px; font-weight: 800; letter-spacing: 2px;
border: 1px solid rgba(255,255,255,0.1);
pointer-events: auto;
flex-shrink: 0;
box-sizing: border-box;
padding: 20px;
}

#game-over {
width: 300px;
background: rgba(0,0,0,0.75); border-radius: 40px;
backdrop-filter: blur(15px); border: 1px solid rgba(0,0,0,0.5);
padding: 40px 20px; display: flex; flex-direction: column;
align-items: center; text-align: center; color: white;
user-select: none; -webkit-user-select: none;
pointer-events: auto;
}

#game-over h1 {
font-size: 42px; margin: 0; font-weight: 900; letter-spacing: -2px;
color: #ff5252;
text-shadow: 0 5px 15px rgba(255,82,82,0.2);
}

/* Game Reward Overlay */
#game-reward {
display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
text-align: center; color: white; z-index: 30;
width: 85%; max-width: 340px; user-select: none; -webkit-user-select: none;
background: rgba(0,0,0,0.85); padding: 12px 16px; border-radius: 40px;
backdrop-filter: blur(15px);
}

#game-reward h1 {
font-size: 32px; margin: 0; font-weight: 900; letter-spacing: -1px;
color: #ffd600;
}

.reward-msg {
font-size: 12px; margin: 10px 0; color: #fff; font-weight: 600; line-height: 1.4;
}

.reward-img-box {
width: 100%;
margin-bottom: 12px; display: flex; align-items: center; justify-content: center;
}

.reward-img {
width: 75%; height: auto;
}

.over-stats {
margin-bottom: 12px;
padding: 12px;
}

.reward-over-stats {
margin-top: 0;
padding: 0;
}

.over-label { font-size: 12px; color: rgba(255,255,255,0.4); letter-spacing: 2px; margin-bottom: 5px; }
.over-value { font-size: 32px; font-weight: 800; color: #fff; }
.reward-over-value { font-size: 20px; }

.btn-restart {
background: #fff; color: #000; border: none; width: 220px;
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.btn-restart:hover { transform: translateY(-3px); box-shadow: 0 15px 30px rgba(0,0,0,0.15); }

.btn-revive {
background: #ffd600; color: #000; border: none; width: 220px;
margin-bottom: 12px; font-size: 16px;
box-shadow: 0 8px 15px rgba(255,214,0,0.2);
display: none; /* Initially hidden, shown via JS */
}
.btn-revive:hover { background: #ffea00; transform: scale(1.05); }
.btn-revive:disabled { background: #555; color: #aaa; transform: none; box-shadow: none; cursor: default; }

/* Pause Menu Overlay */
#pause-menu {
display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
text-align: center; color: white; z-index: 70;
width: 80%; max-width: 280px; user-select: none; -webkit-user-select: none;
background: rgba(0,0,0,0.85); padding: 32px 16px; border-radius: 40px;
backdrop-filter: blur(15px); border: 1px solid rgba(255,255,255,0.1);
}

.btn-pause-menu {
background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.1);
width: 220px; margin: 8px 0; border-radius: 15px;
}
.btn-pause-menu:hover { background: rgba(255,255,255,0.2); transform: scale(1.02); }
.btn-exit { color: #ff5252; border-color: rgba(255,82,82,0.2); }

/* Mobile Controls */
#game-controls {
display: none; position: fixed; bottom: 40px; left: 0; width: 100%;
padding: 0 calc(30px + env(safe-area-inset-right)) 0 calc(30px + env(safe-area-inset-left)); z-index: 50; pointer-events: none;
justify-content: space-between; align-items: flex-end;
box-sizing: border-box;
user-select: none; -webkit-user-select: none;
}
.ctrl-group-left { display: flex; gap: 20px; pointer-events: none; }
.ctrl-group-right { pointer-events: none; }
/* BLACK UI BUTTONS */
.game-ctrl-btn { width: 76px; height: 76px; background: rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.25); border-radius: 50%; color: white; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer; pointer-events: auto; backdrop-filter: blur(10px); -webkit-user-select: none; user-select: none; touch-action: none; transition: transform 0.1s, background 0.1s; position: relative; }
.game-ctrl-btn::after {
content: '';
position: absolute;
top: -20px; left: -20px; right: -20px; bottom: -20px;
border-radius: 50%;
}
.game-ctrl-btn.pressed { background: rgba(0,0,0,0.2); transform: scale(0.95); border-color: rgba(255,255,255,0.25); }
#btn-jump { font-size: 24px; }