html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #1a1625;
    width: 100vw;
    height: 100svh; /* Use small viewport height to exclude browser UI */
    height: 100dvh; /* Fallback to dynamic viewport height */
    position: fixed;
    top: 0;
    left: 0;
    /* Mobile optimizations */
    overscroll-behavior: none;
    touch-action: none;
    -webkit-overflow-scrolling: touch;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    /* Prevent touch callouts and selections on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Textarea for text entry - visible and styled to match canvas */
.mobile-input {
    position: fixed;
    display: none; /* Hidden by default, shown via JS when needed */
    z-index: 1000; /* High z-index to be above canvas */

    /* Match canvas paper aesthetic */
    background: #e0d4b8; /* Lighter paper for input areas (matches canvas) */
    border: none; /* No border - canvas draws the border */
    border-radius: 0; /* Sharp corners like canvas */

    /* Text styling to match canvas exactly */
    font-family: monospace;
    font-size: 16px; /* Prevents iOS zoom on focus */
    line-height: 22px;
    color: #2a1f1a; /* Dark brown text */
    padding: 8px 10px; /* Match canvas text positioning */

    /* Prevent default behaviors */
    resize: none;
    outline: none;
    box-sizing: border-box;

    /* Enable interaction */
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;

    /* Mobile optimizations */
    -webkit-text-size-adjust: 100%;
    touch-action: auto;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-panel {
    background: #f5ead0;
    border: 3px solid #8b7355;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    min-width: 350px;
    max-width: 90%;
    position: relative;
}

.auth-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 15px;
    background: #d4c4a8;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.auth-panel::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 15px;
    background: #d4c4a8;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}

.auth-panel h2 {
    font-family: serif;
    font-size: 26px;
    font-style: italic;
    color: #1a1a2e;
    text-align: center;
    margin: 0 0 30px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #b89650;
}

.auth-field {
    margin-bottom: 20px;
}

.auth-field label {
    display: block;
    font-family: serif;
    font-size: 16px;
    font-weight: bold;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.auth-field input {
    width: 100%;
    padding: 12px 15px;
    font-family: serif;
    font-size: 16px;
    color: #1a1a2e;
    background: #fff;
    border: 2px solid #b89650;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.auth-field input:focus {
    outline: none;
    border-color: #8b7355;
}

.auth-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.auth-btn {
    flex: 1;
    padding: 12px 20px;
    font-family: serif;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #b89650;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-btn-primary {
    background: #5a8a7a;
    color: #f5ead0;
}

.auth-btn-primary:hover {
    background: #7aa896;
}

.auth-btn-secondary {
    background: #6b5545;
    color: #f5ead0;
}

.auth-btn-secondary:hover {
    background: #8b7555;
}

.auth-error {
    margin-top: 15px;
    padding: 12px;
    background: #ffebe9;
    border: 2px solid #c74343;
    border-radius: 4px;
    color: #8b2020;
    font-family: serif;
    font-size: 14px;
    text-align: center;
}
