:root {
            --royal-purple: #1a0f4e;
            --royal-gold: #ffd700;
            --royal-gold-dark: #d4af37;
            --royal-gold-light: #fff9d6;
            --royal-blue: #0a0529;
            --royal-light: #4a3a8a;
            --royal-accent: #8a6de9;
            --royal-text: #f8f1ff;
            --royal-shadow: rgba(45, 27, 105, 0.7);
            --royal-dark: #0f0529;
            --royal-success: #4CAF50;
            --royal-warning: #FF9800;
            --royal-danger: #f44336;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, var(--royal-blue), var(--royal-purple), #0c0635);
            color: var(--royal-text);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
            overflow-x: hidden;
        }

        /* Header */
        header {
            text-align: center;
            padding: 30px 20px;
            width: 100%;
            max-width: 1400px;
            margin-bottom: 20px;
            position: relative;
        }

        header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 80%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
            border-bottom: 2px solid var(--royal-gold);
        }

        .title {
            font-size: 3.5rem;
            color: var(--royal-gold);
            text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
            margin-bottom: 10px;
            letter-spacing: 2px;
            position: relative;
        }

        .subtitle {
            font-size: 1.2rem;
            color: var(--royal-accent);
            max-width: 800px;
            margin: 0 auto;
            line-height: 1.6;
        }

        /* Main container */
        .container {
            width: 100%;
            max-width: 1400px;
            background: radial-gradient(circle at center, rgba(26, 10, 82, 0.9), rgba(15, 5, 41, 0.95));
            border: 3px solid var(--royal-gold);
            border-radius: 25px;
            box-shadow: 
                0 0 40px rgba(138, 109, 233, 0.5),
                inset 0 0 40px rgba(255, 215, 0, 0.1);
            overflow: hidden;
            position: relative;
            margin-bottom: 30px;
        }

        /* Container header - controls */
        .container-header {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            justify-content: center;
            align-items: center;
            padding: 25px;
            background: rgba(74, 58, 138, 0.3);
            border-bottom: 2px solid var(--royal-accent);
        }

        .control-group {
            display: flex;
            align-items: center;
            gap: 10px;
            background: rgba(26, 10, 82, 0.5);
            padding: 12px 20px;
            border-radius: 12px;
            border: 1px solid var(--royal-accent);
        }

        .control-label {
            color: var(--royal-gold);
            font-weight: bold;
            white-space: nowrap;
        }

        /* Input styling */
        .text, .limit-input {
            padding: 14px 20px;
            border-radius: 10px;
            border: 2px solid var(--royal-gold);
            background: rgba(255, 255, 255, 0.1);
            color: var(--royal-text);
            font-size: 1.1rem;
            min-width: 180px;
            transition: all 0.3s;
            box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
        }

        .text:focus, .limit-input:focus {
            outline: none;
            border-color: var(--royal-accent);
            box-shadow: 0 0 15px rgba(138, 109, 233, 0.5);
            background: rgba(255, 255, 255, 0.15);
        }

        .text::placeholder, .limit-input::placeholder {
            color: #b5a8ff;
        }

        /* Button styling */
        .push, .pop, .reset, .set-limit {
            padding: 14px 28px;
            border-radius: 10px;
            border: none;
            color: white;
            font-weight: bold;
            font-size: 1.1rem;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            min-width: 140px;
        }

        .push {
            background: linear-gradient(145deg, var(--royal-success), #2E7D32);
        }

        .push:hover {
            background: linear-gradient(145deg, #66BB6A, #388E3C);
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
        }

        .pop {
            background: linear-gradient(145deg, var(--royal-warning), #F57C00);
        }

        .pop:hover {
            background: linear-gradient(145deg, #FFB74D, #FF9800);
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
        }

        .reset {
            background: linear-gradient(145deg, var(--royal-danger), #b71c1c);
        }

        .reset:hover {
            background: linear-gradient(145deg, #EF5350, #C62828);
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
        }

        .set-limit {
            background: linear-gradient(145deg, var(--royal-accent), #6b4dcc);
        }

        .set-limit:hover {
            background: linear-gradient(145deg, #9b7fff, var(--royal-accent));
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
        }

        .push:disabled, .pop:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none !important;
        }

        /* Container body - stack and info */
        .container-body {
            display: flex;
            flex-wrap: wrap;
            min-height: 600px;
            padding: 30px;
            gap: 40px;
        }

        /* Stack visualization */
        .stack-section {
            flex: 1;
            min-width: 600px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-end;
            position: relative;
        }

        .stack-title {
            color: var(--royal-gold);
            font-size: 2rem;
            margin-bottom: 20px;
            text-align: center;
            position: relative;
        }

        .stack-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 200px;
            height: 3px;
            background: linear-gradient(90deg, transparent, var(--royal-gold), transparent);
        }

        .stack-container {
            width: 500px;
            min-height: 120px;
            max-height: 700px;
            background: rgba(15, 5, 41, 0.7);
            border: 3px solid var(--royal-accent);
            border-bottom: none;
            border-radius: 20px 20px 0 0;
            position: relative;
            overflow: hidden;
            box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column-reverse;
            align-items: center;
            padding-bottom: 10px;
            transition: min-height 0.3s ease;
        }

        .stack-base {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 15px;
            background: linear-gradient(90deg, var(--royal-gold), var(--royal-accent));
            z-index: 5;
        }

        .stack-limit-indicator {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: rgba(244, 67, 54, 0.8);
            z-index: 100;
            display: none;
        }

        .stack-limit-text {
            position: absolute;
            top: -30px;
            left: 50%;
            transform: translateX(-50%);
            color: var(--royal-danger);
            font-weight: bold;
            background: rgba(15, 5, 41, 0.9);
            padding: 5px 15px;
            border-radius: 10px;
            border: 2px solid var(--royal-danger);
            display: none;
            z-index: 101;
        }

        /* Gold Brick Elements */
        .gold-brick {
            width: 400px;
            height: 60px;
            background: linear-gradient(145deg, var(--royal-gold), var(--royal-gold-dark));
            border-radius: 8px;
            color: var(--royal-blue);
            font-weight: bold;
            font-size: 1.8rem;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            transition: all 0.5s ease;
            box-shadow: 
                0 8px 20px rgba(0, 0, 0, 0.3),
                inset 0 2px 5px rgba(255, 255, 255, 0.4),
                0 5px 0 rgba(212, 175, 55, 0.7);
            border: 2px solid rgba(212, 175, 55, 0.8);
            margin: 5px 0;
            z-index: 2;
        }

        .gold-brick::before {
            content: '';
            position: absolute;
            top: 5px;
            left: 5px;
            right: 5px;
            height: 10px;
            background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
            border-radius: 5px;
            z-index: 1;
        }

        .gold-brick::after {
            content: '';
            position: absolute;
            bottom: 5px;
            left: 5px;
            right: 5px;
            height: 10px;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.2), transparent);
            border-radius: 5px;
            z-index: 1;
        }

        .gold-brick.top {
            box-shadow: 
                0 0 30px rgba(255, 215, 0, 0.7),
                inset 0 2px 5px rgba(255, 255, 255, 0.4),
                0 5px 0 rgba(212, 175, 55, 0.7);
            border: 3px solid var(--royal-accent);
            z-index: 10;
        }

        .gold-brick.top::before {
            background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), transparent);
        }

        .gold-brick.brick-index {
            position: absolute;
            top: -25px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 1.1rem;
            color: var(--royal-gold-light);
            font-weight: bold;
            background: rgba(26, 10, 82, 0.9);
            padding: 3px 15px;
            border-radius: 10px;
            border: 1px solid var(--royal-accent);
            z-index: 3;
        }

        /* Stack animations */
        @keyframes brickPush {
            0% { 
                transform: translateY(100px);
                opacity: 0;
            }
            100% { 
                transform: translateY(0);
                opacity: 1;
            }
        }

        @keyframes brickPop {
            0% { 
                transform: translateY(0) rotate(0deg);
                opacity: 1;
            }
            100% { 
                transform: translateY(-100px) rotate(-10deg);
                opacity: 0;
            }
        }

        .gold-brick.pushing {
            animation: brickPush 0.5s ease-out;
        }

        .gold-brick.popping {
            animation: brickPop 0.5s ease-out forwards;
        }

        /* Stack capacity indicator */
        .capacity-indicator {
            margin-top: 20px;
            width: 500px;
            background: rgba(26, 10, 82, 0.5);
            border-radius: 10px;
            padding: 15px;
            border: 2px solid var(--royal-accent);
            text-align: center;
        }

        .capacity-text {
            color: var(--royal-gold);
            font-size: 1.2rem;
            margin-bottom: 10px;
        }

        .capacity-bar {
            width: 100%;
            height: 20px;
            background: rgba(15, 5, 41, 0.7);
            border-radius: 10px;
            overflow: hidden;
            border: 2px solid var(--royal-accent);
        }

        .capacity-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--royal-success), #2E7D32);
            border-radius: 8px;
            transition: width 0.5s ease;
            width: 0%;
        }

        .capacity-fill.warning {
            background: linear-gradient(90deg, var(--royal-warning), #F57C00);
        }

        .capacity-fill.danger {
            background: linear-gradient(90deg, var(--royal-danger), #b71c1c);
        }

        /* Info panel */
        .info {
            flex: 1;
            min-width: 400px;
            display: flex;
            flex-direction: column;
            gap: 25px;
        }

        .info-section {
            background: rgba(74, 58, 138, 0.3);
            border-radius: 15px;
            padding: 20px;
            border: 2px solid var(--royal-accent);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .info-section h3 {
            color: var(--royal-gold);
            font-size: 1.3rem;
        }

        .info-box {
            width: 120px;
            height: 70px;
            background: linear-gradient(145deg, var(--royal-gold), var(--royal-gold-dark));
            border-radius: 10px;
            color: var(--royal-blue);
            font-weight: bold;
            font-size: 1.8rem;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 2px solid var(--royal-accent);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            position: relative;
            overflow: hidden;
        }

        .info-box::before {
            content: '';
            position: absolute;
            top: 5px;
            left: 5px;
            right: 5px;
            height: 10px;
            background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
            border-radius: 5px;
            z-index: 1;
        }

        .info-box.empty {
            background: rgba(255, 255, 255, 0.1);
            color: #b5a8ff;
            font-style: italic;
            font-size: 1.2rem;
        }

        /* Message box */
        .message-box {
            background: rgba(26, 10, 82, 0.7);
            border-radius: 15px;
            padding: 25px;
            border: 2px solid var(--royal-accent);
            margin-top: 20px;
            flex-grow: 1;
            display: flex;
            flex-direction: column;
        }

        .message-box h2 {
            color: var(--royal-gold);
            margin-bottom: 20px;
            text-align: center;
            font-size: 1.8rem;
            border-bottom: 2px solid var(--royal-accent);
            padding-bottom: 10px;
        }

        .message-container {
            background: rgba(15, 5, 41, 0.9);
            border-radius: 10px;
            padding: 20px;
            border: 1px solid var(--royal-accent);
            height: 100%;
            overflow-y: auto;
            font-size: 1.1rem;
            line-height: 1.6;
        }

        .message-item {
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 8px;
            background: rgba(74, 58, 138, 0.3);
            border-left: 4px solid var(--royal-gold);
        }

        .message-item.success {
            border-left-color: var(--royal-success);
            background: rgba(76, 175, 80, 0.1);
        }

        .message-item.warning {
            border-left-color: var(--royal-warning);
            background: rgba(255, 152, 0, 0.1);
        }

        .message-item.error {
            border-left-color: var(--royal-danger);
            background: rgba(244, 67, 54, 0.1);
        }

        .message-item.info {
            border-left-color: var(--royal-accent);
            background: rgba(138, 109, 233, 0.1);
        }

        /* Stack principles */
        .principles {
            width: 100%;
            max-width: 1400px;
            background: rgba(26, 10, 82, 0.7);
            border-radius: 20px;
            padding: 25px;
            margin-top: 20px;
            border: 2px solid var(--royal-accent);
        }

        .principles h2 {
            color: var(--royal-gold);
            margin-bottom: 15px;
            font-size: 1.8rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .principles-content {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }

        .principle {
            background: rgba(74, 58, 138, 0.3);
            border-radius: 10px;
            padding: 20px;
            border: 1px solid var(--royal-accent);
        }

        .principle h3 {
            color: var(--royal-gold);
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .principle p {
            color: #d0c5ff;
            line-height: 1.6;
        }

        /* Footer */
        .footer {
            margin-top: 40px;
            text-align: center;
            color: #b5a8ff;
            font-size: 1rem;
            padding: 25px;
            width: 100%;
            max-width: 1400px;
            border-top: 1px solid rgba(255, 215, 0, 0.3);
            background: rgba(15, 5, 41, 0.5);
            border-radius: 15px;
        }

        /* Back button */
        .back-button {
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 100;
        }

        .back-btn {
            display: flex;
            align-items: center;
            color: var(--royal-gold);
            text-decoration: none;
            font-weight: bold;
            padding: 12px 20px;
            background: rgba(26, 10, 82, 0.8);
            border-radius: 10px;
            border: 2px solid var(--royal-gold);
            transition: all 0.3s;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            backdrop-filter: blur(5px);
        }

        .back-btn:hover {
            background: rgba(255, 215, 0, 0.2);
            transform: translateX(-5px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
        }

        .back-btn i {
            margin-right: 10px;
            font-size: 1.2rem;
        }

        /* Responsive design */
        @media (max-width: 1200px) {
            .container-body {
                flex-direction: column;
            }
            
            .stack-section, .info {
                min-width: 100%;
            }
            
            .stack-container {
                width: 450px;
            }
            
            .gold-brick {
                width: 350px;
            }
            
            .capacity-indicator {
                width: 450px;
            }
            
            .title {
                font-size: 3rem;
            }
        }

        @media (max-width: 768px) {
            .title {
                font-size: 2.5rem;
            }
            
            .container-header {
                flex-direction: column;
                align-items: stretch;
            }
            
            .control-group {
                width: 100%;
                justify-content: space-between;
            }
            
            .text, .limit-input, .push, .pop, .reset, .set-limit {
                width: 100%;
                min-width: auto;
            }
            
            .stack-container {
                width: 350px;
            }
            
            .gold-brick {
                width: 280px;
                height: 50px;
                font-size: 1.5rem;
            }
            
            .capacity-indicator {
                width: 350px;
            }
            
            .info {
                min-width: 100%;
            }
            
            .info-section {
                flex-direction: column;
                text-align: center;
                gap: 10px;
            }
            
            .info-box {
                width: 100px;
                height: 60px;
                font-size: 1.5rem;
            }
        }

        @media (max-width: 480px) {
            .title {
                font-size: 2rem;
            }
            
            .subtitle {
                font-size: 1rem;
            }
            
            .stack-container {
                width: 300px;
            }
            
            .gold-brick {
                width: 240px;
                height: 45px;
                font-size: 1.3rem;
            }
            
            .capacity-indicator {
                width: 300px;
            }
            
            .back-btn {
                padding: 10px 15px;
                font-size: 0.9rem;
            }
        }

        /* Scrollbar styling */
        ::-webkit-scrollbar {
            width: 10px;
        }

        ::-webkit-scrollbar-track {
            background: var(--royal-blue);
        }

        ::-webkit-scrollbar-thumb {
            background: linear-gradient(var(--royal-gold), var(--royal-accent));
            border-radius: 5px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(var(--royal-gold-light), var(--royal-accent-light));
        }