/* ========================================
   Super Mario - UI Components & Editor
   ======================================== */

/* ========================================
   Level Editor Panel
   ======================================== */

#editor-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--ui-bg);
    border-left: 1px solid var(--ui-border);
    z-index: 150;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#editor-panel.active {
    display: flex;
}

.editor-header {
    padding: 16px;
    border-bottom: 1px solid var(--ui-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h3 {
    font-size: 14px;
    letter-spacing: 2px;
}

.editor-close {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--ui-border);
    border-radius: 50%;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.editor-close:hover {
    background: var(--mario-red);
    border-color: var(--mario-red);
}

.editor-tools {
    padding: 12px;
    border-bottom: 1px solid var(--ui-border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.editor-tool-btn {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.editor-tool-btn:hover {
    background: rgba(255,255,255,0.15);
}

.editor-tool-btn.active {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
}

.editor-tiles {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.tile-category {
    margin-bottom: 16px;
}

.tile-category h4 {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.tile-option {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(255,255,255,0.06);
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
    position: relative;
}

.tile-option:hover {
    background: rgba(255,255,255,0.12);
    border-color: var(--ui-border);
}

.tile-option.selected {
    border-color: var(--ui-accent);
    background: rgba(229, 37, 33, 0.2);
}

.tile-option .tile-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
    display: none;
}

.tile-option:hover .tile-label {
    display: block;
}

.editor-actions {
    padding: 12px;
    border-top: 1px solid var(--ui-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-btn {
    padding: 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    color: white;
    font-family: var(--font-pixel);
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.editor-btn:hover {
    background: rgba(255,255,255,0.15);
}

.editor-btn.primary {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
}

.editor-btn.primary:hover {
    background: var(--ui-accent-hover);
}

/* ========================================
   Notification Toast
   ======================================== */

.toast-container {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 24px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: var(--border-radius);
    font-size: 13px;
    letter-spacing: 1px;
    white-space: nowrap;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}

.toast.success {
    border-color: var(--ui-success);
    color: var(--ui-success);
}

.toast.warning {
    border-color: var(--ui-warning);
    color: var(--ui-warning);
}

.toast.error {
    border-color: var(--ui-accent);
    color: var(--ui-accent);
}

@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ========================================
   Dialog Modal
   ======================================== */

.dialog-overlay {
    position: absolute;
    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: 300;
    animation: fadeIn 0.2s ease;
}

.dialog {
    background: #1a1a2e;
    border: 1px solid var(--ui-border);
    border-radius: var(--border-radius-lg);
    padding: 30px;
    max-width: 400px;
    width: 90%;
    animation: bounceIn 0.4s ease;
}

.dialog h3 {
    font-size: 18px;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.dialog p {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
    margin-bottom: 24px;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.dialog-btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: 1px solid var(--ui-border);
    background: rgba(255,255,255,0.08);
    color: white;
    font-family: var(--font-pixel);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dialog-btn:hover {
    background: rgba(255,255,255,0.15);
}

.dialog-btn.danger {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
}

.dialog-btn.danger:hover {
    background: var(--ui-accent-hover);
}

/* ========================================
   Tooltip
   ======================================== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: #1a1a2e;
    border: 1px solid var(--ui-border);
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 100;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ========================================
   Progress Bar Component
   ======================================== */

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--mario-red), var(--coin-gold));
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ========================================
   Transition Overlay
   ======================================== */

#transition-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 180;
    display: none;
    pointer-events: none;
}

#transition-overlay.circle-wipe {
    display: block;
    animation: circleWipe 1s ease-in forwards;
}

#transition-overlay.circle-open {
    display: block;
    animation: circleOpen 1s ease-out forwards;
}

@keyframes circleWipe {
    0% {
        clip-path: circle(100% at 50% 50%);
    }
    100% {
        clip-path: circle(0% at 50% 50%);
    }
}

@keyframes circleOpen {
    0% {
        clip-path: circle(0% at 50% 50%);
    }
    100% {
        clip-path: circle(100% at 50% 50%);
    }
}

/* ========================================
   World Map (Level Select)
   ======================================== */

#world-map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    z-index: 90;
    display: none;
}

#world-map.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.world-path {
    position: relative;
    width: 80%;
    height: 60%;
}

.world-node {
    position: absolute;
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.1);
    border: 2px solid var(--ui-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.world-node:hover {
    transform: scale(1.15);
    background: rgba(255,255,255,0.2);
}

.world-node.current {
    border-color: var(--ui-accent);
    background: rgba(229, 37, 33, 0.3);
    animation: pulse 2s ease infinite;
}

.world-node.completed {
    border-color: var(--ui-success);
    background: rgba(67, 176, 71, 0.3);
}

.world-node.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

.world-node.locked:hover {
    transform: none;
}

/* ========================================
   Death Animation Overlay
   ======================================== */

#death-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 160;
    display: none;
    pointer-events: none;
}

#death-overlay.active {
    display: block;
    animation: deathFade 2s ease forwards;
}

@keyframes deathFade {
    0% { background: transparent; }
    50% { background: transparent; }
    100% { background: #000; }
}

/* ========================================
   Editor Grid Overlay
   ======================================== */

.editor-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 140;
    opacity: 0.15;
    display: none;
}

.editor-grid-overlay.active {
    display: block;
}

/* ========================================
   Mobile Landscape Warning
   ======================================== */

#rotate-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    color: white;
    font-size: 18px;
}

#rotate-warning .rotate-icon {
    font-size: 48px;
    animation: float 2s ease infinite;
}

@media (orientation: portrait) and (max-width: 768px) {
    #rotate-warning {
        display: flex;
    }

    #game-container {
        display: none;
    }
}

/* ========================================
   Keyboard Hints
   ======================================== */

.key-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    font-size: 11px;
    color: rgba(255,255,255,0.6);
}

/* ========================================
   Custom cursor when in editor
   ======================================== */

.editor-cursor {
    cursor: crosshair;
}

/* ========================================
   Pipe Transition Animation
   ======================================== */

.pipe-transition {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 170;
    display: none;
}

.pipe-transition.active {
    display: block;
}

/* ========================================
   Star Power Effect (Invincibility)
   ======================================== */

@keyframes starPower {
    0% { filter: hue-rotate(0deg) brightness(1.3); }
    25% { filter: hue-rotate(90deg) brightness(1.5); }
    50% { filter: hue-rotate(180deg) brightness(1.3); }
    75% { filter: hue-rotate(270deg) brightness(1.5); }
    100% { filter: hue-rotate(360deg) brightness(1.3); }
}

.star-power-active #game-canvas {
    animation: starPower 0.5s linear infinite;
}

/* ========================================
   Coin Counter Animation
   ======================================== */

@keyframes coinPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); color: var(--coin-gold); }
    100% { transform: scale(1); }
}

.coin-pop {
    animation: coinPop 0.3s ease;
}

/* ========================================
   Editor Minimap
   ======================================== */

.editor-minimap {
    height: 80px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    margin: 8px 12px;
    position: relative;
    overflow: hidden;
}

.minimap-viewport {
    position: absolute;
    top: 0;
    height: 100%;
    border: 1px solid var(--ui-accent);
    background: rgba(229, 37, 33, 0.1);
    border-radius: 2px;
}

/* ========================================
   Cheat Menu
   ======================================== */

#cheat-menu.menu-screen {
    background: rgba(0, 0, 0, 0.95);
    padding: 16px;
    flex-direction: column;
}

#cheat-menu.menu-screen.hidden {
    display: none !important;
}

.cheat-panel {
    max-width: 480px;
    width: 90%;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ui-accent) transparent;
    padding: 16px 24px;
    margin: 0 auto;
}

.cheat-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0;
}

.cheat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
}

.cheat-row label {
    font-size: 13px;
    white-space: nowrap;
    letter-spacing: 1px;
}

.cheat-slider-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.cheat-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.15);
    outline: none;
    cursor: pointer;
}

.cheat-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ui-accent);
    box-shadow: 0 0 8px rgba(229,37,33,0.6);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.cheat-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.cheat-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ui-accent);
    border: none;
    cursor: pointer;
}

.cheat-val {
    font-size: 13px;
    min-width: 38px;
    text-align: right;
    color: var(--coin-gold);
    font-weight: bold;
    letter-spacing: 1px;
}

.cheat-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.cheat-btns .menu-btn {
    flex: 1 1 auto;
    min-width: 100px;
    padding: 8px 12px;
    font-size: 12px;
    letter-spacing: 1px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    color: var(--text-white);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.cheat-btns .menu-btn:hover {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
    box-shadow: var(--glow-red);
}

.cheat-hint {
    text-align: center;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    padding: 6px 0 2px;
    letter-spacing: 1px;
}

.cheat-unlock-toast {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.92);
    border: 1px solid var(--coin-gold);
    box-shadow: var(--glow-gold);
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 14px;
    letter-spacing: 1.5px;
    z-index: 300;
    animation: toastIn 0.4s ease, toastOut 0.6s ease 3.4s forwards;
    pointer-events: none;
}

.cheat-unlock-toast.hidden {
    display: none;
}

/* ========================================
   Victory / Credits Screen
   ======================================== */

.victory-content {
    max-width: 500px;
}

.victory-crown {
    font-size: 56px;
    animation: crownBounce 1.5s ease infinite;
    margin-bottom: 8px;
}

@keyframes crownBounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-12px) rotate(5deg); }
}

.victory-title {
    font-size: 36px !important;
    background: linear-gradient(135deg, #ffd700, #ff6b6b, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2s linear infinite;
    background-size: 200% auto;
}

@keyframes shimmer {
    to { background-position: 200% center; }
}

.victory-stats {
    margin: 16px 0;
    padding: 12px 20px;
    background: rgba(255,215,0,0.08);
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 10px;
}

.victory-stats .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    letter-spacing: 1px;
}

.victory-stats .stat-row span:last-child {
    color: var(--coin-gold);
    font-weight: bold;
}

.credits-scroll {
    height: 160px;
    overflow: hidden;
    position: relative;
    margin: 12px 0;
}

.credits-scroll::before,
.credits-scroll::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 30px;
    z-index: 1;
    pointer-events: none;
}

.credits-scroll::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
}

.credits-scroll::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}

.credits-inner {
    animation: scrollCredits 14s linear infinite;
    text-align: center;
}

@keyframes scrollCredits {
    0% { transform: translateY(160px); }
    100% { transform: translateY(-100%); }
}

.credits-heading {
    font-size: 16px;
    letter-spacing: 4px;
    color: var(--coin-gold);
    margin-bottom: 16px;
}

.credits-role {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    letter-spacing: 2px;
    margin-top: 14px;
    text-transform: uppercase;
}

.credits-name {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    letter-spacing: 1px;
    margin-top: 4px;
}

.credits-divider {
    margin: 20px 0;
    color: var(--coin-gold);
    letter-spacing: 8px;
}

.credits-secret {
    font-size: 11px;
    color: var(--ui-accent);
    letter-spacing: 1px;
    margin-top: 12px;
    opacity: 0.7;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to   { opacity: 0; display: none; }
}
