:root {
    /* 日系柔和配色 */
    --bg-color: #F7F5EE;       /* 鳥の子色 / 暖白 */
    --surface: #FFFFFF;
    --text-main: #383431;      /* 墨色 */
    --text-muted: #8F877E;     /* 灰桜 */
    
    /* 柔和硬阴影 (柔和暖调，无模糊) */
    --shadow-color: #DDD4C5;
    --shadow: 3px 3px 0px var(--shadow-color);
    --shadow-sm: 2px 2px 0px var(--shadow-color);
    --shadow-btn: 2px 2px 0px #C9BFB0;
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    /* 双方棋子颜色 */
    --piece-white: #FAF8F2;    /* 胡粉白 */
    --piece-black: #3A3735;    /* 墨石黑 */
    
    /* 昆虫日系和色 */
    --c-queen: #E8A838;  /* 山吹色 */
    --c-ant: #456B91;    /* 藍色 */
    --c-hopper: #659360; /* 抹茶色 */
    --c-beetle: #7C5A86; /* 紫苑 */
    --c-spider: #BE623E; /* 弁柄 */
    --c-lady: #CD483F;   /* 茜色 */
    --c-pill: #427C77;   /* 青鈍 */
    --c-mosq: #858E92;   /* 利休鼠 */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ==================== 顶部导航 ==================== */
header {
    background: var(--surface);
    box-shadow: 0 2px 0px var(--shadow-color);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    width: 100%;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* 状态胶囊标签 */
.status-capsule {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.status-capsule.white {
    background: var(--piece-white);
    color: var(--text-main);
}

.status-capsule.black {
    background: var(--piece-black);
    color: #FAF8F2;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* ==================== 按钮系统 ==================== */
.btn {
    background: #FFFFFF;
    color: var(--text-main);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: bold;
    box-shadow: var(--shadow-btn);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #C9BFB0;
}

.btn.primary {
    background: #E8A838;
    color: #2D271F;
}

.btn.icon-btn {
    width: 35px;
    height: 35px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
}

.btn.icon-btn svg {
    display: block;
}

/* ==================== 游戏棋盘 ==================== */
#board-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: pan-x pan-y;
}

#board-container:active {
    cursor: grabbing;
}

#game-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==================== 底部手牌区 ==================== */
#hand-panel {
    background: var(--surface);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 0px var(--shadow-color);
    z-index: 10;
    position: relative;
    width: 100%;
}

.hand-scroll {
    display: flex;
    overflow-x: auto;
    padding: 6px 4px 2px;
    scrollbar-width: none;
    align-items: center;
}

.hand-scroll::-webkit-scrollbar {
    display: none;
}

.hex-hand-item {
    position: relative;
    flex: 0 0 52px;
    height: 58px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.14s ease;
}

.hex-hand-item svg {
    width: 52px;
    height: 58px;
    overflow: visible;
}

.hex-hand-item.disabled {
    opacity: 0.3;
    filter: grayscale(70%);
    pointer-events: none;
}

.hex-hand-item.selected {
    transform: translateY(-7px);
}

.hex-hand-badge {
    position: absolute;
    top: -2px;
    right: 0px;
    background: var(--text-main);
    color: #FFF;
    font-size: 0.65rem;
    font-weight: 900;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ==================== 弹窗模态框 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(45, 41, 38, 0.35);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #FFF;
    width: 100%;
    max-width: 320px;
    border-radius: var(--radius-lg);
    box-shadow: 4px 4px 0px var(--shadow-color);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 900;
    text-align: center;
}

/* 房间码与输入框 */
.code-box-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg-color);
    padding: 10px;
    border-radius: var(--radius-md);
    min-height: 48px;
}

.code-text {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 4px;
}

.input-box {
    width: 100%;
    height: 48px;
    font-size: 1.5rem;
    letter-spacing: 4px;
    text-align: center;
    padding: 10px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-main);
    outline: none;
    font-weight: 900;
}

.input-box::placeholder {
    color: var(--text-muted);
    font-size: 0.95rem;
    letter-spacing: 1px;
    font-weight: normal;
}

.input-box:focus {
    box-shadow: inset 0 0 0 2px var(--shadow-color);
}

/* 联机弹窗按钮覆盖 */
#onlineModal .btn {
    background: var(--piece-black);
    color: var(--piece-white);
    box-shadow: 2px 2px 0px #1E1C1B;
}

#onlineModal .btn:active {
    box-shadow: 1px 1px 0px #1E1C1B;
    transform: translate(1px, 1px);
}

#onlineModal .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: 2px 2px 0px #1E1C1B;
}

.rule-item {
    font-size: 0.8rem;
    line-height: 1.5;
    padding-bottom: 6px;
    border-bottom: 1px dashed #E8E2D7;
}

/* ==================== DLC 扩展列表 ==================== */
.dlc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dlc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
}

.dlc-item:active {
    background: #EFECE3;
}

.dlc-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dlc-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 1px 1px 0px rgba(0,0,0,0.15);
}

.dlc-name {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-main);
}

.dlc-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ==================== 滑动开关 ==================== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #D6CFBE;
    border-radius: 24px;
    transition: 0.2s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background-color: #E8A838;
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}
