* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    overflow: hidden;
    background: #001f3f;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
}

#game-container {
    position: relative;
    width: 100vw;
    max-width: 480px;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: #004080;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #0066cc;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#hello-world {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #00d4ff;
    z-index: 100;
    pointer-events: auto;
    background: #004080;
}

#hello-world h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

#hello-world p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #f5f5f5;
}

#startButton {
    padding: 15px 40px;
    font-size: 1.2rem;
    background: #00aaff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#startButton:hover {
    background: #0088cc;
    transform: scale(1.05);
}

#startButton:active {
    transform: scale(0.95);
}

.difficulty-btn {
    padding: 10px 15px;
    font-size: 0.9rem;
    background: #3498DB;
    color: white;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.difficulty-btn:hover {
    background: #2980B9;
    transform: scale(1.05);
}

.difficulty-btn.active {
    background: #00aaff;
    border-color: #00ffcc;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

.difficulty-btn:active {
    transform: scale(0.95);
}

.preview-characters {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: none; /* Hidden by default, shown only on start screen */
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 40px 20px 40px;
    pointer-events: none;
    z-index: 101; /* Above title screen */
}

#preview-fred {
    font-size: 70px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
    line-height: 1;
    transform: scaleX(-1);
}

#preview-octavia {
    font-size: 70px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
    line-height: 1;
}

/* Portrait mode optimization */
@media screen and (orientation: portrait) {
    #game-container {
        max-width: 100vw;
    }
}

/* Save/Load Progress UI */
#load-progress-container {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 110;
}

#loadProgressBtn {
    background: rgba(44, 62, 80, 0.8);
    color: #ecf0f1;
    border: 2px solid rgba(236, 240, 241, 0.5);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

#loadProgressBtn:hover {
    background: rgba(44, 62, 80, 0.95);
    border-color: #ecf0f1;
    transform: scale(1.05);
}

#loadProgressForm {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    align-items: center;
}

#loadCodeInput {
    padding: 6px 10px;
    border: 2px solid #3498db;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 135px;
    text-transform: uppercase;
    font-family: monospace;
    background: rgba(255, 255, 255, 0.95);
}

#loadCodeSubmit, #loadCodeCancel {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: bold;
}

#loadCodeSubmit {
    background: #4caf50;
    color: white;
}

#loadCodeSubmit:hover {
    background: #45a049;
}

#loadCodeCancel {
    background: #e74c3c;
    color: white;
    padding: 6px 10px;
}

#loadCodeCancel:hover {
    background: #c0392b;
}

/* Landscape warning (optional) */
@media screen and (orientation: landscape) {
    body::before {
        content: "Please rotate your device to portrait mode";
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.9);
        color: white;
        padding: 20px;
        border-radius: 10px;
        z-index: 1000;
        text-align: center;
        display: none;
    }
}
