:root {
    --bg-color: #02060f;
    --dark-blue: #0a1930;
    --light-blue-dim: #4a7596;
    --light-blue: #88c0d0;
    --sky-blue: #b3e5fc;
    --bright-blue: #e1f5fe;
    --oracle-glow: #ffffff;
    --danger: #ff5252;
    --fulfilled: #4caf50;
    --lock-gold: #ffd700;
    /* SMALL: */
    --text-sm:  clamp(0.75rem, 2vw, 1rem);
    --text-stm: clamp(0.85rem, 2.25vw, 1.25rem);
    --text-md:  clamp(1rem, 2.5vw, 1.5rem); 
    --text-mt: clamp(1.1rem, 2.75vw, 2.2rem);
    --text-mtl: clamp(1.2rem, 2.75vw, 2.25rem);
    --text-lg:  clamp(1.5rem, 5vw, 2.5rem);
    --text-xl:  clamp(2rem, 8vw, 4rem); /* Lowered from 2rem to 1.5rem */
}

/* Forces all elements to strictly obey width limits regardless of padding */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', Courier, 'Microsoft YaHei', 'PingFang SC', 'SimHei', monospace;
    background-color: var(--bg-color);
    color: var(--light-blue);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: scroll;
    padding-top: calc(15px + env(safe-area-inset-top));
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
}

#app-wrapper {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

#system-msg {
    position: fixed; 
    top: calc(10px + env(safe-area-inset-top)); 
    width: 90%; 
    max-width: 580px; 
    background: var(--dark-blue); 
    color: var(--sky-blue); 
    text-align: center; 
    padding: 10px; 
    border: 1px solid var(--sky-blue); 
    z-index: 100;
    display: none; 
    font-weight: bold; 
    box-shadow: 0 0 15px var(--dark-blue);
}

#system-msg.bad { 
    border-color: var(--danger); 
    color: var(--danger); 
    box-shadow: 0 0 15px var(--danger); }

header {
    text-align: center;
    margin-bottom: 20px;
}

.index-logo-img {
    width: 100px;
    height: auto;
    border-radius: 50%;
    margin-bottom: 10px;
    border: 2px solid var(--light-blue-dim);
    box-shadow: 0 0 10px rgba(136, 192, 208, 0.4);
}

header h1 {
    font-size: 1.5rem;
    color: var(--sky-blue);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 0;
}

.rank-badge {
    display: inline-block;
    background: var(--dark-blue);
    border: 1px solid var(--light-blue);
    padding: 5px 15px;
    margin-top: 10px;
    color: var(--sky-blue);
    font-weight: bold;
    letter-spacing: 1px;
}

.rank-grade { 
    color: var(--light-blue-dim); margin-right: 5px; 
}

.main-nav-tabs {
    display: flex;
    width: 100%;
    margin-bottom: 20px;
    gap: 10px;
}

.main-tab {
    flex: 1;
    text-align: center;
    padding: 12px 5px;
    background: #000;
    border: 1px solid var(--light-blue-dim);
    color: var(--light-blue-dim);
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    font-size: 0.85rem;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.main-tab.active {
    background: var(--dark-blue);
    color: var(--sky-blue);
    border-color: var(--sky-blue);
    box-shadow: 0 0 10px rgba(135, 206, 235, 0.2);
}

.view-page {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.container { 
    width: 100%; 
}

.prescript-card {
    background: linear-gradient(180deg, var(--dark-blue) 0%, #030812 100%);
    border: 1px solid var(--light-blue);
    padding: 30px 20px;
    text-align: center;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 0 15px rgba(136, 192, 208, 0.1);
    position: relative;
    transition: all 0.3s ease;
    width: 100%;
}

.prescript-card.generating { 
    box-shadow: inset 0 0 40px rgba(136, 192, 208, 0.2), 0 0 25px rgba(136, 192, 208, 0.3); 
    border-color: var(--sky-blue); 
}

.quest-marker {
    position: absolute;
    top: 10px;
    left: 10px;
    color: var(--lock-gold);
    border: 1px solid var(--lock-gold);
    padding: 2px 5px;
    letter-spacing: 1px;
    font-size: var(--text-sm); /* Removed the old 0.7rem */
}

#prescript-mark {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 60px;
    height: auto;
    z-index: 10;
    filter: drop-shadow(0 0 8px var(--sky-blue));
    animation: markPulse 3s infinite alternate;
}

@keyframes markPulse {
    from { filter: drop-shadow(0 0 5px var(--sky-blue)); 
        opacity: 0.8; }
    to { filter: drop-shadow(0 0 15px var(--oracle-glow)); 
        opacity: 1; transform: scale(1.05); }
}

.prescript-text { 
    line-height: 1.5; 
    color: var(--sky-blue); 
    margin-bottom: 20px; 
    min-height: 80px; 
    width: 100%; 
    white-space: pre-wrap; 
    word-wrap: break-word; 
    text-align: left; 
    font-size: var(--text-mt); 
    line-height: 1.5;}
    
.typing-cursor::after { 
    content: '█'; 
    animation: blink 1s step-end infinite; }
    @keyframes blink { 50% { opacity: 0; } 
}

.btn-large {
    background: transparent;
    border: 1px solid var(--light-blue);
    color: var(--sky-blue);
    padding: 15px 30px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s;
    width: 80%;
    margin: 10px 0;
}

#display-user-name {
    font-size: var(--text-mtl);
}

.btn-large:hover { 
    background: var(--light-blue); 
    color: #000; 
}

.btn-large:disabled {
    opacity: 0.5; 
    cursor: not-allowed; 
}

.cooldown-msg { 
    font-size: 0.9rem; 
    color: var(--light-blue-dim); 
    margin-top: 10px; 
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
}

.hidden { 
    display: none !important; 
}

.action-row { 
    display: flex; 
    width: 100%; 
    justify-content: space-around; 
    gap: 10px; 
    margin-top: 5px; 
}

.btn-action {
    flex: 1;
    background: transparent;
    border: 1px solid var(--light-blue-dim);
    color: var(--light-blue);
    padding: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-action:hover { 
    background: rgba(136, 192, 208, 0.2); 
}

.fulfilled-btn:hover { 
    background: rgba(76, 175, 80, 0.2); 
    border-color: var(--fulfilled); 
    color: var(--fulfilled); 
}

.failed-btn:hover { 
    background: rgba(255, 82, 82, 0.2); 
    border-color: var(--danger); 
    color: var(--danger); 
}

.btn-proceed { 
    border-color: var(--sky-blue); 
    color: var(--sky-blue); 
    font-weight: bold; 
    width: 100%;
    margin-top: 5px; 
}

.stats-area { 
    background: #050a14; 
    padding: 15px; 
    border: 1px solid var(--light-blue-dim); 
    width: 100%; 
}

.stats-grid { 
    display: flex; 
    align-items: center; 
    width: 100%; }

.stat-box { 
    flex: 1; 
    text-align: center; 
    padding: 5px 0; 
}

.stat-box:first-child { 
    border-right: 1px solid var(--light-blue-dim); 
}

.stat-icon { 
    width: 30px; 
    height: 30px; 
    margin-bottom: 5px; 
}

.stat-value { 
    color: var(--sky-blue); 
    font-weight: bold; 
    font-size: var(--text-mtl); /* Changed to lg, removed old 1.5rem */
}

.stat-label { 
    font-size: 0.8rem; 
    color: var(--light-blue-dim); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

.ascend-box { 
    margin-top: 15px; 
    border-top: 1px solid var(--light-blue-dim); 
    padding-top: 10px; 
    text-align: center; 
    display: none; 
}

.ascend-box.visible { 
    display: block; 
}

.ascend-cost { 
    display: block; 
    font-size: 0.8rem; 
    color: var(--light-blue); 
    margin-bottom: 5px; 
}

.ascend-req { 
    display: block; 
    font-size: 0.7rem; 
    color: var(--danger); 
    margin-top: 5px; 
}

.warning-text { 
    font-size: 0.7rem; 
    color: var(--lock-gold); 
    display: block; 
    margin-top: 5px; 
}

.pending-section { 
    background: #050a14; 
    padding: 15px; 
    border: 1px solid var(--light-blue-dim); 
    width: 100%; 
}

.pending-item { 
    padding: 15px; 
    border: 1px solid var(--light-blue-dim); 
    margin-bottom: 10px; 
    font-size: 0.9rem; 
    cursor: pointer; 
    background: #02060f; 
    white-space: normal; 
    word-wrap: break-word; 
    line-height: 1.4;
    border-radius: 4px; 
}

.pending-item:hover { 
    border-color: var(--sky-blue); 
}

.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.85); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 50; 
}

.modal-content { 
    background: #050a14; 
    padding: 20px; 
    border: 1px solid var(--sky-blue); 
    width: 85%; max-width: 400px; 
    text-align: center; 
    position: relative; 
}

.modal-text { 
    font-size: 1rem; 
    color: var(--sky-blue); 
    margin-bottom: 20px; 
    line-height: 1.5; 
    white-space: pre-wrap; 
    word-wrap: break-word; 
    text-align: left; }

.exit-btn { 
    border-color: var(--light-blue-dim); 
    color: var(--light-blue-dim); 
}

.ritual-header { 
    font-size: 0.8rem; 
    color: var(--lock-gold); 
    display: block; 
    margin-bottom: 5px; 
}

.ritual-title { 
    font-size: 1.2rem; 
    color: var(--bright-blue); 
    display: block; 
    margin-bottom: 15px; 
    font-weight: bold; 
}

.ritual-body { 
    font-size: 0.95rem; 
    color: var(--light-blue); 
    text-align: left; 
    padding: 0 10px; 
    line-height: 1.6; 
}

.quote { 
    font-style: italic; 
    color: var(--sky-blue); 
}

input[type="text"] { 
    width: 100%; 
    padding: 10px; 
    background: #02060f; 
    border: 1px solid var(--light-blue-dim); 
    color: var(--sky-blue); 
    font-family: inherit; 
    margin-bottom: 10px; 
    box-sizing: border-box; 
}

.list-item { 
    display: flex; 
    justify-content: space-between; 
    padding: 8px; 
    border: 1px solid var(--light-blue-dim); 
    margin-bottom: 5px; 
    font-size: 0.8rem; 
    background: #02060f; 
}

/* ========================================= */
/* MIRROR DIMENSION HUB AESTHETICS           */
/* ========================================= */
.mirror-hub-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px 10px;
    box-sizing: border-box;
}

.mirror-header {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 30px;
}

.mirror-line {
    flex-grow: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.8), transparent);
}

.mirror-title {
    color: gold;
    letter-spacing: 3px;
    margin: 0 15px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
    text-align: center;
    white-space: nowrap;
    font-size: var(--text-md); /* Removed the old 1.1rem */
}

.mirror-menu-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 500px;
}

.mirror-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.btn-mirror {
    background: rgba(13, 27, 42, 0.6);
    border: 1px solid rgba(135, 206, 235, 0.5);
    color: rgba(176, 224, 230, 0.9);
    padding: 15px 10px;
    font-family: inherit;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 10px rgba(135, 206, 235, 0.05);
    font-size: var(--text-sm); /* Removed the old 0.85rem */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-mirror:hover {
    background: rgba(27, 58, 75, 0.8);
    border-color: rgba(135, 206, 235, 1);
    box-shadow: inset 0 0 15px rgba(135, 206, 235, 0.2);
    color: #fff;
}

.btn-mirror-gold {
    border-color: rgba(255, 215, 0, 0.6);
    color: gold;
    margin-top: 30px;
    background: rgba(255, 215, 0, 0.05);
}

.btn-mirror-gold:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: gold;
    color: #fff;
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.2);
}