html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
}
body {
    font-family: 'Press Start 2P', monospace !important;
    color: white !important;
    background-color: #0d0b14;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
#game-container { position: relative; width: 100%; height: 100%; overflow: hidden; display: flex; justify-content: center; align-items: center; }
body.debug-mode-active #game-container { box-shadow: inset 0 0 0 3px red; }
#vignette-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; box-shadow: inset 0 0 150px rgba(0,0,0,0.7); pointer-events: none; z-index: 100; }
#flash-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: white; z-index: 500; pointer-events: none; opacity: 0; }
.hidden { display: none !important; }
#matter-container { position: relative; z-index: 2; }
#matter-container canvas { display: block; }
.ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; text-align: center; justify-content: center; align-items: center; z-index: 200; }
@keyframes background-pan { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
#start-menu { gap: 20px; background: linear-gradient(225deg, #1d2b3a, #4a1a3a, #2c3e50, #0d0b14); background-size: 400% 400%; animation: background-pan 25s ease infinite; position: relative; overflow: hidden; }
#title-animation-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
#game-screen-wrapper { display: flex; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#ranking-display-container { width: 100%; flex-grow: 1; min-height: 0; display: flex; justify-content: center; }
#ranking-display { overflow-y: auto; display: flex; flex-direction: column; align-items: center; width: 90%; max-width: 480px; padding: 10px; box-sizing: border-box; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 10px; background-color: rgba(0, 0, 0, 0.2); }
@keyframes screen-shake { 0%, 100% { transform: translate(0, 0); } 10%, 30%, 50%, 70%, 90% { transform: translate(-5px, 5px) rotate(-1deg); } 20%, 40%, 60%, 80% { transform: translate(5px, -5px) rotate(1deg); } }
.screen-shake { animation: screen-shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes red-border-flash { from { box-shadow: inset 0 0 0 0px rgba(255, 0, 0, 0.7); } 50% { box-shadow: inset 0 0 0 20px rgba(255, 0, 0, 0.7); } to { box-shadow: inset 0 0 0 0px rgba(255, 0, 0, 0.7); } }
.red-flash-border { animation: red-border-flash 0.5s ease-out both; }
@keyframes anaglyph-move { 0%, 100% { text-shadow: -2px -2px 0 #ff0000, 2px 2px 0 #00ffff; } 25% { text-shadow: 2px -2px 0 #ff0000, -2px 2px 0 #00ffff; } 50% { text-shadow: 2px 2px 0 #ff0000, -2px -2px 0 #00ffff; } 75% { text-shadow: -2px 2px 0 #ff0000, 2px -2px 0 #00ffff; } }
#title-graphic, #game-over-title { color: #f0f0f0; text-shadow: -2px -2px 0 #ff0000, 2px 2px 0 #00ffff; animation: anaglyph-move 1.5s linear infinite; }
#title-graphic { font-size: clamp(32px, 8vw, 60px); margin-bottom: 20px; margin-top: 20px; line-height: 1.2; text-transform: uppercase; }
#game-over-title { font-size: clamp(45px, 11vw, 90px); margin-bottom: 20px; }
#ranking-title { font-size: 20px; margin-bottom: 10px; }
#start-menu .button:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(0,0,0,0.4), inset 0 -2px 5px rgba(0,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.2), 0 0 15px rgba(169, 114, 255, 0.8), 0 0 25px rgba(169, 114, 255, 0.6); }
#game-over-screen, #pause-screen, #design-menu, #share-modal { background-color: rgba(0,0,0,0.7); }
.modal-content { background-color: rgba(44, 42, 60, 0.9); border: 2px solid #a972ff; border-radius: 15px; box-shadow: 0 0 20px rgba(169, 114, 255, 0.5); max-width: 95%; width: 600px; padding: 20px 30px; box-sizing: border-box; margin: auto; position: relative; }
.button-container { display: flex; justify-content: center; flex-wrap: wrap; }
.button { font-family: inherit; font-size: clamp(14px, 2.5vw, 20px); padding: 15px 30px; margin: 10px; border-radius: 50px; cursor: pointer; background: linear-gradient(145deg, #5c62c2, #494ead); border: none; color: #fff; text-shadow: 0 0 5px #fff, 1px 1px 2px rgba(0,0,0,0.7); position: relative; transition: all 0.3s ease-out; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.4), inset 0 -2px 5px rgba(0,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.2); }
#game-ui-overlay { pointer-events: none; justify-content: space-between; height: 100%; width: 100%; position: absolute; top: 0; left: 0; }
#game-top-bar { pointer-events: auto; width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 10px; box-sizing: border-box; height: 80px; }
.ingame-buttons-left { display: flex; align-items: center; gap: 15px; }
.ingame-buttons-right { position: relative; display: flex; align-items: center; gap: 15px; }
#score-and-name-container { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#ingame-player-name { font-size: 12px; opacity: 0.9; }
#ingame-player-name-edit-btn { cursor: pointer; margin-left: 5px; }
#pause-button, #mobile-debug-toggle, #ingame-fullscreen-button { background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; color: white; }
#mobile-debug-toggle { display: none; }
#ingame-fullscreen-button { line-height: 1; }
.mobile-debug-options { position: absolute; top: 100%; right: 0; background-color: rgba(0, 0, 0, 0.7); border-radius: 5px; padding: 5px; display: flex; flex-direction: column; gap: 5px; }
.debug-button { font-size: 14px !important; font-family: monospace !important; border: 1px solid #fff !important; padding: 5px 8px !important; border-radius: 5px; margin: 0 !important; background-color: rgba(255, 255, 255, 0.2); }
#game-bottom-bar { width: 100%; pointer-events: auto; background-color: transparent; padding: 10px; box-sizing: border-box; }
#next-bubble-preview { width: 40px; height: 40px; background-color: rgba(0,0,0,0.3); border: 2px solid #fff; border-radius: 50%; background-size: contain; background-position: center; background-repeat: no-repeat; }
#next-bubble-container { display: flex; align-items: center; gap: 8px; }
.settings-option { width: 100%; display: flex; justify-content: space-between; align-items: center; margin: 15px 0; font-size: 1.2em; }
.setting-row { width: 100%; display: flex; align-items: center; margin: 10px 0 20px; }
.toggle-switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #2196F3; }
input:checked + .slider:before { transform: translateX(26px); }
.modal-close-button { position: absolute; top: 15px; right: 20px; width: 40px; height: 40px; background: none; border: none; font-size: 30px; color: white; cursor: pointer; line-height: 40px; text-align: center; padding: 0; opacity: 0.7; transition: opacity 0.2s, transform 0.2s; z-index: 10; }
.modal-close-button:hover { opacity: 1; transform: rotate(90deg); }
.modal-close-button::before { content: '\00d7'; font-weight: bold; }
#debug-menu .modal-content, #design-menu .modal-content { max-height: 80vh; overflow-y: auto; }
#close-design-menu { margin-top: 20px; }
#quality-selector-container { display: flex; gap: 10px; }
.quality-button { padding: 8px 16px !important; font-size: 14px !important; background: #4a4a70; box-shadow: none; }
.quality-button.selected { background: linear-gradient(145deg, #5c62c2, #494ead); box-shadow: 0 5px 15px rgba(0,0,0,0.4), inset 0 -2px 5px rgba(0,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.2); transform: scale(1.05); }
.share-options { display: flex; flex-direction: column; gap: 15px; margin: 20px auto; width: 80%; }
.share-option { display: flex; align-items: center; gap: 15px; padding: 15px; background-color: #4a4a70; color: white; text-decoration: none; border-radius: 10px; transition: background-color 0.2s; font-size: 16px; }
.share-option:hover { background-color: #5c62c2; }
.share-option::before { content: ''; display: inline-block; width: 28px; height: 28px; background-size: contain; background-repeat: no-repeat; background-position: center; flex-shrink: 0; }
#share-twitter::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='white' d='M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.31l5.743-6.572L0 .75h5.063l3.495 4.633L12.6.75Zm-.806 13.022h1.284L4.12 2.164H2.74l8.054 11.608Z'/%3E%3C/svg%3E"); }
#share-facebook::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='white' d='M16 8.049c0-4.446-3.582-8.05-8-8.05C3.58 0 0 3.603 0 8.05c0 4.017 2.926 7.347 6.75 7.951v-5.625h-2.03V8.05H6.75V6.275c0-2.017 1.195-3.131 3.022-3.131.876 0 1.791.157 1.791.157v1.98h-1.009c-.993 0-1.303.621-1.303 1.258v1.51h2.218l-.354 2.326H9.25V16c3.824-.604 6.75-3.934 6.75-7.951z'/%3E%3C/svg%3E"); }
#share-line::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 128'%3E%3Cpath fill='%2300B900' d='M114.71 0H13.29A13.3 13.3 0 0 0 0 13.29v101.42A13.3 13.3 0 0 0 13.29 128h101.42A13.3 13.3 0 0 0 128 114.71V13.29A13.3 13.3 0 0 0 114.71 0z'/%3E%3Cpath fill='white' d='M83.35 64.92q0 4.31-1.31 7.82t-3.5 6.13q-2.18 2.62-4.9 4.31t-5.83 2.63q-3.11 1-6.52.99h-4.32V50.55h4.8q3.49 0 6.64 1t6.05 3.32q2.9 2.3 4.41 5.83t1.58 8.22zm-10.87.12q0-5.85-3.08-8.75-3.08-2.9-8.49-2.9h-1.6v23.14h1.6q5.58 0 8.57-2.83t2.99-8.66zM96.11 50.55h7.2v25.21h10.32v6.64h-17.52V50.55zm-63.54 0h17.52v6.64H39.86v7.38h8.86v6.52h-8.86v7.7h9.45v6.56H29.67l.01-34.8zM56.41 50.55l-9.1 16.29-1.2-1.33v-15h-7.2v34.8h7.2v-16.3l9.36 16.3h8.33l-9.91-17.38L64 50.55h-7.59z'/%3E%3C/svg%3E"); }
@media (orientation: landscape) { #debug-menu { justify-content: center; align-items: flex-end; } #debug-menu .modal-content { margin: 20px; width: 450px; max-height: 95vh; } }
.debug-slider-group { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.debug-slider-group .preview-img { width: 30px; height: 30px; background-size: contain; background-position: center; background-repeat: no-repeat; border-radius: 50%; border: 1px solid #fff; }
.debug-slider-group label { flex-basis: 120px; text-align: left; font-size: 12px; }
.debug-slider-group .value-display { font-size: 12px; min-width: 45px; text-align: right; }
#bubble-selector { display: none; justify-content: center; align-items: center; width: 100%; gap: 1vw; }
.bubble-selector-icon { width: 7vw; height: 7vw; max-width: 40px; max-height: 40px; background-size: contain; background-position: center; background-repeat: no-repeat; border: 2px solid #fff; border-radius: 50%; cursor: pointer; transition: transform 0.2s; }
.bubble-selector-icon:hover { transform: scale(1.1); border-color: #ffc107; }
#banner-ad-container { position: fixed; bottom: 0; left: 0; width: 100%; height: 50px; z-index: 150; display: flex; justify-content: center; align-items: center; background-color: #000; padding-bottom: env(safe-area-inset-bottom); box-sizing: content-box; }
.ad-container-hidden { display: none !important; }
.design-section-container { width: 100%; margin-top: 20px; padding-top: 15px; border-top: 1px solid #fff; }
.items-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 15px; }
.design-option { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.preview-box { width: 80px; height: 80px; border: 2px solid #fff; background-size: cover; background-position: center; }
.design-button-container { display: flex; gap: 10px; }
.button.share-button { background: linear-gradient(145deg, #28a745, #218838); }
#player-name-container { margin-bottom: 20px; }
#ranking-list { list-style-type: none; padding-left: 0; width: 100%; }
#ranking-list li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.rank-part { flex-basis: 15%; text-align: center; }
.name-part { flex-grow: 1; text-align: left; padding-left: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-part { flex-basis: 35%; text-align: right; }
@keyframes gameplay-gradient-animation { 0% { background-position: 50% 0%; } 50% { background-position: 50% 100%; } 100% { background-position: 50% 0%; } }
#matter-container.aurora-background { background: linear-gradient(180deg, #1d1a2f, #3b2a55, #6d3b6d, #a8527a); background-size: 100% 300%; animation: gameplay-gradient-animation 20s ease infinite; }
#start-button.primary-action { width: 90%; max-width: 400px; padding-top: 20px; padding-bottom: 20px; font-size: clamp(20px, 4vw, 28px); background: linear-gradient(145deg, #3cacd7, #2d8cb3); border: none; box-shadow: 0 5px 15px rgba(0,0,0,0.4), inset 0 -2px 5px rgba(0,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.2); white-space: nowrap; }
#start-button.primary-action:hover { background: linear-gradient(145deg, #4cbbe0, #3a98bb); }
#open-debug-menu-button { background: linear-gradient(145deg, #ac3535, #912b2b); }
#open-debug-menu-button:hover { background: linear-gradient(145deg, #c04343, #a13838); }
.evolution-order { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; padding: 10px; background-color: rgba(0,0,0,0.2); border-radius: 8px; }
.evolution-order img { width: clamp(50px, 10.8vw, 72px); height: clamp(50px, 10.8vw, 72px); }
.evolution-order img.evo-bubble-final { width: clamp(70px, 15vw, 100px); height: clamp(70px, 15vw, 100px); }
.evolution-order .arrow { font-size: clamp(16px, 4vw, 20px); color: #ccc; }
#game-tips { text-align: left; padding-left: 25px; font-size: clamp(12px, 2.5vw, 16px); line-height: 1.6; }
#game-tips li { margin-bottom: 8px; }
#privacy-policy-section { margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.policy-text-container { font-family: sans-serif; font-size: 12px; line-height: 1.5; text-align: left; color: #ddd; padding: 10px; background-color: rgba(0,0,0,0.2); border-radius: 5px; max-height: 200px; overflow-y: auto; }
.policy-text-container p { margin-top: 0; margin-bottom: 10px; }
.policy-text-container ul { margin: 10px 0; padding-left: 20px; }
.policy-text-container a { color: #87cefa; text-decoration: underline; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-out { animation: fadeOut 0.3s forwards ease-in-out; pointer-events: none; }
.fade-in { animation: fadeIn 0.3s forwards ease-in-out; }
.modal-slide-container { z-index: 300; pointer-events: none; background-color: transparent; transition: background-color 0.3s ease-in-out; }
.modal-slide-container .modal-content { transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); max-height: 95vh; overflow-y: auto; }
#settings-modal .modal-content { position: absolute; top: 50%; left: 0; transform: translate(calc(-100% + 10px), -50%); }
#how-to-play-modal .modal-content { position: absolute; top: 50%; right: 0; transform: translate(calc(100% - 10px), -50%); }
.modal-slide-container.active { pointer-events: auto; background-color: rgba(0,0,0,0.7); }
#settings-modal.active .modal-content { transform: translate(20px, -50%); }
#how-to-play-modal.active .modal-content { transform: translate(-20px, -50%); }
.sidebar { display: none; flex-direction: column; justify-content: center; align-items: center; flex: 1; padding: 20px; box-sizing: border-box; }
#center-column { position: relative; display: flex; justify-content: center; align-items: center; }
body.landscape-mode #game-screen-wrapper { justify-content: space-between; }
body.landscape-mode .sidebar { display: flex; }
body.landscape-mode #center-column { flex: 1; }
body.landscape-mode #ranking-display { min-height: 300px; max-height: 80vh; }
#ingame-how-to-play { background-color: rgba(0, 0, 0, 0.2); border-radius: 10px; padding: 15px; max-height: 80vh; overflow-y: auto; max-width: 480px; width: 90%; }
#ingame-how-to-play h2, #ingame-how-to-play h3 { margin-top: 10px; }
#ingame-how-to-play .policy-text-container { max-height: 100px; }
#settings-modal .modal-content,
#how-to-play-modal .modal-content {
    height: 80vh;
}
@keyframes chaos-filter {
    0% { filter: hue-rotate(0deg) saturate(1); }
    25% { filter: hue-rotate(90deg) saturate(2) contrast(1.2); }
    50% { filter: hue-rotate(180deg) saturate(1); }
    75% { filter: hue-rotate(270deg) saturate(2) contrast(1.2); }
    100% { filter: hue-rotate(360deg) saturate(1); }
}
body.chaos-mode-active #game-container {
    animation: chaos-filter 8s linear infinite;
}
@keyframes chaos-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-10px, 10px) rotate(-3deg); }
  20%, 40%, 60%, 80% { transform: translate(10px, -10px) rotate(3deg); }
}
.chaos-shake {
    animation: chaos-shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}
.chaos-invert-flash {
    opacity: 1;
    background-color: transparent;
    backdrop-filter: invert(1);
    -webkit-backdrop-filter: invert(1);
    transition: opacity 0.15s ease-out;
}