body { margin: 0; overflow: hidden; display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #333; font-family: 'Press Start 2P', cursive; color: white; }
.side-wing { flex-grow: 1; height: 100vh; position: relative; overflow: hidden; }
.side-wing canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#game-container { position: relative; width: 375px; height: 667px; overflow: hidden; background-color: #333; box-shadow: 0 0 20px rgba(0, 0, 0, 0.7); background-size: cover; background-position: center; flex-shrink: 0; }
#game-container.custom-bg { background-size: cover; background-position: center; }
canvas { position: absolute; top: 0; left: 0; image-rendering: pixelated; }
#playerCanvas { z-index: 5; pointer-events: none; }
.ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 10; text-align: center; backdrop-filter: blur(4px); }
#start-menu {
    justify-content: flex-start;
    padding-top: 20px;
    box-sizing: border-box;
}
.hidden { display: none; }
h1 { font-size: 20px; color: #ffde00; margin-bottom: 15px; text-shadow: 2px 2px #000; }
h2 { font-size: 18px; color: #ffde00; margin-bottom: 15px; text-shadow: 1px 1px #000; }
h3 { font-size: 14px; color: #fff; margin-bottom: 10px; text-shadow: 1px 1px #000; }
.button { font-family: 'Press Start 2P', cursive; font-size: 16px; padding: 12px 24px; margin: 10px; border: none; border-radius: 8px; cursor: pointer; color: #383838; background-image: linear-gradient(to top, #f7b733, #fdd835); box-shadow: 0 5px 0 #c79100; text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.5); transition: transform 0.1s, box-shadow 0.1s; -webkit-tap-highlight-color: transparent; }
.button:active { transform: translateY(3px); box-shadow: 0 2px 0 #c79100; }
.button.secondary { color: #fff; background-image: linear-gradient(to top, #555, #888); box-shadow: 0 5px 0 #333; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); }
.button.secondary:active { transform: translateY(3px); box-shadow: 0 2px 0 #333; }
.button.share { color: #fff; background-image: linear-gradient(to top, #27ae60, #2ecc71); box-shadow: 0 5px 0 #1e8449; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); }
.button.share:active { transform: translateY(3px); box-shadow: 0 2px 0 #1e8449; }
.button.small { font-size: 10px; padding: 10px 16px; }
.button.large { padding: 15px 30px; font-size: 20px; width: 100%; box-sizing: border-box; }
.button.danger { color: #fff; background-image: linear-gradient(to top, #c0392b, #e74c3c); box-shadow: 0 5px 0 #962d22; }
.button.danger:active { transform: translateY(3px); box-shadow: 0 2px 0 #962d22; }
.button.warning { color: #fff; background-image: linear-gradient(to top, #f39c12, #f1c40f); box-shadow: 0 5px 0 #c27c0e; }
.button.warning:active { transform: translateY(3px); box-shadow: 0 2px 0 #c27c0e; }
.input-label { font-size: 12px; margin-bottom: 5px; text-shadow: 1px 1px #000; }
#player-name-input { font-family: 'Press Start 2P', cursive; font-size: 16px; padding: 8px; background-color: #eee; border: 2px solid #000; color: #000; text-align: center; max-width: 100%; }
#ranking-display {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    margin-top: 15px;
    width: 80%;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
    border: 2px solid white;
}
#ranking-display::-webkit-scrollbar {
    display: none;
}
#ranking-list { list-style-type: none; padding: 0; margin: 0; }
#ranking-list li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 12px; }
.rank-medal { font-size: 16px; margin-right: 10px; display: inline-block; width: 24px; text-align: center; }
.rank-details { flex-grow: 1; display: flex; justify-content: space-between; align-items: center; width: 100%; overflow: hidden;}
.rank-name { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-score { text-align: right; flex-shrink: 0; margin-left: 10px; }
.modal .modal-content { max-width: 95%; }
.modal-content { background-color: rgba(0, 0, 0, 0.9); padding: 25px; max-width: 95%; box-sizing: border-box; pointer-events: auto; }
.modal-content h1, .modal-content h2 { margin-top: 0; font-size: 24px; }
.modal-content h3 { font-size: 16px; margin: 10px 0; }
#new-record-container { margin: -10px 0; }
.modal-footer { margin-top: auto; padding-top: 20px; width: 100%; display: flex; justify-content: space-between; align-items: center; }
#final-score-display { font-size: 28px; color: #ffde00; margin: 20px 0; }
#final-time-display { font-size: 16px; margin-top: -10px; margin-bottom: 20px; }
#game-top-bar { position: absolute; top: 0; left: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 8px; background-color: rgba(0,0,0,0.6); box-sizing: border-box; z-index: 10; font-size: 12px; }
#game-top-bar > * { flex-shrink: 0; }
#game-top-bar #score-display, #game-top-bar #time-display {
    flex-grow: 1;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5em;
}
#game-hud { position: absolute; bottom: 0; left: 0; width: 100%; display: flex; justify-content: center; align-items: center; padding: 8px; box-sizing: border-box; z-index: 10; font-size: 12px; }
#score-display { color: #ffde00; }
#time-display { color: #fff; }
#hp-gauge-container { width: 80%; height: 24px; background-color: #555; border: 2px solid #222; position: relative; overflow: hidden; }
#hp-gauge-container.red-shake { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
#hp-gauge-bar { position: absolute; top: 0; left: 0; height: 100%; width: 100%; background-color: #4caf50; transition: width 0.2s ease-out, background-color 0.3s; z-index: 2; }
#hp-gauge-preview-bar { position: absolute; top: 0; left: 0; height: 100%; width: 100%; background-color: #ff9800; transition: width 0.5s ease-in-out; z-index: 1; }
#hp-gauge-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 14px; text-shadow: 1px 1px 2px #000; z-index: 3; }
#ingame-settings-button { font-size: 20px; padding: 0; width: 30px; height: 30px; background: rgba(255,255,255,0.3); border: 1px solid #000; display: flex; justify-content: center; align-items: center; cursor: pointer; color: #fff; border-radius: 4px; margin: 0; }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }
#new-record-display { color: #0f0; font-size: 20px; margin-top: -10px; }
#new-record-subtitle { color: #fff; font-size: 14px; margin-bottom: 20px; }
.floating-text { position: absolute; font-size: 20px; font-weight: bold; pointer-events: none; animation: floatUpAndFade 1s forwards; z-index: 100; text-shadow: 1px 1px 2px rgba(0,0,0,0.7); }
.floating-text.positive { color: #0f0; }
.floating-text.negative { color: #f00; }
@keyframes floatUpAndFade { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-50px) scale(0.8); opacity: 0; } }
#fullscreen-button {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 15;
    font-size: 20px;
    padding: 0;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid #000;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
}
.vignette { position: absolute; top: 0; bottom: 0; width: 120px; pointer-events: none; z-index: 12; display: none; background: linear-gradient(to right, rgba(255, 0, 0, 0.6), transparent); opacity: 0;}
#vignette-right { right: 0; transform: scaleX(-1); }
.vignette.active { display: block; animation: flashing 1s infinite ease-in-out; }
@keyframes flashing { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
#pause-screen { background-color: rgba(0, 0, 0, 0.7); z-index: 30; }
#pause-screen h1 { font-size: 32px; margin-bottom: 30px; }
#pause-share-button, #gameover-share-button { margin-top: 15px; }
.close-icon-button { border-radius: 50%; width: 45px; height: 45px; font-size: 22px; cursor: pointer; transition: transform 0.2s; background-color: #fff; color: #000; border: 2px solid #000; margin-top: 15px; }
.close-icon-button:hover { transform: scale(1.1); }
.ui-panel { position: absolute; top: 0; left: 100%; width: 100%; height: 100%; background-color: #222; z-index: 20; transition: left 0.4s ease-in-out; display: flex; flex-direction: column; color: white; }
.ui-panel.is-open { left: 0; }
.panel-header { display: flex; align-items: center; padding: 10px; background-color: #111; }
.panel-header h2 { flex-grow: 1; text-align: center; margin: 0; font-size: 16px; }
.panel-content { flex-grow: 1; padding: 15px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.design-option { background: #333; border: 2px solid #555; padding: 10px; text-align: center; display: flex; flex-direction: column; }
.design-option h4 { margin: 0 0 10px 0; font-size: 12px; }
.preview-box { width: 100%; height: 60px; background: #444; display: flex; justify-content: center; align-items: center; margin-bottom: 10px; overflow: hidden; }
.preview-box img { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: pixelated; }
.emoji-preview { font-size: 40px; display: none; }
.design-button-container { display: flex; gap: 5px; margin-top: auto; }
.design-change-button { font-family: inherit; font-size: 12px; padding: 6px; background: #ffde00; color: #000; border: 2px solid black; cursor: pointer; flex-grow: 3; }
.design-reset-button { font-family: inherit; font-size: 12px; padding: 6px; background: #e74c3c; color: #fff; border: 2px solid #c0392b; cursor: pointer; flex-grow: 1; }
.color-picker { width: 100%; height: 60px; border: none; padding: 0; cursor: pointer; background-color: transparent; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 2px solid #555; }
.settings-option { display: flex; justify-content: space-between; align-items: center; width: 90%; max-width: 280px; margin-bottom: 20px; font-size: 16px; }
.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: #666; transition: .4s; border: 2px solid #333; }
.slider:before { position: absolute; content: ""; height: 22px; width: 22px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: #ffde00; }
input:checked + .slider:before { transform: translateX(26px); }
.rules-container { text-align: left; font-size: 12px; line-height: 1.6; overflow-y: auto; padding-right: 15px; flex-grow: 1; min-height: 0;}
.rules-container > * + * { border-top: 1px solid #ddd; padding-top: 20px; margin-top: 20px; }
.rules-container strong { display: block; margin-bottom: 4px; }
.rule-item { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: start; }
.rule-item-emoji { font-size: 14px; }
.player-name-container { display: flex; justify-content: center; align-items: center; margin-bottom: 8px; max-width: 90%; flex-shrink: 0; }
#player-name-input { margin-bottom: 0; flex-grow: 1; min-width: 0; }
.icon-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: white;
    padding: 5px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.3s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-button:active {
    transform: rotate(180deg);
    transform-origin: center;
}
hr.ui-separator { width: 80%; border: 0; height: 1px; background-color: #555; margin: 20px 0; }
#how-to-play-modal .modal-content { background-color: #ffffff; color: #333333; height: 90%; max-height: 90vh; border: 3px solid #333; display: flex; flex-direction: column; }
#how-to-play-modal h2 { color: #333333; text-shadow: none; margin-top: 15px; }
#settings-modal .modal-content { display: flex; flex-direction: column;}
.start-menu-buttons { width: 100%; padding: 0; flex-shrink: 0; display: flex; flex-wrap: wrap; justify-content: center; }
.share-button-container { width: 100%; flex-shrink: 0; margin-top: auto; padding-bottom: 10px; }
#start-menu-player-preview {
    flex-shrink: 1;
    flex-grow: 0;
    flex-basis: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 80px;
    position: relative;
}
#start-menu-player-preview canvas {
    position: static;
}
.button-container { display: flex; width: 100%; gap: 10px; padding: 0 20px; box-sizing: border-box; }
.button-container .button { flex: 1; margin: 0; padding: 12px 5px; font-size: 14px; }
.links-container { border-top: 1px solid #ddd; padding-top: 20px; margin-top: 20px; }
.social-icons { display: flex; justify-content: center; align-items: center; gap: 25px; margin-top: 10px; }
#game-over-screen .social-icons, #pause-screen .social-icons { margin-top: 20px; }
#pause-screen .social-icons img, #game-over-screen .social-icons img { filter: invert(1); }
.social-icons a { display: inline-block; }
.social-icons img { width: 32px; height: 32px; transition: transform 0.2s; }
.social-icons a:hover img { transform: scale(1.15); }

/* New Title Styles */
.title-container {
    width: 95%;
    margin-top: 20px;
    margin-bottom: 15px;
    flex-shrink: 0;
}
#title-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}
#title-text-fallback {
    font-size: 10vw;
    color: #ffde00;
    text-shadow: 2px 2px #000;
    line-height: 1;
    margin: 0;
    padding: 0;
}
.title-ver {
    position: absolute;
    top: 0;
    left: 0;
    padding: 5px 10px;
    font-family: sans-serif;
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px #000;
}
.ranking-title-container {
    margin: 0;
}
#ranking-title-fallback {
    margin: 0;
}
#ranking-title-image {
    max-width: 80%;
    height: auto;
    display: block;
    margin: 0 auto 10px auto;
}


/* Rule to hide in-game HUD on title screen */
#start-menu:not(.hidden) ~ #game-top-bar,
#start-menu:not(.hidden) ~ #game-hud {
    display: none !important;
}

#omakase-button {
    background-image: linear-gradient(to right, #ff8177 0%, #ff867a 0%, #ff8c7f 21%, #f99185 52%, #cf556c 78%, #b12a5b 100%);
    box-shadow: 0 5px 0 #8a2a4c;
    color: white;
    text-shadow: 1px 1px 2px #000;
}

#omakase-button:active {
    box-shadow: 0 2px 0 #8a2a4c;
}

#screen-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0);
    pointer-events: none;
    z-index: 999;
}

#screen-flash.flash {
    animation: flash-animation 0.5s ease-out;
}

@keyframes flash-animation {
    0% { background-color: rgba(255, 255, 255, 0.8); }
    100% { background-color: rgba(255, 255, 255, 0); }
}

#full-hp-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 998;
    opacity: 0;
    box-shadow: inset 0 0 30px 15px rgba(144, 238, 144, 0);
}

#full-hp-glow.flash-glow {
    animation: flash-green-glow 1.5s ease-out;
}

@keyframes flash-green-glow {
    0% {
        opacity: 0;
        box-shadow: inset 0 0 30px 15px rgba(144, 238, 144, 0);
    }
    30% {
        opacity: 1;
        box-shadow: inset 0 0 40px 20px rgba(144, 238, 144, 0.7);
    }
    100% {
        opacity: 0;
        box-shadow: inset 0 0 30px 15px rgba(144, 238, 144, 0);
    }
}


@media (max-height: 600px) {
    #start-menu { padding-top: 10px; }
    h3.input-label { font-size: 10px; margin-bottom: 2px; }
    .player-name-container { margin-bottom: 4px; }
    #ranking-display { margin-top: 10px; padding: 8px; }
    .start-menu-buttons { padding-bottom: 5px; }
    .button { font-size: 12px; padding: 8px 16px; margin: 5px; }
    .button-container .button { font-size: 12px; padding: 8px 5px; }
    #how-to-play-modal .modal-content { padding: 15px; }
    .rules-container { font-size: 10px; }
}

/* First Time Modal Styles */
.first-time-content {
    background-color: #2c3e50;
    border: 3px solid #ecf0f1;
}
.first-time-content h2 {
    font-size: 20px;
}
.first-time-content p {
    font-size: 12px;
}
.style-choice-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    width: 100%;
}
.style-option {
    flex: 1;
    background-color: #34495e;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #7f8c8d;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}
.style-option:hover {
    background-color: #46627f;
    transform: scale(1.05);
}
.style-option h3 {
    font-size: 14px;
    margin-top: 0;
}
.style-preview {
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0,0,0,0.2);
    border-radius: 5px;
    margin-bottom: 10px;
}
.style-preview img {
    max-width: 90%;
    max-height: 90%;
}
.style-preview .emoji-preview {
    font-size: 60px;
    display: block;
}
.style-description {
    font-size: 10px;
    min-height: 3em;
    flex-grow: 1;
}