:root {
    --bg: #e8f5e9;
    --card: #ffffff;
    --primary: #43a047;
    --primary-dark: #2e7d32;
    --accent: #ffca28;
    --accent-dark: #ffb300;
    --danger: #ef5350;
    --text: #333;
    --shadow: rgba(0, 0, 0, 0.15);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

#app {
    width: 100%;
    height: 100vh;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 开始界面 */
.setup-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 32px 40px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 8px 24px var(--shadow);
    text-align: center;
}

.setup-card h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    color: var(--primary-dark);
}

.subtitle {
    margin: 0 0 24px;
    font-size: 1.1rem;
    color: #666;
}

.rules {
    background: #f1f8e9;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 18px;
    text-align: left;
}

.rules h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: var(--primary-dark);
}

.rules ul {
    margin: 0;
    padding-left: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
}

.rules li {
    margin-bottom: 4px;
}

.form-row {
    margin-bottom: 18px;
    text-align: left;
}

.form-row label {
    display: block;
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 6px;
}

.form-row input,
.form-row select {
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    border: 2px solid #c8e6c9;
    border-radius: 12px;
    outline: none;
}

.form-row input:focus,
.form-row select:focus {
    border-color: var(--primary);
}

.player-name-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.player-name-input .avatar {
    font-size: 1.6rem;
}

/* 按钮 */
.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 3px 0 var(--primary-dark);
}

.btn-primary:hover {
    box-shadow: 0 5px 0 var(--primary-dark);
}

.btn-primary:active {
    box-shadow: 0 1px 0 var(--primary-dark);
}

.btn-small {
    background: var(--accent);
    color: #5d4037;
    box-shadow: 0 2px 0 var(--accent-dark);
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-small:hover {
    box-shadow: 0 4px 0 var(--accent-dark);
}

/* 游戏主界面 - 大屏一屏展示 */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: var(--card);
    box-shadow: 0 2px 8px var(--shadow);
    height: 56px;
    flex-shrink: 0;
}

.game-header h1 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--primary-dark);
}

.timer-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-dark);
    background: #e8f5e9;
    padding: 4px 12px;
    border-radius: 10px;
    border: 2px solid #c8e6c9;
}

.timer-display.timer-warning {
    color: #d32f2f;
    background: #ffebee;
    border-color: #ef5350;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 14px;
    padding: 14px;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
}

.panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: 0 4px 12px var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: var(--primary-dark);
}

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

.panel-header h3 {
    margin: 0;
}

/* 玩家面板 */
.players-panel {
    flex: 1;
    overflow-y: auto;
}

#player-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    background: #f1f8e9;
    border: 2px solid transparent;
}

.player-item.active {
    background: #c8e6c9;
    border-color: var(--primary);
}

.player-avatar {
    font-size: 2rem;
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-info .name {
    font-weight: bold;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-info .pinyin {
    font-size: 0.7rem;
    color: #888;
}

.player-progress {
    font-size: 0.8rem;
    color: #555;
    margin: 4px 0;
}

.coins {
    color: #f9a825;
    font-weight: bold;
}

/* 状态条 */
.stats-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.stat {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
}

.stat-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 2px;
}

.stat-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.stat-fill.hunger { background: #ff9800; }
.stat-fill.happiness { background: #ec407a; }
.stat-label {
    color: #666;
}

/* 棋盘区域 */
.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.dice-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 8px 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.dice {
    font-size: 2.4rem;
    line-height: 1;
    transition: transform 0.2s;
}

.dice.rolling {
    animation: shake 0.4s infinite;
}

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

.hint {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 6px;
    width: 100%;
    max-height: calc(100vh - 160px);
    aspect-ratio: 1 / 1;
}

.cell {
    background: var(--card);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2px;
    box-shadow: 0 2px 4px var(--shadow);
    position: relative;
    font-size: 0.65rem;
    overflow: hidden;
}

.cell .emoji {
    font-size: 1.3rem;
    margin-bottom: 1px;
}

.cell .name {
    font-size: 0.6rem;
    font-weight: bold;
    line-height: 1.1;
}

.cell .pinyin {
    font-size: 0.5rem;
    color: #888;
}

.cell.start { background: #fff9c4; }
.cell.tree { background: #c8e6c9; }
.cell.recycle { background: #b3e5fc; }
.cell.energy { background: #fff59d; }
.cell.animal { background: #f8bbd0; }
.cell.ocean { background: #b2dfdb; }
.cell.chance { background: #fff59d; border: 2px solid #fbc02d; }
.cell.fate { background: #ffccbc; border: 2px solid #e64a19; }
.cell.auction { background: #e1f5fe; border: 2px solid #0288d1; }

.cell-large .emoji { font-size: 2rem; }
.cell-large .name { font-size: 0.8rem; }
.cell-large .pinyin { font-size: 0.55rem; }

.cell.current {
    box-shadow: 0 0 0 4px var(--primary), 0 4px 12px rgba(67, 160, 71, 0.4);
    animation: pulse-cell 1.2s infinite;
    z-index: 1;
}

@keyframes pulse-cell {
    0%, 100% { box-shadow: 0 0 0 4px var(--primary), 0 4px 12px rgba(67, 160, 71, 0.4); }
    50% { box-shadow: 0 0 0 6px #66bb6a, 0 6px 16px rgba(67, 160, 71, 0.55); }
}

.cell .players {
    position: absolute;
    bottom: 2px;
    display: flex;
    gap: 2px;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.board-center {
    grid-row: 3 / 8;
    grid-column: 3 / 8;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: inset 0 0 20px rgba(67, 160, 71, 0.12);
    border: 2px dashed #a5d6a7;
}

.center-emoji {
    font-size: 2.4rem;
    margin-bottom: 4px;
}

.center-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-dark);
}

.center-sub {
    font-size: 0.75rem;
    color: #558b2f;
}

/* 知识面板 */
.knowledge-panel p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 10px;
}

.knowledge-panel .pinyin {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

/* 日志 */
.log-panel {
    flex: 1;
    min-height: 0;
}

.log-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    font-size: 0.8rem;
    flex: 1;
}

.log-panel li {
    padding: 5px 0;
    border-bottom: 1px dashed #e0e0e0;
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}

.modal-content h2 {
    margin-top: 0;
    font-size: 1.3rem;
    color: var(--primary-dark);
}

.modal-close-x {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 32px;
    color: #666;
    cursor: pointer;
    transition: 0.15s;
    padding: 0;
}

.modal-close-x:hover {
    background: #ef5350;
    color: #fff;
}

.modal-content .emoji-big {
    font-size: 3.5rem;
    margin-bottom: 10px;
}

.modal-content p {
    font-size: 1rem;
    line-height: 1.5;
    margin: 8px 0;
}

.modal-content .pinyin {
    font-size: 0.85rem;
    color: #888;
}

.modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 选择题按钮 */
.choice-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.choice-btn {
    background: #f1f8e9;
    border: 2px solid #c8e6c9;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.15s;
}

.choice-btn:hover {
    background: #c8e6c9;
    border-color: var(--primary);
}

.choice-btn.correct {
    background: #a5d6a7;
    border-color: var(--primary-dark);
}

.choice-btn.wrong {
    background: #ef9a9a;
    border-color: var(--danger);
}

/* 问答 */
.quiz-question {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin: 14px 0 4px;
    line-height: 1.4;
}

.quiz-pinyin {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 14px;
}

.quiz-choices {
    flex-direction: column;
    gap: 8px;
}

.quiz-choice {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.quiz-explain {
    background: #f1f8e9;
    border-radius: 10px;
    padding: 10px;
    margin-top: 10px;
    font-size: 0.9rem;
    color: #555;
}

/* 商城 */
.shop-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.shop-tab {
    background: #f1f8e9;
    border: 2px solid #c8e6c9;
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.9rem;
}

.shop-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.shop-wallet {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.shop-card {
    background: #fff;
    border: 2px solid #c8e6c9;
    border-radius: 10px;
    padding: 8px 4px;
    cursor: pointer;
    transition: 0.15s;
    text-align: center;
}

.shop-card:hover {
    border-color: var(--primary);
    background: #f1f8e9;
}

.shop-card.owned {
    opacity: 0.5;
    cursor: default;
    background: #f5f5f5;
    border-color: #e0e0e0;
}

.shop-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
    background: #fafafa;
}

.shop-emoji {
    font-size: 1.6rem;
    margin-bottom: 2px;
}

.shop-name {
    font-size: 0.8rem;
    font-weight: bold;
    color: #333;
    line-height: 1.2;
}

.shop-desc {
    font-size: 0.7rem;
    color: #666;
    margin-top: 2px;
}

.shop-price {
    font-size: 0.8rem;
    color: var(--primary-dark);
    font-weight: bold;
    margin-top: 4px;
}

/* 房屋预览 */
.house-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 70px;
    position: relative;
    margin: 0 auto;
}

.house-flag {
    position: absolute;
    top: -8px;
    right: -6px;
    font-size: 1rem;
    z-index: 2;
    animation: wave 1.5s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.house-roof {
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 24px solid #8d6e63;
    position: relative;
    background: transparent !important;
}

.house-roof-icon {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
}

.house-body {
    width: 50px;
    height: 40px;
    background: #fff9c4;
    border-radius: 0 0 3px 3px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.house-window {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: #b3e5fc;
    font-size: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.house-door {
    width: 14px;
    height: 24px;
    border-radius: 3px 3px 0 0;
    background: #5d4037;
    font-size: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
}

.house-garden {
    width: 58px;
    height: 12px;
    background: #c8e6c9;
    border-radius: 6px;
    margin-top: 1px;
    font-size: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-house {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-house .decorate-btn {
    margin-top: 4px;
    padding: 3px 8px;
    font-size: 0.7rem;
    background: #e1f5fe;
    color: #0277bd;
    box-shadow: 0 2px 0 #0288d1;
}

/* 道具卡 */
.item-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.item-card {
    background: #fff;
    border: 2px solid #c8e6c9;
    border-radius: 10px;
    padding: 10px;
    width: 100px;
    cursor: pointer;
    transition: 0.15s;
}

.item-card:hover {
    border-color: var(--primary);
    background: #f1f8e9;
}

.item-card .item-emoji {
    font-size: 1.6rem;
    margin-bottom: 2px;
}

.item-card .item-name {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--primary-dark);
}

.item-card .item-desc {
    font-size: 0.7rem;
    color: #666;
    margin-top: 2px;
}

.player-items {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin: 3px 0;
}

.item-badge {
    background: #fff;
    border-radius: 6px;
    padding: 1px 3px;
    font-size: 0.95rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 排行榜 */
.rank-list {
    margin-top: 16px;
    text-align: left;
}

.rank-list h3 {
    text-align: center;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.rank-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f8e9;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.rank-row.rank-first {
    background: #fff9c4;
    border: 2px solid var(--accent-dark);
}

.rank-num {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary-dark);
    width: 24px;
    text-align: center;
}

.rank-avatar {
    font-size: 1.3rem;
}

.rank-name {
    flex: 1;
    font-weight: bold;
}

.rank-score {
    font-weight: bold;
    color: var(--primary-dark);
}

/* 响应式 */
@media (max-width: 1100px) {
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        overflow-y: auto;
    }
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar > * {
        flex: 1 1 260px;
    }
    .board {
        max-width: 100%;
    }
}
