* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-particle {
    position: absolute;
    top: -60px;
    animation: fallDown linear infinite;
    opacity: 0.05;
    font-size: 1.4rem;
    color: #ffd200;
    user-select: none;
}

@keyframes fallDown {
    0% { transform: translateY(-60px) rotate(0deg); }
    100% { transform: translateY(110vh) rotate(360deg); }
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    padding: 20px 0 10px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #888;
    font-size: 0.9rem;
    margin-top: 4px;
    font-style: italic;
}

/* Auth bar */
.auth-bar {
    margin-top: 10px;
    font-size: 0.9rem;
}

.auth-bar .username {
    color: #ffd200;
    font-weight: 600;
}

.auth-bar button {
    background: none;
    border: 1px solid #2a2a3e;
    color: #aaa;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 8px;
    transition: all 0.2s;
}

.auth-bar button:hover {
    border-color: #f7971e;
    color: #ffd200;
}

/* Modal */
.modal-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: 100;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: #1a1a2e;
    border: 2px solid #2a2a3e;
    border-radius: 16px;
    padding: 30px;
    width: 340px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #666;
    font-size: 1.4rem;
    cursor: pointer;
}

.modal-close:hover {
    color: #e74c3c;
}

.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #2a2a3e;
}

.modal-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: #666;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.modal-tab.active {
    color: #ffd200;
    border-bottom-color: #f7971e;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#auth-form input {
    padding: 10px 14px;
    border: 2px solid #2a2a3e;
    border-radius: 10px;
    background: #12121f;
    color: #fff;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

#auth-form input:focus {
    border-color: #f7971e;
}

.auth-error {
    color: #e74c3c;
    font-size: 0.85rem;
    text-align: center;
}

.auth-error.hidden {
    display: none;
}

.auth-submit {
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #0f0f1a;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
}

.auth-submit:hover {
    transform: scale(1.02);
}

.main-layout {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    align-items: flex-start;
}

/* Slot machine */
.slot-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.slot-machine {
    position: relative;
    width: 440px;
}

.slot-window {
    height: 350px;
    overflow: hidden;
    border-radius: 16px;
    background: #1a1a2e;
    border: 2px solid #2a2a3e;
    position: relative;
}

.slot-reel {
    display: flex;
    flex-direction: column;
    transition: none;
}

.slot-item {
    height: 70px;
    display: grid;
    grid-template-columns: 110px 1fr auto;
    align-items: center;
    padding: 0 24px;
    gap: 10px;
    flex-shrink: 0;
    transition: opacity 0.1s;
}

.slot-item .item-ticker {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffd200;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-item .item-name {
    font-size: 0.95rem;
    color: #aaa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-item .item-price {
    font-size: 0.9rem;
    color: #e0e0e0;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.slot-item.active {
    background: rgba(247, 151, 30, 0.1);
}

.slot-item.active .item-ticker {
    color: #ffd200;
    font-size: 1.5rem;
}

.slot-item.active .item-name {
    color: #e0e0e0;
}

/* Fade overlays */
.slot-fade {
    position: absolute;
    left: 0;
    right: 0;
    height: 120px;
    z-index: 5;
    pointer-events: none;
}

.slot-fade.top {
    top: 0;
    background: linear-gradient(to bottom, #0f0f1a 0%, transparent 100%);
    border-radius: 16px 16px 0 0;
}

.slot-fade.bottom {
    bottom: 0;
    background: linear-gradient(to top, #0f0f1a 0%, transparent 100%);
    border-radius: 0 0 16px 16px;
}

/* Pointers */
.slot-pointer {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #ffd200;
    z-index: 10;
    filter: drop-shadow(0 0 6px rgba(255, 210, 0, 0.6));
}

.slot-pointer.left {
    left: -24px;
}

.slot-pointer.right {
    right: -24px;
}

/* Center highlight line */
.slot-window::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 70px;
    transform: translateY(-50%);
    border-top: 2px solid rgba(247, 151, 30, 0.4);
    border-bottom: 2px solid rgba(247, 151, 30, 0.4);
    z-index: 4;
    pointer-events: none;
}

/* Controls */
.controls {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 440px;
}

.budget-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.budget-row label {
    font-size: 0.9rem;
    color: #aaa;
    white-space: nowrap;
}

.input-group {
    position: relative;
    flex: 1;
}

.input-group input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 2px solid #2a2a3e;
    border-radius: 10px;
    background: #1a1a2e;
    color: #fff;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: #f7971e;
}

.currency {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 1rem;
}

.spin-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #0f0f1a;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 2px;
}

.spin-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(247, 151, 30, 0.4);
}

.spin-btn:active {
    transform: scale(0.98);
}

.spin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Result */
.result {
    margin-top: 24px;
    width: 100%;
    max-width: 440px;
    transition: opacity 0.3s, transform 0.3s;
}

.result.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.result-card {
    background: #1a1a2e;
    border: 2px solid #2a2a3e;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.result-header {
    margin-bottom: 16px;
}

.result-ticker {
    font-size: 2rem;
    font-weight: 800;
    color: #ffd200;
}

.result-name {
    font-size: 1rem;
    color: #aaa;
}

.result-details {
    display: flex;
    justify-content: space-around;
    margin-bottom: 16px;
}

.detail {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e0e0e0;
    margin-top: 4px;
}

.budget-remaining {
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(247, 151, 30, 0.1);
    border: 1px solid rgba(247, 151, 30, 0.3);
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
    color: #ffd200;
    font-weight: 600;
}

.budget-remaining.hidden {
    display: none;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #2a2a3e;
    border-radius: 6px;
    background: #12121f;
    color: #ffd200;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.qty-btn:hover {
    border-color: #f7971e;
    background: rgba(247, 151, 30, 0.15);
}

.result-actions {
    display: flex;
    gap: 10px;
}

.buy-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #4caf50;
    border-radius: 10px;
    background: transparent;
    color: #4caf50;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.buy-btn:hover {
    background: #4caf50;
    color: #0f0f1a;
}

.skip-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #555;
    border-radius: 10px;
    background: transparent;
    color: #888;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.skip-btn:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

/* Right panel */
.right-panel {
    width: 400px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Portfolio */
.portfolio-section {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 20px;
    border: 2px solid #2a2a3e;
    max-height: 40vh;
    overflow-y: auto;
}

.portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.portfolio-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffd200;
}

.manual-add {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    align-items: center;
}

.manual-add.hidden {
    display: none;
}

.manual-add input {
    flex: 1;
    margin-bottom: 0;
}

.manual-add .buy-btn {
    width: auto;
    padding: 8px 14px;
    white-space: nowrap;
}

.portfolio-total {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2a2a3e;
}

.portfolio-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-msg {
    color: #555;
    font-size: 0.85rem;
    text-align: center;
    padding: 20px 0;
}

.position {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #12121f;
    border-radius: 10px;
    transition: background 0.2s;
}

.position:hover {
    background: #1e1e32;
}

.position-info {
    display: flex;
    flex-direction: column;
}

.position-ticker {
    font-weight: 700;
    font-size: 0.95rem;
    color: #e0e0e0;
}

.position-name {
    font-size: 0.75rem;
    color: #666;
}

.position-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.position-qty {
    text-align: right;
}

.position-qty-num {
    font-weight: 600;
    font-size: 0.95rem;
}

.position-qty-val {
    font-size: 0.75rem;
    color: #888;
}

.remove-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    transition: color 0.2s;
}

.remove-btn:hover {
    color: #e74c3c;
}

/* Analytics */
.analytics-section {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 20px;
    border: 2px solid #2a2a3e;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.analytics-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffd200;
}

.analytics-updated {
    font-size: 0.7rem;
    color: #555;
    margin-bottom: 10px;
}

.analytics-group {
    margin-bottom: 10px;
}

.analytics-group:last-child {
    margin-bottom: 0;
}

.analytics-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #2a2a3e;
}

.top-label {
    color: #4caf50;
}

.bottom-label {
    color: #e74c3c;
}

.analytics-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.analytics-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
}

.analytics-item:hover {
    background: #1e1e32;
}

.analytics-item {
    display: grid;
    grid-template-columns: 100px 1fr 65px;
    gap: 4px;
}

.analytics-item .ai-ticker {
    font-weight: 700;
    color: #e0e0e0;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analytics-item .ai-name {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analytics-item .ai-change {
    font-weight: 700;
    text-align: right;
}

.ai-change.positive {
    color: #4caf50;
}

.ai-change.negative {
    color: #e74c3c;
}

/* Filter */
.filter-section {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 20px;
    border: 2px solid #2a2a3e;
    max-height: 40vh;
    display: flex;
    flex-direction: column;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.filter-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffd200;
}

.filter-buttons {
    display: flex;
    gap: 6px;
}

.filter-btn {
    padding: 4px 10px;
    border: 1px solid #2a2a3e;
    border-radius: 6px;
    background: #12121f;
    color: #aaa;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: #f7971e;
    color: #ffd200;
}

.filter-btn.fav-btn {
    color: #f7971e;
}

.filter-btn.active {
    border-color: #f7971e;
    background: rgba(247, 151, 30, 0.15);
    color: #ffd200;
}

.filter-search {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #2a2a3e;
    border-radius: 8px;
    background: #12121f;
    color: #fff;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.filter-search:focus {
    border-color: #f7971e;
}

.filter-count {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 8px;
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.filter-item:hover {
    background: #1e1e32;
}

.filter-item .fi-fav {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #333;
    padding: 0;
    line-height: 1;
    transition: color 0.15s, transform 0.15s;
}

.filter-item .fi-fav:hover {
    transform: scale(1.2);
}

.filter-item .fi-fav.is-fav {
    color: #f7971e;
}

.filter-item input[type="checkbox"] {
    accent-color: #f7971e;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.filter-item .fi-ticker {
    font-weight: 700;
    font-size: 0.8rem;
    color: #e0e0e0;
    min-width: 75px;
}

.filter-item .fi-name {
    font-size: 0.75rem;
    color: #666;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-item .fi-price {
    font-size: 0.75rem;
    color: #888;
}

/* Responsive */
@media (max-width: 800px) {
    .main-layout {
        flex-direction: column;
        align-items: center;
    }

    .right-panel {
        width: 100%;
        max-width: 400px;
    }

    .slot-machine {
        width: 100%;
        max-width: 340px;
    }
}
