body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: #ddd;
    overflow: hidden;
    background: #222;
    padding: 0;
    margin: 0;
}

#app {
    position: relative;
    margin: 0 auto;
    background: #222;
    font-size: 14px;
    box-shadow: 5px 5px 10px -5px #000;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#logo {
    pointer-events: none;
    position: relative;
    z-index: 10;
    padding: 5px 0;
    width: 100%;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

#logo img {
    transition: all 0.5s ease;
    width: 10%;
}

#logo.play-status img {
    width: 6%;
}

#container {
    width: 100%;
    flex: 1;
    position: relative;
    overflow: hidden;
}

#container>div {
    width: 100%;
    height: 100%;
    padding-top: 5%;
    visibility: hidden;
    text-align: center;
    opacity: 0;
}

#container #play {
    padding-top: 0;
}

#container>div.action {
    visibility: visible;
    opacity: 1;
    transition: all 0.2s ease;
}

/* Auto-start countdown timer */
#auto-start-countdown {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

#countdown-number {
    color: #ffff00;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 0 0 20px #ffff00, 0 0 40px #ffff00, 3px 3px 6px rgba(0, 0, 0, 0.9);
    display: block;
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

#start-btn p:nth-child(2) {
    display: none;
}

#start-btn:disabled p:nth-child(1) {
    display: none;
}

#start-btn:disabled p:nth-child(2) {
    display: block;
}

#play {
    background: transparent;
    padding-top: 0 !important;
    display: flex;
    flex-direction: column;
}

#canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
    pointer-events: none;
    touch-action: none;
    -webkit-touch-action: none;
    -ms-touch-action: none;
}

.content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 2;
}

.content .header {
    user-select: none;
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
}

.content .header ul {
    width: 45%;
    height: 50px;
    font-size: 20px;
}

.content .header li img {
    width: 30px;
    height: 30px;
    margin-right: 5px;
}

.content .header ul,
.content .header ul li {
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.content .header .option img {
    cursor: pointer;
}

.content .header .option img:nth-child(2) {
    display: none;
}

.content .header .option li:active {
    opacity: 0.5;
}

.content .header .option li.active img:nth-child(1) {
    display: none;
}

.content .header .option li.active img:nth-child(2) {
    display: block;
}

#over {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.game-over-title {
    font-size: 3rem;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 0 0 20px #ff0000, 0 0 30px #ff0000;
    margin: 0;
    letter-spacing: 0.1em;
}

#over .game-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#over .message {
    margin: 0;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#over .message img {
    width: 30px;
    height: 30px;
}

#over .message span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    width: 20%;
}

#over .message span:nth-last-child(1) {
    width: auto;
    padding-left: 10px;
}

table {
    height: 80%;
    overflow: hidden;
}

footer{
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 5px;
    color: #666;
    font-size: .7rem;
    opacity: 0.6;
    z-index: 11;
    text-align: center;
}
footer a{
    color: inherit;
    text-decoration: none;
}

#start.action ~ footer,
#rank.action ~ footer {
    display: flex;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
        background: #000;
    }

    #app {
        margin: 0;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        background: #000;
    }

    #logo {
        padding: 6px 0;
    }

    body #app #logo {
        background: transparent;
    }

    #logo img {
        width: 12%;
    }

    #app > #logo {
        display: none;
    }

    #start::before {
        content: '';
        display: block;
        width: 100%;
        height: 120px;
        background: url('../img/logo-01.png') no-repeat center;
        background-size: contain;
        max-width: 280px;
        margin: 0 auto 40px;
    }

    #logo.play-status {
        padding: 4px 0;
    }

    #logo.play-status img {
        width: 8%;
    }

    #container>div {
        padding-top: 3%;
    }

    #play {
        padding-top: 0 !important;
    }

    #logo.play-status {
        padding: 3px 0;
        background: transparent;
    }

    .message {
        font-size: 0.85rem;
        padding: 0 10px;
    }

    #start .message {
        display: none;
    }

    #start {
        justify-content: center;
        padding-top: 0;
        gap: 40px;
    }

    #start.action {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    #countdown-number {
        font-size: 2.5rem;
    }

    .btn {
        font-size: 0.9rem;
        padding: 8px 20px;
        margin: 10px auto;
    }

    .content .header {
        flex-direction: row;
        flex-wrap: wrap;
        height: auto;
        padding: 3px 5px;
        gap: 5px;
    }

    .content .header ul {
        width: auto;
        flex: 1;
        min-width: 200px;
        height: auto;
        font-size: 14px;
        margin: 0;
    }

    .content .header li img {
        width: 20px;
        height: 20px;
    }

    .content .header li {
        margin: 0 3px;
    }

    .content .header .option {
        justify-content: flex-end;
        gap: 8px;
    }

    .game-over-title {
        font-size: 2.5rem;
    }

    #over .message {
        margin: 0;
        width: auto;
        font-size: 0.9rem;
    }

    #over .message span {
        height: 50px;
    }

    table {
        font-size: 0.85rem;
    }

    tbody tr {
        height: 40px;
    }

    footer {
        font-size: 0.7rem;
        padding-bottom: 5px;
    }

    .mobile-controls {
        height: 150px;
        padding: 5px 15px;
    }

    footer {
        display: none !important;
    }
}

@media screen and (max-width: 480px) {
    #app {
        max-width: 100vw;
        margin: 0;
        border-radius: 0;
    }

    #logo img {
        width: 15%;
    }

    #app > #logo {
        display: none;
    }

    #start::before {
        content: '';
        display: block;
        width: 100%;
        height: 110px;
        background: url('../img/logo-01.png') no-repeat center;
        background-size: contain;
        max-width: 260px;
        margin: 0 auto 35px;
    }

    #logo.play-status img {
        width: 8%;
    }

    .message {
        font-size: 0.7rem;
        line-height: 1.5;
    }

    #start .message {
        display: none;
    }

    #start.action {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 35px;
    }

    #countdown-number {
        font-size: 2rem;
    }

    .btn {
        font-size: 0.85rem;
        padding: 6px 15px;
    }

    .content .header {
        padding: 2px 3px;
    }

    #logo.play-status {
        padding: 4px 0;
    }

    #container>div {
        padding-top: 2%;
    }

    #start.action {
        padding-top: 0;
    }

    .content .header {
        background: rgba(0, 0, 0, 0.5);
    }

    .content .header ul {
        font-size: 11px;
        justify-content: space-between;
        padding: 0;
        min-width: 140px;
        height: 35px;
    }

    .content .header li {
        margin: 0 1px;
    }

    .content .header li img {
        width: 16px;
        height: 16px;
        margin-right: 2px;
    }

    .content .header .option img {
        width: 26px;
        height: 26px;
        padding: 2px;
    }

    .game-over-title {
        font-size: 2rem;
    }

    #over .message {
        margin: 0;
        width: auto;
    }

    #over .message span {
        height: 45px;
        font-size: 0.85rem;
    }

    table {
        font-size: 0.75rem;
    }

    tbody tr {
        height: 35px;
    }

    .mobile-controls {
        height: 120px;
        padding: 5px 10px;
    }

    .dpad {
        width: 110px;
        height: 110px;
    }
    .joystick {
        width: 110px;
        height: 110px;
    }
    .joystick-knob {
        width: 48px;
        height: 48px;
    }

    .control-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
        border-width: 1.5px;
    }

    .btn-shoot {
        width: 55px;
        height: 55px;
        font-size: 11px;
        letter-spacing: 0.5px;
    }
}

/* Mobile Touch Controls */
.mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 180px;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 10px 20px;
    pointer-events: none;
    z-index: 10;
    margin-top: auto;
}

.mobile-controls .joystick,
.mobile-controls .action-buttons {
    pointer-events: auto;
}

.dpad {
    position: relative;
    width: 140px;
    height: 140px;
}

.joystick {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(80, 140, 255, 0.25), rgba(0, 0, 0, 0.4));
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0,0,0,0.35), inset 0 4px 12px rgba(255,255,255,0.08);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -ms-touch-action: none;
}

.joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(180, 200, 255, 0.6), rgba(70, 120, 240, 0.9));
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 18px rgba(0,0,0,0.45), inset 0 3px 8px rgba(255,255,255,0.25);
}

.control-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(30, 30, 30, 0.7);
    color: white;
    font-size: 20px;
    border-radius: 10px;
    cursor: pointer;
    outline: none;
    user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    font-weight: bold;
}

.control-btn:active {
    background: rgba(100, 100, 100, 0.8);
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.btn-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.btn-up:active {
    transform: translateX(-50%) scale(0.95);
}

.btn-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.btn-down:active {
    transform: translateX(-50%) scale(0.95);
}

.btn-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.btn-left:active {
    transform: translateY(-50%) scale(0.95);
}

.btn-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.btn-right:active {
    transform: translateY(-50%) scale(0.95);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-shoot {
    position: static;
    width: 70px;
    height: 70px;
    font-size: 14px;
    font-weight: bold;
    background: rgba(220, 20, 60, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    letter-spacing: 1px;
}

.btn-shoot:active {
    background: rgba(255, 50, 80, 0.9);
    box-shadow: 0 0 15px rgba(255, 50, 80, 0.8);
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 100px;
    }

    .content .header .option img {
        width: 35px;
        height: 35px;
        padding: 5px;
    }

    .content .header .option li {
        padding: 5px;
    }

    .mobile-controls {
        display: flex;
    }
}

@media screen and (max-width: 768px) {
    .mobile-controls {
        display: flex;
    }
}