/* ============================================================
   layout.css  —  整体骨架布局
   ============================================================ */

.container {
    max-width: 1800px;
    margin: 0 auto;
    background-color: var(--c-panel);
    border-radius: var(--radius-lg);
    box-shadow:
        var(--shadow-xl),
        inset 0 0 60px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    border: 1px solid var(--c-primary-lighter);
    position: relative;
}

.container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.2) 0%, transparent 20%),
        radial-gradient(circle at 90% 90%, rgba(255, 255, 255, 0.2) 0%, transparent 20%);
    pointer-events: none;
    z-index: 0;
}

/* -------- 顶部标题栏 -------- */
header {
    background: var(--header-bg);
    color: var(--c-text-on-dark);
    padding: 20px 30px;
    border-bottom: 5px solid var(--c-primary-darker);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    /* 顶栏固定：向下滚动时依然能随时打开设置 / 用户中心 */
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

header h1 {
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    gap: 15px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #4caf50, 0 0 20px #4caf50; }
    to   { text-shadow: 0 0 10px #fff, 0 0 15px #4caf50, 0 0 20px #4caf50, 0 0 25px #4caf50; }
}

/* -------- 顶栏操作按钮 -------- */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-icon-btn {
    background-color: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.2rem;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-round);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-base);
    padding: 0;
}

.header-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

.user-avatar-btn {
    background-color: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
}

.user-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* -------- 顶部状态栏 -------- */
.game-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat {
    background-color: rgba(255, 255, 255, 0.15);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    min-width: 110px;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--c-gold);
}

/* -------- 下一天计时器 -------- */
.time-control {
    flex: 1;
    min-width: 300px;
    margin-top: 15px;
}

.next-day-timer {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.timer-bar {
    flex: 1;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    min-width: 200px;
}

.timer-progress {
    height: 100%;
    background: linear-gradient(to right, var(--c-primary), var(--c-primary-light));
    width: 0%;
    transition: width 1s linear;
    border-radius: 10px;
}

#timer-text {
    min-width: 100px;
    font-weight: bold;
    color: var(--c-gold);
}

/* -------- 游戏主区域：两栏布局 -------- */
.game-area {
    display: flex;
    padding: 25px;
    gap: 25px;
    position: relative;
    z-index: 1;
}

.main-game {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 0;
}

.side-panel {
    flex: 1;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* -------- 事件日志 -------- */
.events-log {
    background-color: var(--c-panel-grey);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 2px solid var(--c-border);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.events-log h3 {
    background: var(--log-header-bg);
    color: var(--c-text-on-dark);
    padding: 18px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
}

.log-controls {
    padding: 15px 25px;
    background-color: var(--c-border-light);
    display: flex;
    gap: 15px;
    border-bottom: 1px solid var(--c-border);
    align-items: center;
    flex-wrap: wrap;
}

.event-frequency {
    margin-left: auto;
    font-weight: bold;
    color: var(--c-text-muted);
}

#event-rate { color: var(--c-primary); }

.log-content {
    padding: 20px;
    height: 300px;
    overflow-y: auto;
    background-color: var(--c-panel-solid);
}

.log-entry {
    padding: 10px 15px;
    margin-bottom: 10px;
    background-color: var(--c-panel-solid);
    border-radius: 8px;
    border-left: 5px solid #8d6e63;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    transition: all var(--t-base);
}

.log-entry:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.08);
}

.log-entry.warning { border-left-color: var(--c-warning); background-color: #fff8e1; }
.log-entry.success { border-left-color: var(--c-success); background-color: var(--c-primary-bg-light); }
.log-entry.event   { border-left-color: var(--c-magic);   background-color: #f3e5f5; }
.log-entry.danger  { border-left-color: var(--c-danger);  background-color: #ffebee; }

/* ============================================================
   4 版布局（由 js/core/layout.js 加到 html 上的类）
   ============================================================ */

/* 默认：移动端工具栏隐藏 */
.mobile-toolbar {
    display: none;
}

html.layout-desktop    .mobile-toolbar { display: none; }
html.layout-wide-short .mobile-toolbar { display: none; }
html.layout-tall-narrow .mobile-toolbar { display: none; }
html.layout-mobile     .mobile-toolbar { display: flex; }

/* -------- 移动版：单栏 + 底部工具栏 + 抽屉侧栏 -------- */
html.layout-mobile .game-area {
    flex-direction: column;
    padding: 15px;
    padding-bottom: 90px;
    gap: 15px;
}

html.layout-mobile .side-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 88vw;
    max-width: 400px;
    height: 100vh;
    height: 100dvh;
    background-color: var(--c-panel-solid);
    z-index: 9000;
    overflow-y: auto;
    padding: 20px;
    transition: right 0.3s ease;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
    min-width: 0;
}

html.layout-mobile .side-panel.open {
    right: 0;
}

html.layout-mobile header {
    padding: 12px 15px;
    gap: 10px;
}

html.layout-mobile header h1 {
    font-size: 1.5rem;
}

html.layout-mobile .stat {
    min-width: 80px;
    padding: 8px 12px;
}

html.layout-mobile .stat-value {
    font-size: 1.3rem;
}

/* -------- 横屏手机版：右侧窄侧栏 -------- */
html.layout-wide-short .game-area {
    flex-direction: row;
    padding: 15px;
    gap: 15px;
}

html.layout-wide-short .side-panel {
    min-width: 260px;
    max-width: 320px;
}

html.layout-wide-short header h1 {
    font-size: 1.6rem;
}

/* -------- 平板竖屏版：主栏 + 3 格侧栏 -------- */
html.layout-tall-narrow .game-area {
    flex-direction: column;
    padding: 18px;
    gap: 18px;
}

html.layout-tall-narrow .side-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    min-width: 0;
}

/* ============================================================
   响应式兜底（保留，用于无 JS 环境的降级）
   ============================================================ */

@media (max-width: 1200px) {
    .game-area { flex-direction: column; }
    .side-panel { min-width: 0; }
}

@media (max-width: 768px) {
    header { flex-direction: column; gap: 20px; padding: 15px; }
    header h1 { font-size: 1.6rem; }
    .game-stats { justify-content: center; gap: 10px; }
    .stat { min-width: 90px; padding: 10px 12px; }
    .stat-value { font-size: 1.4rem; }
    .time-control { min-width: 0; width: 100%; margin-top: 5px; }
    .game-area { padding: 15px; gap: 15px; }
    .log-content { height: 200px; }
}

@media (max-width: 576px) {
    body { padding: 10px; }
    .container { border-radius: var(--radius-md); }
    header h1 { font-size: 1.3rem; }
    .next-day-timer { gap: 8px; font-size: 0.85rem; }
    .timer-bar { min-width: 120px; }
}