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

body {
    font-family: Arial, sans-serif;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
}

/* ===================== INTRO ===================== */
#intro-overlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; flex-direction: column;
    animation: introFadeOut 0.6s ease-in 4.2s forwards;
}
#intro-overlay.hidden { display: none; }

.intro-top-screen {
    flex: 1;
    background: linear-gradient(180deg, #f5e97a, #ede88f 60%, #e8e4a0);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    position: relative;
}
.intro-status-bar {
    position: absolute; top: 6px; left: 0; right: 0;
    display: flex; align-items: center; padding: 0 10px; font-size: 12px;
}
.intro-signal {
    display: flex; align-items: center; gap: 2px;
    background: #6ab4f5; color: white;
    padding: 2px 7px; border-radius: 3px;
    font-size: 11px; font-weight: bold;
}
.signal-bar { display: inline-block; width: 3px; background: white; border-radius: 1px; }
.signal-bar:nth-child(1) { height: 5px; }
.signal-bar:nth-child(2) { height: 8px; }
.signal-bar:nth-child(3) { height: 11px; }
.signal-text { margin-left: 3px; }
.intro-datetime { margin-left: auto; font-size: 12px; color: #555; }
.intro-battery  { margin-left: 8px; font-size: 11px; color: #4a4; letter-spacing: -2px; }

.intro-logo { animation: logoSlideIn 0.7s cubic-bezier(0.22,1,0.36,1) 0.4s both; }
.intro-logo img { width: min(500px, 85vw); }

.intro-bottom-screen {
    flex: 1;
    background: linear-gradient(180deg, #f0edd8, #e8e5c8);
    display: flex; align-items: center; justify-content: center;
}
.intro-mascot {
    display: flex; flex-direction: column; align-items: center;
    animation: bagBounce 0.5s ease-out 1.4s both, mascotIdle 1.2s ease-in-out 2s infinite;
}
.bag-handle {
    width: 36px; height: 20px;
    border: 6px solid #e86000; border-bottom: none;
    border-radius: 16px 16px 0 0; margin-bottom: -2px;
}
.bag-body {
    width: 68px; height: 72px; background: #f07030;
    border-radius: 7px 7px 14px 14px; position: relative;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 -5px 0 rgba(0,0,0,0.12);
}
.bag-eye {
    position: absolute; width: 12px; height: 12px;
    background: white; border-radius: 50%; top: 20px;
}
.bag-eye::after {
    content: ''; position: absolute;
    width: 6px; height: 6px; background: #333;
    border-radius: 50%; top: 3px; left: 3px;
}
.bag-eye-left  { left: 12px; }
.bag-eye-right { right: 12px; }
.bag-smile {
    position: absolute; bottom: 16px;
    width: 28px; height: 14px;
    border: 3px solid white; border-top: none;
    border-radius: 0 0 14px 14px;
}
.bag-feet { display: flex; gap: 14px; margin-top: 3px; }
.bag-foot { width: 16px; height: 9px; background: #e05000; border-radius: 0 0 8px 8px; }

@keyframes logoSlideIn { from{opacity:0;transform:scale(0.85)} to{opacity:1;transform:scale(1)} }
@keyframes bagBounce   { 0%{opacity:0;transform:translateY(30px)} 60%{transform:translateY(-10px)} 80%{transform:translateY(4px)} 100%{opacity:1;transform:translateY(0)} }
@keyframes mascotIdle  { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
@keyframes introFadeOut{ from{opacity:1} to{opacity:0;pointer-events:none} }

/* ===================== TOP SCREEN ===================== */
.top-screen {
    background: #111;
    position: relative;
    overflow: hidden;
    aspect-ratio: 5 / 3;
    flex-shrink: 0;
}

.status-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 4;
    display: flex; align-items: center;
    padding: 5px 10px;
    background: rgba(0,0,0,0.45);
}
.status-signal {
    display: flex; align-items: flex-end; gap: 2px;
    background: #5aabf0; color: white;
    padding: 2px 7px 2px 5px; border-radius: 3px;
    font-size: 11px; font-weight: bold;
}
.sig-bar { display: inline-block; width: 3px; background: white; border-radius: 1px; margin-right: 1px; }
.sig-bar.s1{height:5px} .sig-bar.s2{height:8px} .sig-bar.s3{height:11px}
.sig-label { margin-left: 3px; }
.status-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#ds-time      { font-size: 12px; color: #ddd; }
.status-battery { font-size: 11px; color: #8f8; letter-spacing: -2px; }

/* Banner */
.banner-area { position: absolute; inset: 0; }
.banner {
    display: none; position: absolute; inset: 0;
    align-items: center; justify-content: space-between;
    padding: 36px 30px 50px; gap: 16px;
}
.banner.active { display: flex; }
.banner-text { flex: 1; }
.banner-title { font-size: clamp(20px, 5vw, 34px); font-weight: bold; color: white; text-shadow: 0 2px 8px rgba(0,0,0,0.3); line-height: 1.2; }
.banner-sub   { font-size: clamp(11px, 2.5vw, 15px); color: rgba(255,255,255,0.82); margin-top: 6px; }
.banner-img   { width: clamp(70px, 18vw, 110px); height: clamp(70px, 18vw, 110px); object-fit: contain; border-radius: 14px; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.3)); flex-shrink: 0; }
.banner-vc    { flex-shrink: 0; border: 2px solid rgba(255,255,255,0.65); border-radius: 8px; padding: 10px 16px; color: white; font-size: 14px; font-weight: bold; background: rgba(255,255,255,0.12); }

.banner-dots  { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; z-index: 4; }
.banner-dot   { width: 8px; height: 8px; background: rgba(255,255,255,0.38); border-radius: 50%; cursor: pointer; transition: background 0.2s; }
.banner-dot.active { background: white; }

/* Info strip */
.top-info-strip { position: absolute; bottom: 0; left: 0; right: 0; z-index: 4; }
.top-notice  { background: rgba(15,12,20,0.72); color: #ccc; font-size: 12px; padding: 3px 10px; border-top: 1px solid rgba(255,255,255,0.07); }
.top-balance { background: rgba(10,8,16,0.85); color: #eee; text-align: center; padding: 7px; font-size: 17px; font-weight: bold; border-top: 1px solid rgba(255,255,255,0.07); }

/* ===================== BOTTOM SCREEN ===================== */
.bottom-screen {
    flex: 1;
    background: #ede5cc;
    display: flex;
    flex-direction: column;
    border-top: 4px solid #111;
}

/* Navbar */
.ds-navbar {
    background: #d96010;
    display: flex; align-items: center;
    padding: 6px 8px; gap: 7px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.ds-menu-btn {
    background: #b84e08; color: white; border: none;
    border-radius: 6px; padding: 6px 12px;
    font-size: 13px; font-weight: bold;
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; white-space: nowrap;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.25);
    flex-shrink: 0;
}
.ds-menu-btn:active { transform: translateY(1px); box-shadow: none; }
.ds-search {
    flex: 1; min-width: 0;
    border: none; outline: none;
    padding: 6px 10px; font-size: 13px;
    border-radius: 5px; background: white;
}
.ds-search-btn {
    background: #e87820; border: none;
    border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}
.ds-search-btn:active { transform: scale(0.9); }

/* Main tile area */
.ds-main {
    flex: 1;
    display: flex; flex-direction: column;
    justify-content: center; align-items: flex-start;
    padding: 10px 8px 6px; gap: 6px; overflow: hidden;
}

.ds-tiles-row {
    display: flex; align-items: center; gap: 10px;
    overflow-x: auto; padding: 6px 4px;
    width: 100%; scrollbar-width: none;
    cursor: grab; user-select: none;
    -webkit-overflow-scrolling: touch;
}
.ds-tiles-row::-webkit-scrollbar { display: none; }
.ds-tiles-row.dragging { cursor: grabbing; }

/* News icon */
.tile-news { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; cursor: pointer; }
.tile-news-circle {
    width: 68px; height: 68px;
    background: linear-gradient(135deg, #e8a020, #f5c030);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.3);
}
.tile-news span { font-size: 11px; font-weight: bold; color: #555; }

/* Game tiles */
.tile-main { flex-shrink: 0; position: relative; cursor: pointer; }
.tile-cover {
    width: 96px; height: 96px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    border: 4px solid transparent;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    overflow: hidden;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.tile-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.tile-main:active .tile-cover { transform: scale(0.94); }

.tile-active .tile-cover {
    border-color: #d96010;
    box-shadow: 0 0 0 1px #d96010, 0 4px 14px rgba(0,0,0,0.3);
}
.tile-vc { background: linear-gradient(135deg, #e07010, #f08030); }
.tile-vc span { color: white; font-size: 11px; font-weight: bold; text-align: center; text-transform: uppercase; line-height: 1.4; }

.tile-badge {
    position: absolute; top: -5px; left: -5px;
    background: #22aadd; color: white;
    font-size: 9px; font-weight: bold;
    padding: 2px 5px; border-radius: 4px; text-transform: uppercase;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.tile-label {
    align-self: center;
    font-size: 13px; font-weight: bold; color: #555;
    background: rgba(205,192,155,0.9);
    border-radius: 10px; padding: 3px 14px;
}

/* Category bar */
.ds-catbar {
    display: flex; overflow-x: auto; scrollbar-width: none;
    border-top: 2px solid rgba(0,0,0,0.18);
    flex-shrink: 0; cursor: grab;
}
.ds-catbar::-webkit-scrollbar { display: none; }
.ds-catbar.dragging { cursor: grabbing; }

.cat-btn {
    flex-shrink: 0; background: var(--bg,#888); border: none;
    min-width: 80px; padding: 7px 6px 6px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; cursor: pointer;
    border-right: 1px solid rgba(255,255,255,0.15);
    transition: filter 0.12s; user-select: none;
}
.cat-btn:hover  { filter: brightness(1.12); }
.cat-btn:active { filter: brightness(0.84); }
.cat-btn img  { width: 34px; height: 34px; object-fit: contain; border-radius: 5px; }
.cat-btn span { font-size: 9px; font-weight: bold; color: white; text-align: center; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }

/* ===================== 3DS ERROR DIALOG ===================== */
#error-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
}
#error-modal.visible { display: flex; }

.error-dialog {
    width: min(310px, 88vw);
    background: #dde2ee;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #7088b0;
    box-shadow: 0 6px 28px rgba(0,0,0,0.6);
    font-family: Arial, sans-serif;
    animation: errorPop 0.2s ease-out;
}

@keyframes errorPop {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

.error-titlebar {
    background: linear-gradient(180deg, #7898cc 0%, #5070a8 100%);
    color: white;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.error-warn-icon {
    font-size: 17px;
    line-height: 1;
}

.error-body {
    padding: 18px 18px 12px;
    background: #edf0f8;
    font-size: 14px;
    color: #1a1a2a;
    line-height: 1.6;
}

.error-footer {
    border-top: 1px solid #a8b8d0;
    background: #edf0f8;
    padding: 10px;
    text-align: center;
}

#error-ok {
    background: none;
    border: none;
    font-size: 15px;
    font-weight: bold;
    color: #1a1a2a;
    cursor: pointer;
    padding: 5px 40px;
    border-radius: 5px;
    transition: background 0.12s;
}
#error-ok:hover  { background: rgba(0,0,0,0.07); }
#error-ok:active { background: rgba(0,0,0,0.15); }
