/* ==========================================================================
   DouShouQi.com — 設計系統
   「陽光叢林」亮色主題：奶油白底 × 嫩葉綠 × 陽光橘 × 亮藍水域
   走童趣路線：大圓角、圓潤字體、飽和但不刺眼的顏色、柔和彩色陰影
   ========================================================================== */

:root {
    /* 底層 */
    --bg:            #f6faf1;
    --bg-grad-1:     #fbfdf6;
    --bg-grad-2:     #eef7e6;
    --surface:       #ffffff;
    --surface-2:     #f2f8ea;
    --surface-3:     #e5f0d9;
    --surface-hover: #eaf5de;

    /* 線條 */
    --border:        #dbe9cc;
    --border-soft:   rgba(38, 60, 42, .09);
    --border-strong: #bedaa6;

    /* 文字 */
    --text:          #26372a;
    --text-dim:      #5a6f5e;
    --text-mute:     #78907f;

    /* 品牌：陽光橘（主要行動）＋ 嫩葉綠（輔助） */
    --gold:          #f79824;   /* 沿用變數名，實際是陽光橘 */
    --gold-2:        #ffb84d;
    --gold-deep:     #e07d08;
    --gold-dim:      rgba(247, 152, 36, .14);
    --gold-ink:      #4a2a03;   /* 橘底上的深色文字 */

    --leaf:          #3fa96b;
    --leaf-2:        #57c384;
    --leaf-dim:      rgba(63, 169, 107, .14);

    /* 雙方 */
    --red:           #e14b34;
    --red-2:         #ff7d63;
    --red-ink:       #b03520;
    --red-dim:       rgba(225, 75, 52, .13);
    --blue:          #2f86d8;
    --blue-2:        #66b0ec;
    --blue-ink:      #1f6ab3;
    --blue-dim:      rgba(47, 134, 216, .13);

    /* 語意 */
    --success:       #2f9e5f;
    --success-dim:   rgba(47, 158, 95, .14);
    --warning:       #e8940f;
    --danger:        #e04b34;
    --danger-dim:    rgba(224, 75, 52, .13);
    --water:         #7fd0e8;
    --water-2:       #bfe9f5;

    /* 形狀：圓一點比較可愛 */
    --radius-sm:     12px;
    --radius:        18px;
    --radius-lg:     26px;
    --radius-full:   999px;

    --shadow-sm:     0 2px 6px rgba(45, 70, 50, .07);
    --shadow:        0 8px 24px rgba(45, 70, 50, .10);
    --shadow-lg:     0 18px 46px rgba(45, 70, 50, .16);
    --glow-gold:     0 0 0 3px rgba(247, 152, 36, .22), 0 8px 20px rgba(247, 152, 36, .18);

    --header-h:      66px;
    --container:     1220px;

    --ease:          cubic-bezier(.22, .68, .36, 1);
    --bounce:        cubic-bezier(.34, 1.56, .64, 1);
    --font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
}

/* ─────────────────────────── Reset ─────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text);
    background:
        radial-gradient(900px 520px at 10% -8%, rgba(87, 195, 132, .20), transparent 62%),
        radial-gradient(820px 480px at 98% 4%, rgba(127, 208, 232, .22), transparent 58%),
        radial-gradient(700px 420px at 50% 100%, rgba(255, 184, 77, .13), transparent 60%),
        linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2) 55%, var(--bg));
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-deep); text-decoration: none; transition: color .18s var(--ease); }
a:hover { color: var(--gold); }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.18; font-weight: 800; letter-spacing: -.015em; }
h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
p { margin: 0 0 1em; }

::selection { background: rgba(247, 152, 36, .28); color: var(--text); }

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
    border-radius: 6px;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* 捲軸 */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #cfe0be;
    border-radius: 10px;
    border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─────────────────────────── Layout ─────────────────────────── */

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.section { padding: 56px 0; }
.section-tight { padding: 32px 0; }

.page-head {
    text-align: center;
    margin-bottom: 36px;
}
.page-head h1 { margin-bottom: .35em; }
.page-head p {
    color: var(--text-dim);
    max-width: 640px;
    margin: 0 auto;
    font-size: 1.05rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--gold-deep);
    background: var(--gold-dim);
    border: 2px solid rgba(247, 152, 36, .3);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    margin-bottom: 18px;
}

/* ─────────────────────────── Header ─────────────────────────── */

header {
    position: sticky;
    top: 0;
    z-index: 400;
    height: var(--header-h);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 2px solid var(--border-soft);
    box-shadow: 0 2px 14px rgba(45, 70, 50, .05);
}

header .container {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo a {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -.02em;
    color: var(--text);
}
.logo a:hover { color: var(--gold-deep); }
/* Logo 圖示盡量大：導覽列 66px 高，圖示給到 48px，小了就看不出是什麼動物 */
.logo-mark {
    width: 48px; height: 48px;
    flex-shrink: 0;
    display: grid; place-items: center;
    filter: drop-shadow(0 3px 6px rgba(247, 152, 36, .28));
}
.logo-mark svg, .logo-mark img { width: 48px; height: 48px; object-fit: contain; }
.logo-dot { color: var(--gold-deep); }

nav { margin-left: auto; }
nav ul {
    display: flex;
    align-items: center;
    gap: 3px;
    list-style: none;
    margin: 0; padding: 0;
}
nav a {
    display: block;
    padding: 9px 14px;
    border-radius: var(--radius-full);
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-dim);
    white-space: nowrap;
    transition: all .18s var(--ease);
}
nav a:hover { color: var(--text); background: var(--surface-2); }
nav a.active { color: var(--gold-deep); background: var(--gold-dim); }

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    width: 44px; height: 44px;
    align-items: center; justify-content: center;
    border-radius: 14px;
    color: var(--text);
    cursor: pointer;
    background: var(--surface-2);
    border: 2px solid var(--border);
}

/* 已登入的使用者選單 */
.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 14px 4px 4px;
    border-radius: var(--radius-full);
    background: var(--surface-2);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all .18s var(--ease);
}
.user-chip:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.user-chip img {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-3);
}
.user-chip .u-name { font-size: .9rem; font-weight: 800; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u-rating { font-size: .78rem; font-weight: 800; }

.user-menu {
    position: absolute;
    top: calc(var(--header-h) - 4px);
    right: 20px;
    min-width: 244px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 420;
    animation: dropIn .18s var(--bounce);
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px) scale(.97); } }
.user-menu a, .user-menu button {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: none;
    border-radius: 12px;
    color: var(--text-dim);
    font-size: .93rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: all .15s var(--ease);
}
.user-menu a:hover, .user-menu button:hover { background: var(--surface-2); color: var(--text); }
.user-menu i { width: 16px; text-align: center; color: var(--text-mute); }
.user-menu hr { border: 0; border-top: 2px solid var(--border-soft); margin: 6px 4px; }
.user-menu .danger { color: var(--danger); }

/* 手機導覽抽屜 */
.mobile-nav {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(250, 253, 246, .98);
    backdrop-filter: blur(10px);
    z-index: 390;
    padding: 20px;
    overflow-y: auto;
    display: none;
}
.mobile-nav.open { display: block; animation: fadeIn .2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.mobile-nav ul { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.mobile-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text);
    font-weight: 800;
    font-size: 1.02rem;
    box-shadow: var(--shadow-sm);
}
.mobile-nav a.active { border-color: var(--gold); color: var(--gold-deep); background: var(--gold-dim); }
.mobile-nav a i { width: 20px; color: var(--text-mute); }
.mobile-nav a.active i { color: var(--gold-deep); }

/* ─────────────────────────── Buttons ─────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: .95rem;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s var(--ease);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, var(--gold-deep));
    color: var(--gold-ink);
    border-color: rgba(224, 125, 8, .45);
    box-shadow: 0 4px 14px rgba(247, 152, 36, .32);
}
.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffc86b, var(--gold-2) 55%, var(--gold));
    box-shadow: 0 8px 22px rgba(247, 152, 36, .4);
}

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }

.btn-danger { background: var(--danger-dim); border-color: rgba(224, 75, 52, .4); color: #b8341f; }
.btn-danger:hover:not(:disabled) { background: rgba(224, 75, 52, .2); border-color: var(--danger); }

.btn-success { background: var(--success-dim); border-color: rgba(47, 158, 95, .42); color: #1f7a46; }
.btn-success:hover:not(:disabled) { background: rgba(47, 158, 95, .22); border-color: var(--success); }

.btn-sm { padding: 7px 15px; font-size: .86rem; }
.btn-lg { padding: 15px 32px; font-size: 1.06rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; width: 44px; height: 44px; }

.login-btn, .signup-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: .92rem; font-weight: 800;
    cursor: pointer;
    transition: all .18s var(--ease);
}
.login-btn { background: transparent; border: 2px solid var(--border); color: var(--text-dim); }
.login-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.signup-btn {
    background: linear-gradient(135deg, var(--gold-2), var(--gold) 55%, var(--gold-deep));
    color: var(--gold-ink); border: 2px solid rgba(224, 125, 8, .45);
    box-shadow: 0 4px 14px rgba(247, 152, 36, .3);
}
.signup-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(247, 152, 36, .38); }

/* ─────────────────────────── Cards ─────────────────────────── */

.card {
    background: var(--surface);
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.card-head h3 { margin: 0; font-size: 1.08rem; display: flex; align-items: center; gap: 9px; }
.card-head h3 i { color: var(--gold-deep); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ─────────────────────────── 首頁 Hero ─────────────────────────── */

.hero {
    position: relative;
    padding: 56px 0 48px;
    overflow: hidden;
}
.hero-inner {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 48px;
    align-items: center;
}
/* 大標題跟著文字欄的寬度縮放，最長的那一行（英文 "Jungle Chess Online"）才不會被折成兩行 */
.hero-body { container-type: inline-size; }
.hero h1 {
    font-size: clamp(1.5rem, 9cqi, 3.5rem);
    font-weight: 900;
    line-height: 1.06;
    margin-bottom: 18px;
    color: var(--text);
}
.hero-tagline {
    font-size: 1.12rem;
    color: var(--text-dim);
    max-width: 540px;
    margin-bottom: 28px;
}
.hero-media {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 3px solid #ffffff;
    box-shadow: var(--shadow-lg);
    background: linear-gradient(160deg, #eaf7dd, #d9eec6);
    aspect-ratio: 5 / 6;
    display: grid;
    place-items: center;
    padding: 14px;
}
.hero-media img { width: 100%; height: 100%; object-fit: cover; }

/* 首頁的示範棋盤依「高度」縮放，才不會被容器裁掉 */
#hero-board-preview { height: 100%; width: 100%; display: grid; place-items: center; }
#hero-board-preview .board { height: 100%; width: auto; aspect-ratio: 7 / 9; }

.cta-group { display: grid; gap: 12px; max-width: 490px; }
.cta {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: all .2s var(--ease);
}
.cta:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    color: var(--text);
}
.cta > i:first-child {
    width: 50px; height: 50px;
    flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 16px;
    font-size: 1.25rem;
    background: var(--surface-3);
    color: var(--leaf);
}
.cta-text { flex: 1; min-width: 0; }
.cta-text strong { display: block; font-size: 1.08rem; font-weight: 800; }
.cta-text small { display: block; color: var(--text-mute); font-size: .88rem; margin-top: 1px; }
.cta-arrow { color: var(--text-mute); transition: transform .2s var(--bounce); }
.cta:hover .cta-arrow { transform: translateX(5px); color: var(--gold-deep); }

.cta-primary {
    border-color: rgba(247, 152, 36, .5);
    background: linear-gradient(135deg, #fff7e8, #ffeed3);
}
.cta-primary > i:first-child {
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    color: var(--gold-ink);
    box-shadow: 0 3px 10px rgba(247, 152, 36, .3);
}

/* 首頁統計條 */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 34px;
}
.stat-strip div {
    background: var(--surface);
    border: 2px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.stat-strip b {
    display: block;
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--gold-deep);
    font-variant-numeric: tabular-nums;
}
.stat-strip span { font-size: .78rem; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }

/* 特色格 */
.feature {
    padding: 26px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 2px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    transition: all .2s var(--ease);
}
.feature:hover { border-color: var(--border); transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-icon {
    width: 52px; height: 52px;
    border-radius: 16px;
    display: grid; place-items: center;
    background: var(--leaf-dim);
    color: var(--leaf);
    font-size: 1.3rem;
    margin-bottom: 14px;
}
.feature:nth-child(even) .feature-icon { background: var(--gold-dim); color: var(--gold-deep); }
.feature h3 { font-size: 1.1rem; margin-bottom: 8px; }
.feature p { color: var(--text-dim); font-size: .95rem; margin: 0; }

/* 八獸階級展示 */
.animal-ladder {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
}
.animal-tile {
    text-align: center;
    padding: 18px 8px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 2px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    transition: all .22s var(--bounce);
}
.animal-tile:hover { transform: translateY(-6px) rotate(-2deg); border-color: var(--gold); box-shadow: var(--glow-gold); }
.animal-tile svg { width: 50px; height: 50px; margin: 0 auto 8px; }
.animal-tile b { display: block; font-size: .95rem; }
.animal-tile span { display: block; font-size: .76rem; color: var(--text-mute); }
/* 階級數字固定自己一行、置中：不然名字短的（Rat）會跟在後面，名字長的（Elephant）又被擠到下一行 */
.animal-tile .rank-no {
    display: inline-block;
    font-size: .7rem;
    font-weight: 900;
    color: var(--gold-ink);
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    border-radius: var(--radius-full);
    padding: 1px 10px;
    margin: 7px auto 0;
    width: fit-content;
    min-width: 30px;
}

/* ─────────────────────────── 表單 ─────────────────────────── */

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: .87rem;
    font-weight: 800;
    color: var(--text-dim);
    margin-bottom: 7px;
}
/* 用「排除法」而不是列舉 type，否則沒寫 type 屬性的 <input> 會漏掉樣式 */
.input,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]),
select, textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .96rem;
    font-weight: 600;
    transition: all .18s var(--ease);
}
.input:focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 4px var(--gold-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); font-weight: 500; }
textarea { resize: vertical; min-height: 96px; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2378907f' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 11px;
    padding-right: 36px;
    cursor: pointer;
}
.field-hint { font-size: .82rem; color: var(--text-mute); margin-top: 6px; }
.field-error { font-size: .84rem; font-weight: 700; color: var(--danger); margin-top: 6px; }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 2px solid var(--border-soft);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row b { display: block; font-size: .96rem; font-weight: 800; }
.switch-row small { color: var(--text-mute); font-size: .85rem; }

.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
    position: absolute; inset: 0;
    background: var(--surface-3);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all .22s var(--bounce);
}
.switch span::before {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    left: 2px; top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(45, 70, 50, .25);
    transition: all .22s var(--bounce);
}
.switch input:checked + span { background: var(--gold); border-color: var(--gold-deep); }
.switch input:checked + span::before { transform: translateX(22px); }

/* 分段控制 */
.segmented {
    display: inline-flex;
    padding: 4px;
    gap: 3px;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
}
.segmented button {
    padding: 8px 18px;
    border: 0;
    background: none;
    border-radius: var(--radius-full);
    color: var(--text-mute);
    font-size: .9rem;
    font-weight: 800;
    cursor: pointer;
    transition: all .16s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
    background: var(--surface);
    color: var(--gold-deep);
    box-shadow: var(--shadow-sm);
}

/* ─────────────────────────── Modal ─────────────────────────── */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(38, 55, 42, .38);
    backdrop-filter: blur(5px);
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 20px;
    animation: fadeIn .16s var(--ease);
    overflow-y: auto;
}
.modal {
    width: 100%;
    max-width: 450px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalIn .26s var(--bounce);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}
.modal-wide { max-width: 620px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.94); } }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 24px;
    border-bottom: 2px solid var(--border-soft);
}
.modal-head h3 { margin: 0; font-size: 1.2rem; }
.modal-close {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border: 0; background: var(--surface-2);
    border-radius: 12px;
    color: var(--text-mute);
    cursor: pointer;
    transition: all .16s var(--ease);
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-foot {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 16px 24px;
    border-top: 2px solid var(--border-soft);
}

.tabs {
    display: flex;
    gap: 3px;
    padding: 4px;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    margin-bottom: 22px;
}
.tabs button {
    flex: 1;
    padding: 10px;
    border: 0; background: none;
    border-radius: var(--radius-full);
    color: var(--text-mute);
    font-weight: 800;
    font-size: .94rem;
    cursor: pointer;
    transition: all .16s var(--ease);
}
.tabs button.active { background: var(--surface); color: var(--gold-deep); box-shadow: var(--shadow-sm); }

/* ─────────────────────────── Toast ─────────────────────────── */

#toast-stack {
    position: fixed;
    top: calc(var(--header-h) + 14px);
    right: 16px;
    z-index: 950;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 17px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-left: 5px solid var(--gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toastIn .3s var(--bounce);
}
.toast.leaving { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(32px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(32px); } }
.toast i { font-size: 1.1rem; margin-top: 2px; }
.toast-body { flex: 1; min-width: 0; }
.toast-body b { display: block; font-size: .95rem; font-weight: 800; margin-bottom: 2px; }
.toast-body span { font-size: .88rem; color: var(--text-dim); }
.toast.success { border-left-color: var(--success); } .toast.success i { color: var(--success); }
.toast.error   { border-left-color: var(--danger); }  .toast.error i { color: var(--danger); }
.toast.warning { border-left-color: var(--warning); } .toast.warning i { color: var(--warning); }
.toast.info    { border-left-color: var(--blue); }    .toast.info i { color: var(--blue); }
.toast-close { border: 0; background: none; color: var(--text-mute); cursor: pointer; padding: 0 2px; }
.toast-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ─────────────────────────── 表格 ─────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
thead th {
    text-align: left;
    padding: 14px 16px;
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-mute);
    background: var(--surface-2);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 2px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .14s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* 排行榜 */
.lb-pos {
    display: inline-grid;
    place-items: center;
    width: 34px; height: 34px;
    border-radius: 12px;
    font-weight: 900;
    font-size: .88rem;
    background: var(--surface-3);
    color: var(--text-dim);
}
.lb-pos.gold   { background: linear-gradient(135deg, #ffd875, #f0a800); color: #4a2a03; box-shadow: 0 3px 8px rgba(240,168,0,.3); }
.lb-pos.silver { background: linear-gradient(135deg, #e6ecf1, #b4c0cb); color: #38424c; }
.lb-pos.bronze { background: linear-gradient(135deg, #f0bb8c, #c98450); color: #4a2a03; }

.player-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.player-cell img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex-shrink: 0; border: 2px solid var(--border); }
.player-cell .pc-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-cell .pc-sub { font-size: .78rem; color: var(--text-mute); }

.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 4px;
    border-radius: var(--radius-full);
    font-size: .8rem;
    font-weight: 800;
    background: var(--surface-2);
    border: 2px solid var(--border);
}
.rank-badge svg, .rank-badge .badge-img { width: 20px; height: 20px; flex-shrink: 0; }
.rank-badge > span { white-space: nowrap; }

.delta-up { color: var(--success); font-weight: 800; }
.delta-down { color: var(--danger); font-weight: 800; }
.delta-flat { color: var(--text-mute); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: var(--radius-full);
    font-size: .77rem;
    font-weight: 800;
    background: var(--surface-3);
    color: var(--text-dim);
    border: 2px solid transparent;
}
.pill.win  { background: var(--success-dim); color: #1f7a46; }
.pill.loss { background: var(--danger-dim); color: #b8341f; }
.pill.draw { background: var(--surface-3); color: var(--text-dim); }
.pill.live { background: var(--danger-dim); color: #b8341f; }
.pill.live::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: currentColor; animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ─────────────────────────── 空狀態 / 載入 ─────────────────────────── */

.empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-mute);
}
.empty i { font-size: 2.6rem; margin-bottom: 14px; opacity: .35; display: block; color: var(--leaf); }
.empty b { display: block; color: var(--text-dim); font-size: 1.04rem; margin-bottom: 6px; }

.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; gap: 12px; padding: 48px; color: var(--text-mute); }

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─────────────────────────── Footer ─────────────────────────── */

footer {
    margin-top: 72px;
    padding: 48px 0 28px;
    border-top: 2px solid var(--border-soft);
    background: rgba(255, 255, 255, .6);
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(3, 1fr);
    gap: 36px;
    margin-bottom: 34px;
}
.footer-brand p { color: var(--text-mute); font-size: .92rem; max-width: 320px; }
.footer-col h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-mute); margin-bottom: 14px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.footer-col a { color: var(--text-dim); font-size: .92rem; font-weight: 600; }
.footer-col a:hover { color: var(--gold-deep); }
.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-top: 22px;
    border-top: 2px solid var(--border-soft);
    color: var(--text-mute);
    font-size: .87rem;
}
.lang-select {
    padding: 8px 34px 8px 14px;
    font-size: .87rem;
    width: auto;
}

/* ─────────────────────────── 個人頁 ─────────────────────────── */

/* ─────────────────────── 個人檔案 ─────────────────────── */
.profile-hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 22px;
    padding: 26px 28px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #ffffff, #f2f8ea);
    border: 2px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.profile-avatar {
    width: 96px; height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #ffffff;
    box-shadow: var(--shadow);
    background: var(--surface-3);
}
.profile-meta { min-width: 0; }
.profile-meta h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 2px; overflow-wrap: anywhere; }
.profile-sub { color: var(--text-mute); font-size: .86rem; }
.profile-sub span { margin: 0 3px; opacity: .6; }
.profile-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.profile-meta .bio { color: var(--text-dim); font-size: .95rem; margin: 10px 0 0; overflow-wrap: anywhere; }
.profile-actions { display: grid; gap: 8px; }
.fav-chip .piece-img { width: 22px; height: 22px; }
.fav-chip i { color: var(--red); font-size: .7rem; margin-right: 2px; }

.rating-card { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; padding: 20px 24px; }
.rating-badge { width: 76px; height: 76px; flex-shrink: 0; }
.rating-badge img, .rating-badge svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.rating-body { flex: 1; min-width: 0; }
.rating-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.rating-line b { font-size: 2.2rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.rating-rank { font-weight: 800; }
.rating-peak { color: var(--text-mute); font-size: .88rem; margin-left: auto; }
.rating-scale { display: flex; justify-content: space-between; font-size: .76rem; color: var(--text-mute); margin-top: 6px; }

.stat-grid.profile-stats { grid-template-columns: repeat(6, 1fr); margin-bottom: 16px; }
.stat-grid.profile-ai-stats { grid-template-columns: repeat(3, 1fr); }
.profile-two { margin-bottom: 16px; }
#rating-chart { height: 150px; }
.chart-empty {
    height: 100%;
    display: grid; place-content: center; justify-items: center; gap: 8px;
    color: var(--text-mute); font-size: .9rem; text-align: center;
}
.chart-empty i { font-size: 1.6rem; opacity: .35; color: var(--leaf); }

@media (max-width: 900px) {
    .stat-grid.profile-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 620px) {
    .profile-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 12px; padding: 22px 18px; }
    .profile-avatar { width: 84px; height: 84px; }
    .profile-meta h1 { font-size: 1.45rem; }
    .profile-chips { justify-content: center; }
    .profile-actions { width: 100%; }
    .profile-actions .btn { width: 100%; justify-content: center; }
    .rating-card { gap: 14px; padding: 16px; }
    .rating-badge { width: 58px; height: 58px; }
    .rating-line b { font-size: 1.8rem; }
    .profile-stats, .profile-ai-stats { gap: 8px; }
    .profile-stats .stat-box, .profile-ai-stats .stat-box { padding: 12px 6px; }
    .profile-stats .stat-box b, .profile-ai-stats .stat-box b { font-size: 1.3rem; }
    .profile-stats .stat-box span, .profile-ai-stats .stat-box span { font-size: .68rem; letter-spacing: 0; }
}

/* 設定頁：最喜歡的動物 */
.animal-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.animal-opt {
    display: grid; justify-items: center; gap: 4px;
    padding: 10px 4px 8px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    font: inherit; font-size: .8rem; font-weight: 800;
    cursor: pointer;
    transition: all .16s var(--ease);
}
.animal-opt .piece-img, .animal-opt svg { width: 46px; height: 46px; display: block; }
.animal-opt:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.animal-opt.active { border-color: var(--gold); background: var(--gold-dim); color: var(--gold-deep); box-shadow: var(--glow-gold); }
@media (max-width: 760px) { .animal-picker { grid-template-columns: repeat(4, 1fr); } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat-box {
    padding: 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 2px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.stat-box b { display: block; font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-box span { font-size: .78rem; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .04em; }

.progress {
    height: 12px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress > div {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-2));
    border-radius: var(--radius-full);
    transition: width .6s var(--ease);
}

/* ─────────────────────── 內容排版（規則 / 教學 / 法務頁） ─────────────────────── */

.prose { max-width: 780px; margin: 0 auto; }
.prose h2 { margin-top: 2em; padding-bottom: .35em; border-bottom: 3px solid var(--surface-3); }
.prose h3 { margin-top: 1.6em; color: var(--gold-deep); }
.prose p, .prose li { color: var(--text-dim); }
.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 1.2em; }
.prose li { margin-bottom: .5em; }
.prose li::marker { color: var(--leaf); font-weight: 800; }
.prose strong { color: var(--text); font-weight: 800; }
.prose code {
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 7px;
    font-size: .9em;
    border: 2px solid var(--border-soft);
}
.callout {
    display: flex;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #fff8ea, #fff2d9);
    border: 2px solid rgba(247, 152, 36, .3);
    margin: 22px 0;
}
.callout i { color: var(--gold-deep); font-size: 1.15rem; margin-top: 3px; }
.callout p { margin: 0; color: var(--text-dim); font-size: .95rem; }

.rule-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 2px solid var(--border-soft);
}
.rule-row:last-child { border-bottom: 0; }
.rule-row svg { width: 48px; height: 48px; flex-shrink: 0; }
/* 匯入的獸穴／陷阱圖是 <img>，沒給尺寸會用原圖大小撐爆這一列 */
.rule-row img { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; display: block; }
.rule-row b { display: block; font-weight: 800; }
.rule-row span { color: var(--text-mute); font-size: .9rem; }

/* ─────────────────────────── RWD ─────────────────────────── */

@media (max-width: 1080px) {
    nav a { padding: 8px 11px; font-size: .9rem; }
}

/* 英文版的導覽列比中文長很多，1200px 以下放不下七個連結加登入／註冊，改用選單按鈕 */
@media (max-width: 1200px) {
    nav { display: none; }
    .menu-toggle { display: flex; }
    .auth-buttons { margin-left: auto; }
}

@media (max-width: 900px) {
    .auth-buttons .signup-btn { display: none; }
    .hero-inner { grid-template-columns: 1fr; gap: 30px; }
    .hero-media { order: -1; aspect-ratio: 16 / 11; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 26px; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .animal-ladder { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 620px) {
    .container { padding: 0 14px; }
    .section { padding: 36px 0; }
    .hero { padding: 28px 0 26px; }
    .stat-strip { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .card { padding: 18px; }
    .modal { max-width: 100%; }
    #toast-stack { left: 12px; right: 12px; max-width: none; top: calc(var(--header-h) + 8px); }
    .profile-hero { padding: 20px; gap: 16px; }
    .profile-avatar { width: 76px; height: 76px; }
    .animal-ladder { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .animal-tile { padding: 12px 5px; }
    .animal-tile svg { width: 38px; height: 38px; }
    .logo a { font-size: 1.06rem; }
    thead th, tbody td { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   第二輪調整：精簡首頁、手機優先的細節
   ========================================================================== */

/* 所有可點的東西至少 44px 高（Apple / Google 的觸控建議值） */
.btn { min-height: 44px; }
.btn-sm { min-height: 36px; }
.btn-lg { min-height: 52px; }
.login-btn, .signup-btn { min-height: 42px; }
button, a, input, select, label { -webkit-tap-highlight-color: transparent; }

.card-sub { color: var(--text-dim); font-size: .93rem; margin: -6px 0 16px; }
.cell-sub { font-size: .72rem; color: var(--text-mute); }
.desktop-only { }

/* ── 首頁 ── */
.live-strip {
    display: inline-flex; align-items: center; gap: 14px;
    margin-top: 20px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 2px solid var(--border-soft);
    font-size: .86rem; color: var(--text-dim); font-weight: 700;
}
.live-strip b { color: var(--text); font-variant-numeric: tabular-nums; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); animation: pulse 1.6s infinite; }

.hero-media { aspect-ratio: auto; padding: 16px; background: linear-gradient(160deg, #eef8e2, #dcefca); }
#hero-board-preview { height: auto; width: 100%; max-width: 440px; }
#hero-board-preview .board { height: auto; width: 100%; }
#hero-board-preview.board-wrap { box-shadow: var(--shadow); }

/* 主視覺蓋在示範棋盤上面，圓角跟外框一致；停留幾秒後淡出、棋盤淡入（home.js 加上 .show-board） */
.hero-media .hero-art {
    position: absolute;
    /* 同心圓角：內層半徑 = 外框半徑 − 外框白邊 3px − 留白 10px，兩條弧線才會平行 */
    inset: 10px;
    border-radius: calc(var(--radius-lg) - 13px);
    overflow: hidden;
    z-index: 2;
    transition: opacity 1.1s var(--ease);
}
.hero-media .hero-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero-media.has-art #hero-board-preview { opacity: 0; transition: opacity 1.1s var(--ease); }
.hero-media.show-board .hero-art { opacity: 0; pointer-events: none; }
.hero-media.show-board #hero-board-preview { opacity: 1; }

/* ── 線上對戰大廳 ── */
.lobby-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 880px; margin: 0 auto; }
.lobby-grid + .card { max-width: 880px; margin-left: auto; margin-right: auto; }
.join-row { display: flex; gap: 8px; margin-top: 12px; }
.join-row input {
    flex: 1; min-width: 0;
    text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 800;
}
.join-row input::placeholder { letter-spacing: .2em; }
.check-row {
    display: flex; align-items: center; gap: 9px;
    margin-top: 14px;
    font-size: .88rem; font-weight: 700; color: var(--text-dim);
    cursor: pointer;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--gold); flex-shrink: 0; }
.waiting-card { max-width: 480px; margin: 32px auto; text-align: center; }

/* ── 教學 ── */
.lesson-title { font-size: 1.2rem; margin: 0 0 6px; }
.lesson-text { color: var(--text-dim); font-size: .96rem; margin: 0; }
.lesson-feedback { font-size: .92rem; font-weight: 700; margin-top: 10px; }
.lesson-feedback:empty { display: none; }
#lesson-list .room-card { width: 100%; text-align: left; cursor: pointer; padding: 9px 12px; }

/* ── 手機 ── */
@media (max-width: 1024px) {
    .desktop-only { display: none !important; }
}

@media (max-width: 900px) {
    .hero-inner { gap: 26px; }
    .hero-media { order: 0; aspect-ratio: auto; padding: 12px; }
    #hero-board-preview { max-width: 400px; margin: 0 auto; }
    .cta-group { max-width: none; }
    .hero h1 { margin-bottom: 12px; }
    .hero-tagline { font-size: 1.02rem; margin-bottom: 20px; }
}

@media (max-width: 720px) {
    .lobby-grid { grid-template-columns: minmax(0, 1fr); }
    .col-hide-sm { display: none; }
}

@media (max-width: 620px) {
    :root { --header-h: 58px; }
    .page-head { margin-bottom: 22px; }
    .page-head p { font-size: .98rem; }
    .section { padding: 32px 0; }
    .eyebrow { font-size: .72rem; padding: 5px 13px; margin-bottom: 12px; }
    .cta { padding: 13px 14px; gap: 12px; }
    .cta > i:first-child { width: 44px; height: 44px; border-radius: 14px; font-size: 1.1rem; }
    .cta-text strong { font-size: 1rem; }
    .cta-text small { font-size: .82rem; }
    .logo-mark, .logo-mark svg, .logo-mark img { width: 42px; height: 42px; }
    .login-btn { padding: 8px 15px; min-height: 40px; }
    .menu-toggle { width: 40px; height: 40px; border-radius: 13px; }
    header .container { gap: 10px; }
    .logo { margin-right: auto; }

    /* 對話框在手機上從底部滑出，按鈕落在拇指搆得到的位置 */
    .modal-backdrop { place-items: end center; padding: 0; }
    .modal {
        max-width: 100%;
        border-radius: 26px 26px 0 0;
        border-bottom: 0;
        max-height: 92vh;
        padding-bottom: env(safe-area-inset-bottom, 0);
        animation: sheetIn .26s var(--ease);
    }
    .modal-head { padding: 16px 18px; }
    .modal-body { padding: 18px; }
    .modal-foot { padding: 12px 18px 16px; }
    .modal-foot .btn { flex: 1; }

    #toast-stack { top: calc(var(--header-h) + 8px); }
    .toast { padding: 12px 14px; }

    footer { margin-top: 40px; padding: 30px 0 22px; }
    .footer-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 22px; }
    .footer-brand { grid-column: 1 / -1; }
    .footer-brand p { max-width: none; }
    .footer-col h4 { margin-bottom: 9px; }
    .footer-col ul { gap: 7px; }
    .footer-bottom { flex-direction: column; align-items: flex-start; }
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }

/* 有瀏海的手機：內容不要被瀏海或 Home 橫條蓋住 */
@supports (padding: max(0px)) {
    .container { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
    @media (max-width: 620px) {
        .container { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
    }
}

/* ==========================================================================
   共用元件（原本放在 board.css，但好友、訊息、後台這些沒有棋盤的頁面也在用。
   放在只有對局頁才載入的檔案裡，其他頁面就會沒有樣式：頭像變成原圖大小、
   陣營圓點塌成一條線。）
   ========================================================================== */

/* 陣營圓點 */
.side-dot {
    display: inline-block;      /* 不在 flex 容器裡時也要有寬高，否則會塌成一條細弧線 */
    vertical-align: -1px;
    width: 11px; height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1.5px currentColor;
}
.side-dot.red { background: var(--red); color: var(--red); }
.side-dot.blue { background: var(--blue); color: var(--blue); }

/* 房間／玩家／對局列表的卡片 */
.room-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 2px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    color: inherit;
    font: inherit;
}
.room-card + .room-card { margin-top: 8px; }
.room-card img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); border: 2px solid var(--border); flex-shrink: 0; }
.room-card .rc-info { flex: 1; min-width: 0; }
.room-card .rc-name { font-weight: 800; font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card .rc-meta { font-size: .79rem; color: var(--text-mute); display: flex; gap: 10px; flex-wrap: wrap; }
/* 觀戰列表：一列裡有兩位玩家，各自是「頭像 + 陣營圓點 + 名字」 */
.rc-versus { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-weight: 800; font-size: .96rem; margin-bottom: 4px; }
.rc-player { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.rc-player img { width: 32px; height: 32px; }
.rc-player b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14ch; }
.rc-player .rc-rating { color: var(--gold-deep); font-size: .8rem; font-weight: 800; }
.rc-vs { color: var(--text-mute); font-weight: 700; font-size: .84rem; }

/* 聊天訊息（對局內聊天與私人訊息共用） */
.chat-box { display: flex; flex-direction: column; height: 236px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; margin-bottom: 8px; }
.chat-msg { font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.chat-msg .who { font-weight: 800; margin-right: 5px; }
.chat-msg .who.red { color: var(--red-ink); }
.chat-msg .who.blue { color: var(--blue-ink); }
.chat-msg .who.spectator { color: var(--text-mute); }
.chat-msg.system { color: var(--text-mute); font-style: italic; font-size: .82rem; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; min-width: 0; padding: 10px 14px; font-size: .92rem; }
