html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}
body {
    font-family: 'Press Start 2P', cursive;
    background-color: #18181b;
    color: #f4f4f5;
    display: flex;
    justify-content: center;
    align-items: center;
}
.page-container {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "header header"
        "main   leaderboard"
        "footer footer";
    height: 95vh;
    max-height: 900px;
    max-width: 80rem;
    width: 100%;
    gap: 1rem;
    padding: 1rem;
    box-sizing: border-box;
}
.hud-container { grid-area: header; }
.game-wrapper { grid-area: main; min-height: 0; display: flex; }
.leaderboard-panel { 
    grid-area: leaderboard;
    display: flex; 
    flex-direction: column;
    background-color: #27272a;
    border-radius: 0.5rem;
    padding: 1rem;
    border: 2px solid #a1a1aa;
    min-height: 0;
}
.global-footer { grid-area: footer; }
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.hud-element {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 2px solid #a1a1aa;
    letter-spacing: 1px;
    white-space: nowrap;
    display: flex;
    align-items: center;
}
.hud-element svg {
    width: 1.25rem;
    height: 1.25rem;
}
#muteBtn {
    background: transparent;
    color: #f4f4f5;
    cursor: pointer;
}
.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: #27272a;
    border: 2px solid #a1a1aa;
    aspect-ratio: 16 / 9;
}
.canvas-container.shake {
    animation: screen-shake 0.15s ease-in-out;
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #1e1e1e;
}
.modal {
    position: absolute;
    inset: 0;
    background-color: rgba(24, 24, 27, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 100;
    text-align: center;
}
.modal-header { padding-bottom: 1rem; }
.modal-body { flex-grow: 1; overflow-y: auto; width: 100%; min-height: 0; display: flex; justify-content: center; align-items: center; }
.modal-footer { display: flex; flex-direction: column; align-items: center; padding-top: 1rem; width: 100%;}
.modal-title { font-size: 2.25rem; letter-spacing: 2px; color: white; margin-bottom: 0.5rem; }
.modal-subtitle { font-size: 1rem; letter-spacing: 1px; color: #facc15; margin-bottom: 1.5rem;}
.game-over-title { font-size: 1.75rem; }
.final-score-text { font-size: 1.25rem; color: #f4f4f5; margin-bottom: 0.5rem; }
.leaderboard-rank-text { font-size: 1.1rem; color: #facc15; }
.intro-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    max-width: 40rem;
    width: 100%;
}
.instruction-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.instruction-item p {
    font-size: 0.8rem;
    margin: 0;
}
.icon-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.instruction-icon {
    height: 40px;
    width: auto;
}
.arrow {
    font-size: 1.5rem;
    color: #facc15;
}
.player-name-input {
    background-color: #3f3f46;
    color: white;
    width: 100%;
    max-width: 20rem;
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    border: 2px solid #71717a;
    margin-bottom: 1rem;
    font-family: 'Press Start 2P', cursive;
}
.player-name-input:focus {
    outline: none;
    border-color: #4ade80;
}
.player-name-input.shake-input {
    animation: input-shake 0.4s;
}
@keyframes input-shake {
    10%, 90% { transform: translateX(-3px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}
.btn-primary, .btn-secondary {
    color: white;
    font-family: 'Press Start 2P', cursive;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
    text-align: center;
}
.btn-primary { background-color: #4ade80; }
.btn-primary:hover { background-color: #22c55e; }
.btn-secondary { background-color: #60a5fa; }
.btn-secondary:hover { background-color: #3b82f6; }
.modal-footer-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}
.leaderboard-panel-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    color: #facc15;
}
.leaderboard-box {
    background: #18181b;
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    overflow-y: auto;
    flex-grow: 1;
}
.leaderboard-box > div {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem;
    border-bottom: 1px solid #3f3f46;
}
.leaderboard-box > div:last-child {
    border-bottom: none;
}
.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}
.footer-logo {
    height: 2rem;
    transition: transform 0.2s ease-in-out;
    color: #a1a1aa;
}
.footer-logo.large { height: 2.5rem; }
.footer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #a1a1aa;
    transition: color 0.2s;
}
.footer-link:hover { color: #f4f4f5; }
.footer-link:hover .footer-logo { transform: scale(1.1); }
@keyframes screen-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}
#comboMeter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: bold;
    color: #facc15;
    text-shadow: 0 0 10px #f59e0b;
    pointer-events: none;
    transition: transform 0.1s;
}
#comboMeter.pop {
    animation: combo-pop-animation 0.2s;
}
@keyframes combo-pop-animation {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.2); }
    100% { transform: translateX(-50%) scale(1); }
}
#scorePopContainer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
}
.score-pop {
    position: absolute;
    font-size: 1.25rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 101;
    animation: score-pop-animation 1s ease-out forwards;
}
.score-positive {
    color: #fde047;
    text-shadow: 0 0 5px #f59e0b;
}
@keyframes score-pop-animation {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -50px); opacity: 0; }
}
#messageContainer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: bold;
    text-shadow: 0 0 10px black;
    pointer-events: none;
    z-index: 100;
    animation: message-fade 2s ease-out forwards;
}
@keyframes message-fade {
    0%, 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}
.hidden {
    display: none !important;
}
@media (max-width: 1023px) {
    .page-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "header"
            "main"
            "footer";
        height: 100vh;
        padding: 0.5rem;
    }
    .leaderboard-panel {
        display: none;
    }
    .modal-footer-buttons {
        flex-direction: column;
    }
}
@media (max-width: 640px) {
    .modal-title { font-size: 1.5rem; }
    .modal-subtitle { font-size: 0.8rem; }
    .btn-primary, .btn-secondary { font-size: 0.9rem; }
    .hud-element { font-size: 0.7rem; padding: 0.5rem; }
    .instruction-item p { font-size: 0.7rem; }
    .instruction-icon { height: 30px; width: auto; }
}
@media (min-width: 1024px) {
    #leaderboardBtn {
        display: none;
    }
}
