/* 幻想小勇士 - 点击式文字冒险 */

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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #08081a;
    color: #e0dce8;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(100, 50, 160, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(40, 80, 160, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 30%, rgba(160, 100, 40, 0.06) 0%, transparent 60%);
    animation: bgFloat 12s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes bgFloat {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.05); }
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.35) 50%, transparent 100%),
        radial-gradient(1px 1px at 30% 70%, rgba(255,255,255,0.25) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at 50% 30%, rgba(255,215,0,0.4) 50%, transparent 100%),
        radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.35) 50%, transparent 100%),
        radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.25) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at 20% 80%, rgba(160,100,255,0.4) 50%, transparent 100%),
        radial-gradient(1px 1px at 60% 90%, rgba(255,255,255,0.35) 50%, transparent 100%),
        radial-gradient(1px 1px at 80% 10%, rgba(255,255,255,0.25) 50%, transparent 100%);
    animation: twinkle 5s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

#game-container {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr 320px;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    gap: 10px;
    padding: 10px;
    position: relative;
    z-index: 1;
}

/* 头部 */
#game-header {
    grid-column: 1 / -1;
    background: rgba(45, 25, 75, 0.75);
    backdrop-filter: blur(12px);
    padding: 14px 22px;
    border-radius: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.header-left h1 {
    font-size: 22px;
    background: linear-gradient(135deg, #ffd700, #ff9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
}

#location-name {
    font-size: 13px;
    color: #8a8aaa;
    margin-top: 2px;
}

#quick-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#quick-stats.hidden {
    display: none;
}

.stat-item {
    padding: 5px 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 18px;
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    white-space: nowrap;
}

/* 主游戏区 */
#game-main {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 10px;
    min-height: 0;
}

/* 故事面板 */
#story-panel {
    background: rgba(12, 8, 24, 0.55);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 22px;
    overflow-y: auto;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

#story-scroll {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.story-line {
    animation: textFadeIn 0.5s ease-out;
    padding: 4px 0;
}

@keyframes textFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.story-line.story {
    color: #a0b8d8;
    line-height: 1.85;
    text-indent: 2em;
    font-size: 15px;
}

.story-line.system {
    color: #6ee66e;
    font-size: 14px;
    padding: 8px 14px;
    background: rgba(110, 230, 110, 0.08);
    border-radius: 8px;
    border-left: 3px solid rgba(110, 230, 110, 0.4);
}

.story-line.combat {
    color: #f08080;
    font-size: 14px;
}

.story-line.reward {
    color: #ffd700;
    font-size: 14px;
    padding: 8px 14px;
    background: rgba(255, 215, 0, 0.06);
    border-radius: 8px;
    border-left: 3px solid rgba(255, 215, 0, 0.4);
}

.story-line.info {
    color: #9a9ab8;
    font-size: 14px;
    padding: 8px 14px;
    background: rgba(100, 100, 140, 0.08);
    border-radius: 8px;
}

.story-line.title {
    color: #ffd700;
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

.story-line.damage {
    color: #ff5555;
    font-weight: 600;
}

.story-line.heal {
    color: #55ff55;
    font-weight: 600;
}

.story-line.separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(138, 106, 170, 0.3), transparent);
    margin: 8px 0;
}

/* 选项面板 */
#choices-panel {
    background: rgba(18, 12, 32, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.2);
}

#choices-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-option {
    display: block;
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(70, 45, 120, 0.5) 0%, rgba(45, 28, 80, 0.5) 100%);
    border: 1px solid rgba(120, 80, 200, 0.25);
    border-radius: 12px;
    color: #d8cce8;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: all 0.22s ease;
    position: relative;
    overflow: hidden;
}

.choice-option::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #8a5ac8;
    opacity: 0;
    transition: opacity 0.22s;
}

.choice-option:hover {
    background: linear-gradient(135deg, rgba(100, 65, 160, 0.6) 0%, rgba(65, 38, 110, 0.6) 100%);
    border-color: rgba(140, 100, 220, 0.4);
    transform: translateX(6px);
    box-shadow: 0 4px 14px rgba(100, 50, 180, 0.25);
}

.choice-option:hover::before {
    opacity: 1;
}

.choice-option:active {
    transform: translateX(6px) scale(0.98);
}

.choice-option.primary {
    background: linear-gradient(135deg, rgba(120, 80, 200, 0.6) 0%, rgba(80, 50, 140, 0.6) 100%);
    border-color: rgba(160, 120, 240, 0.4);
}

.choice-option.danger {
    background: linear-gradient(135deg, rgba(140, 40, 40, 0.5) 0%, rgba(100, 25, 25, 0.5) 100%);
    border-color: rgba(200, 60, 60, 0.3);
}

.choice-option.danger:hover {
    background: linear-gradient(135deg, rgba(170, 50, 50, 0.6) 0%, rgba(120, 35, 35, 0.6) 100%);
    border-color: rgba(230, 80, 80, 0.5);
}

.choice-option.success {
    background: linear-gradient(135deg, rgba(40, 120, 60, 0.5) 0%, rgba(30, 80, 45, 0.5) 100%);
    border-color: rgba(60, 160, 80, 0.3);
}

.choice-option.success:hover {
    background: linear-gradient(135deg, rgba(50, 150, 75, 0.6) 0%, rgba(40, 100, 55, 0.6) 100%);
    border-color: rgba(80, 190, 100, 0.5);
}

.choice-option .choice-label {
    display: block;
    font-weight: 600;
    margin-bottom: 3px;
}

.choice-option .choice-desc {
    display: block;
    font-size: 12px;
    color: rgba(216, 204, 232, 0.6);
}

.choice-option .choice-icon {
    margin-right: 8px;
}

/* 侧边栏 */
#info-panel {
    background: rgba(12, 8, 24, 0.55);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    overflow: hidden;
}

#tabs {
    display: flex;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tab-btn {
    flex: 1;
    padding: 11px 6px;
    background: transparent;
    border: none;
    color: #7070a0;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-weight: 500;
}

.tab-btn:hover {
    color: #a0a0c0;
}

.tab-btn.active {
    color: #ffd700;
    border-bottom-color: #ffd700;
    background: rgba(255, 215, 0, 0.06);
}

.tab-content {
    display: none;
    flex: 1;
    padding: 14px;
    overflow-y: auto;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

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

/* 物品卡片 */
.item-card {
    background: rgba(45, 32, 70, 0.4);
    border: 1px solid rgba(90, 74, 122, 0.25);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.item-card.legendary {
    border-color: #ff8800;
    box-shadow: 0 0 12px rgba(255, 136, 0, 0.25);
    animation: legendaryGlow 2.5s ease-in-out infinite;
}

@keyframes legendaryGlow {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 136, 0, 0.25); }
    50% { box-shadow: 0 0 22px rgba(255, 136, 0, 0.45); }
}

.item-card.orange {
    border-color: #ff6600;
    box-shadow: 0 0 8px rgba(255, 102, 0, 0.15);
}

.item-card.purple {
    border-color: #9933ff;
    box-shadow: 0 0 8px rgba(153, 51, 255, 0.15);
}

.item-card.blue {
    border-color: #3366ff;
    box-shadow: 0 0 6px rgba(51, 102, 255, 0.1);
}

.item-card.green {
    border-color: #33cc33;
    box-shadow: 0 0 6px rgba(51, 204, 51, 0.1);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}

.stat-label {
    color: #8a8aaa;
}

.stat-value {
    color: #e0dce8;
    font-weight: 500;
}

.stat-value.good {
    color: #6ee66e;
}

.stat-value.bad {
    color: #f08080;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(138, 106, 170, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 106, 170, 0.5);
}

/* 战斗状态条 */
.hp-bar {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff5555, #55ff55);
    transition: width 0.3s ease;
}

/* 响应式 */
@media (max-width: 850px) {
    #game-container {
        grid-template-columns: 1fr;
    }

    #info-panel {
        display: none;
    }

    #quick-stats {
        display: none;
    }
}

@supports (padding: max(0px)) {
    #game-container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container {
        grid-template-rows: auto 1fr;
        grid-template-columns: 1fr 280px;
        padding: 6px;
        gap: 6px;
    }

    #game-header {
        padding: 8px 14px;
        border-radius: 10px;
    }

    .header-left h1 {
        font-size: 18px;
    }

    #location-name {
        font-size: 11px;
    }

    .stat-item {
        padding: 3px 8px;
        font-size: 11px;
    }

    #story-panel {
        padding: 14px;
    }

    .story-line.story {
        font-size: 13px;
        line-height: 1.6;
    }

    .story-line.title {
        font-size: 15px;
    }

    #choices-panel {
        padding: 10px;
    }

    .choice-option {
        padding: 8px 12px;
        font-size: 12px;
    }

    .choice-option .choice-desc {
        font-size: 10px;
    }

    #tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 6px 4px;
        font-size: 10px;
    }

    .tab-content {
        padding: 8px;
    }

    .item-card {
        padding: 8px;
        margin-bottom: 4px;
    }

    .stat-row {
        font-size: 11px;
        padding: 2px 0;
    }
}

/* 竖屏提示 */
@media (orientation: portrait) {
    .portrait-warning {
        display: flex !important;
    }
}

.portrait-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: #0a0a2a;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffd700;
    font-size: 18px;
    text-align: center;
    padding: 20px;
}

.portrait-warning .icon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: rotateIcon 2s ease-in-out infinite;
}

@keyframes rotateIcon {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    75% { transform: rotate(-90deg); }
}
