/* Game Boy shell - only visible on mobile */
#gameboy-shell {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #c8c8c8 0%, #a8a8a8 40%, #989898 100%);
    position: fixed;
    top: 0;
    left: 0;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

#gameboy-shell.active {
    display: flex;
}

/* Top section: branding above screen */
.gb-top-label {
    width: 90%;
    max-width: 400px;
    text-align: left;
    padding: 38px 12px 0;
    font-family: monospace;
    font-size: 7px;
    letter-spacing: 1px;
    color: #666;
    font-weight: bold;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* Screen bezel area */
#gameboy-screen-bezel {
    width: 92%;
    max-width: 400px;
    aspect-ratio: 3 / 4.25;
    background: linear-gradient(145deg, #3a3a4a 0%, #2a2a35 100%);
    border-radius: 12px;
    padding: 10px;
    position: relative;
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.5),
        0 3px 6px rgba(0,0,0,0.3);
    flex-shrink: 1;
    min-height: 0;
    margin-top: 4px;
}

/* Power LED */
#gameboy-screen-bezel::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 6px #4caf50, 0 0 12px rgba(76, 175, 80, 0.4);
    animation: ledPulse 3s ease-in-out infinite;
}

@keyframes ledPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Screen label */
.gb-screen-label {
    font-family: monospace;
    font-size: 6px;
    letter-spacing: 2px;
    color: #888;
    text-align: center;
    margin-bottom: 4px;
    text-transform: uppercase;
}

/* Canvas inside the bezel */
#gameboy-screen-bezel canvas {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Brand text below screen */
.gb-brand {
    font-family: monospace;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 3px;
    color: #445;
    text-align: center;
    margin-top: 6px;
    flex-shrink: 0;
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

/* Controls area */
#gameboy-controls {
    flex: 0 0 auto;
    width: 100%;
    max-width: 440px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 16px 20px 12px;
    gap: 12px 0;
}

/* Joystick zone */
#joystick-area {
    display: flex;
    justify-content: center;
    align-items: center;
    grid-column: 1;
    grid-row: 1;
}

#joystick-zone {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(40,40,40,0.3) 0%, rgba(40,40,40,0.15) 70%, transparent 100%);
    border: 2px solid rgba(60,60,60,0.4);
    position: relative;
}

#joystick-knob {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #555 0%, #333 100%);
    border: 2px solid #222;
    box-shadow:
        0 2px 6px rgba(0,0,0,0.5),
        inset 0 1px 2px rgba(255,255,255,0.15);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.05s;
}

#joystick-knob.active {
    background: radial-gradient(circle at 35% 35%, #666 0%, #444 100%);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.5),
        inset 0 1px 2px rgba(255,255,255,0.2);
}

/* Action buttons area */
#action-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    grid-column: 2;
    grid-row: 1;
    transform: rotate(-25deg);
}

.action-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(145deg, #8b2252 0%, #6b1a42 100%);
    border: 2px solid #4a1030;
    box-shadow:
        0 4px 6px rgba(0,0,0,0.4),
        inset 0 1px 2px rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c88;
    font-family: monospace;
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 1px;
    transition: box-shadow 0.05s, transform 0.05s;
}

.action-btn:active, .action-btn.pressed {
    box-shadow:
        0 1px 2px rgba(0,0,0,0.4),
        inset 0 2px 4px rgba(0,0,0,0.3);
    transform: scale(0.95);
    background: linear-gradient(145deg, #6b1a42 0%, #4a1030 100%);
}

/* Meta buttons (START / SELECT) */
#meta-buttons {
    grid-column: 1 / 3;
    grid-row: 2;
    display: flex;
    justify-content: center;
    gap: 32px;
    padding-bottom: 0;
    margin-top: 30px;
}

.meta-btn {
    width: 64px;
    height: 20px;
    border-radius: 10px;
    background: linear-gradient(180deg, #555 0%, #444 100%);
    border: 1px solid #333;
    box-shadow: 0 2px 3px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-family: monospace;
    font-size: 8px;
    letter-spacing: 2px;
    font-weight: bold;
    text-transform: uppercase;
    transition: background 0.05s;
}

.meta-btn:active, .meta-btn.pressed {
    background: linear-gradient(180deg, #444 0%, #333 100%);
    box-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

/* Speaker grille */
.gb-speaker {
    position: fixed;
    bottom: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transform: rotate(-30deg);
}

.gb-speaker-line {
    width: 32px;
    height: 2px;
    background: #888;
    border-radius: 1px;
    opacity: 0.5;
}

/* Landscape orientation warning */
#orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    color: #fff;
    font-family: monospace;
    text-align: center;
}

#orientation-warning .rotate-icon {
    font-size: 48px;
    animation: rotateHint 2s ease-in-out infinite;
}

@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

#orientation-warning p {
    font-size: 16px;
    color: #aaa;
}

/* Show warning in landscape on mobile */
@media (orientation: landscape) and (max-height: 500px) {
    #orientation-warning {
        display: flex !important;
    }
}

/* Hide the bare canvas on mobile (it's inside the shell) */
body.mobile-mode > canvas {
    display: none;
}
