/* Alt-mode dock — hidden on Classic; top-right pill on OS / Terminal / RPG */
.view-switcher-alt {
    position: fixed;
    z-index: 100;
    display: none;
}

body.mode-scroll #view-switcher-alt {
    display: none;
}

body.mode-os #view-switcher-alt {
    display: block;
    top: 1rem;
    right: 1rem;
    left: auto;
    bottom: auto;
}

body.mode-terminal #view-switcher-alt {
    display: block;
    top: 3.5rem;
    right: 1rem;
    left: auto;
    bottom: auto;
}

body.mode-rpg #view-switcher-alt:not(.view-switcher-rpg) {
    display: none;
}

.view-switcher-rpg {
    position: absolute !important;
    top: 0.5rem !important;
    right: 0.5rem !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 10;
    display: block !important;
}

.view-switcher-rpg .view-switcher-alt-inner {
    padding: 0.25rem 0.4rem;
    gap: 0.2rem;
}

.view-switcher-rpg .view-switch-label {
    display: none;
}

.view-switcher-rpg .view-switch-btn {
    padding: 0.3rem 0.45rem;
}

.view-switcher-rpg .view-switch-btn .material-icons {
    font-size: 1rem;
}

.view-switcher-alt-hidden {
    display: none !important;
}

.view-switcher-alt-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.65rem;
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.view-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: #e5e7eb;
    border-radius: 9999px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-switch-btn .material-icons {
    font-size: 1.1rem;
}

.view-switch-btn:hover,
.view-switch-active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
}

body.mode-scroll #view-root {
    min-height: 100vh;
}

body.mode-os #view-root,
body.mode-terminal #view-root,
body.mode-rpg #view-root {
    min-height: 100vh;
}

body.mode-scroll {
    overflow-x: hidden;
    overflow-y: auto;
}

body.mode-os,
body.mode-terminal,
body.mode-rpg {
    overflow: hidden;
}

/* Classic — portfolio mode picker */
.portfolio-mode-card-current {
    border-color: #667eea;
    background: #eef2ff;
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.15);
    cursor: default;
    transform: none !important;
}

.portfolio-mode-card-current:hover {
    border-color: #667eea;
    background: #eef2ff;
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.15);
}

/* Mati OS */
.os-desktop {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.os-wallpaper {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.os-icons {
    position: absolute;
    inset: 0;
    bottom: 2.5rem;
    z-index: 2;
    pointer-events: none;
}

.os-icon {
    position: absolute;
    width: 5.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: #fff;
    background: transparent;
    border: none;
    cursor: grab;
    font-size: 0.75rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    user-select: none;
    touch-action: none;
}

.os-icon:active,
.os-icon.os-icon-dragging {
    cursor: grabbing;
}

.os-icon.os-icon-dragging {
    opacity: 0.92;
    z-index: 5;
}

.os-icon .material-icons {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    padding: 0.35rem;
}

.os-windows {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.os-window {
    position: absolute;
    width: min(420px, 90vw);
    background: #f9fafb;
    border-radius: 0.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    pointer-events: auto;
}

.os-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #e5e7eb;
    cursor: move;
    font-weight: 600;
    font-size: 0.875rem;
}

.os-window-close {
    border: none;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.os-window-body {
    padding: 1rem;
    max-height: 360px;
    overflow-y: auto;
}

.os-link {
    color: #4338ca;
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    padding: 0;
}

.os-taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2.5rem;
    background: rgba(17, 24, 39, 0.85);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 4;
    font-size: 0.875rem;
}

/* Terminal */
.terminal-shell {
    height: 100vh;
    background: #0f172a;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    flex-direction: column;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    font-size: 0.85rem;
}

.terminal-hint {
    opacity: 0.65;
    font-size: 0.75rem;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.terminal-line {
    margin-bottom: 0.35rem;
    white-space: pre-wrap;
}

.terminal-echo {
    color: #94a3b8;
}

.terminal-error {
    color: #f87171;
}

.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #334155;
    background: #1e293b;
}

.terminal-prompt {
    color: #4ade80;
    white-space: nowrap;
    font-size: 0.875rem;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #f8fafc;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
}

/* RPG — GBC / Pokémon-style pixel world */
.rpg-shell {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #080810;
    overflow: hidden;
}

.rpg-phaser-host {
    width: min(960px, 96vw);
    height: min(540px, calc(100vh - 3rem));
    border-radius: 0;
    overflow: hidden;
    box-shadow:
        0 0 0 4px #1a1a2e,
        0 0 0 8px #f8f8f0,
        0 16px 40px rgba(0, 0, 0, 0.6);
    image-rendering: pixelated;
}

.rpg-phaser-host canvas {
    image-rendering: pixelated;
}

.rpg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    animation: rpg-pulse 1.4s ease-in-out infinite;
}

@keyframes rpg-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.rpg-canvas {
    max-width: 100%;
    border-radius: 0.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    background: #1f2937;
}

.rpg-hud {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.65rem;
    align-items: center;
    background: #f8f8f0;
    color: #1a1a2e;
    padding: 0.45rem 1rem;
    border: 3px solid #1a1a2e;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    box-shadow: 4px 4px 0 #1a1a2e;
    z-index: 4;
    --zone-accent: #306230;
    transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.rpg-hud::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--zone-accent);
    border: 2px solid #1a1a2e;
    flex-shrink: 0;
}

.rpg-zone-label {
    color: var(--zone-accent);
    transition: color 0.35s ease;
}

.rpg-journal {
    color: #444;
    font-size: 0.42rem;
    white-space: nowrap;
}

.rpg-hud-sep {
    color: #aaa;
    font-size: 0.45rem;
}

.rpg-hint {
    color: #555;
    font-size: 0.45rem;
}

.rpg-zone-banner {
    position: absolute;
    top: 4.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    pointer-events: none;
    padding: 0.35rem 0.9rem;
    background: #f8f8f0ee;
    border: 3px solid #1a1a2e;
    box-shadow: 3px 3px 0 #1a1a2e;
    font-family: 'Press Start 2P', monospace;
    opacity: 0;
    --zone-accent: #306230;
}

.rpg-zone-banner.hidden {
    display: none;
}

.rpg-zone-banner-in {
    animation: rpg-zone-banner-in 0.28s ease forwards;
}

.rpg-zone-banner-out {
    animation: rpg-zone-banner-out 0.32s ease forwards;
}

.rpg-zone-banner-text {
    display: block;
    font-size: 0.48rem;
    color: var(--zone-accent);
    text-align: center;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

@keyframes rpg-zone-banner-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes rpg-zone-banner-out {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
}

.rpg-dialog {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, 92vw);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: #f8f8f0;
    color: #1a1a2e;
    border: 4px solid #1a1a2e;
    padding: 1rem;
    z-index: 5;
    box-shadow: 6px 6px 0 #1a1a2e;
    font-family: 'Press Start 2P', monospace;
}

.rpg-dialog.hidden {
    display: none;
}

.rpg-dialog-portrait {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border: 3px solid #1a1a2e;
    background: #306230;
    image-rendering: pixelated;
    overflow: hidden;
}

.rpg-portrait-sprite {
    background-repeat: no-repeat;
    background-color: #9bbc0f;
}

.rpg-portrait-empty {
    background: #306230;
}

.rpg-dialog-body {
    flex: 1;
    min-width: 0;
}

.rpg-dialog-text {
    margin-bottom: 0.75rem;
    line-height: 1.85;
    font-size: 0.55rem;
    min-height: 2.8rem;
    word-break: break-word;
}

.rpg-dialog-speaking .rpg-dialog-text::after {
    content: ' ▼';
    animation: rpg-cursor-blink 0.55s step-end infinite;
}

@keyframes rpg-cursor-blink {
    50% { opacity: 0; }
}

.rpg-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rpg-dialog-actions-hidden {
    visibility: hidden;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    margin: 0;
}

.rpg-dialog-btn {
    background: #306230;
    color: #f8f8f0;
    border: 2px solid #1a1a2e;
    border-radius: 0;
    padding: 0.4rem 0.65rem;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    cursor: pointer;
    box-shadow: 2px 2px 0 #1a1a2e;
    transition: transform 0.1s ease;
}

.rpg-dialog-btn:hover,
.rpg-dialog-btn-selected {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #1a1a2e;
}

.rpg-dialog-btn-selected {
    background: #ffd700;
    color: #1a1a2e;
    outline: 2px solid #1a1a2e;
    outline-offset: 1px;
}

.rpg-shell.rpg-cutscene-active .rpg-dialog {
    z-index: 5;
}

@media (max-width: 640px) {
    .view-switch-label {
        display: none;
    }

    .view-switch-btn {
        padding: 0.45rem;
    }

    .os-icon {
        width: 4.5rem;
    }
}
