/* ============================================
   台灣16張麻將 - 遊戲樣式
   ============================================ */

:root {
    --table-green: #1a6b3c;
    --table-dark: #0d4a28;
    --table-border: #8b6914;
    --tile-width: 42px;
    --tile-height: 58px;
    --tile-small: 0.6;
    --gold: #d4a517;
    --gold-light: #f0d060;
    --red: #cc2222;
}

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

body {
    font-family: 'Microsoft JhengHei', '微軟正黑體', 'Noto Sans TC', sans-serif;
    background: #0a0a0a;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== 大廳 ===== */
#lobby {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #0d1b0e 0%, #1a3a1f 50%, #0d1b0e 100%);
}

#lobby h1 {
    font-size: 3rem;
    color: var(--gold);
    text-shadow: 0 2px 10px rgba(212,165,23,0.5);
    margin-bottom: 40px;
    letter-spacing: 8px;
}

#lobby h1 span {
    font-size: 1.2rem;
    display: block;
    color: #aaa;
    letter-spacing: 2px;
    margin-top: 8px;
}

.lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 320px;
}

.lobby-btn {
    padding: 16px 32px;
    font-size: 1.2rem;
    border: 2px solid var(--gold);
    background: rgba(26,107,60,0.6);
    color: var(--gold-light);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 3px;
    font-weight: bold;
}

.lobby-btn:hover {
    background: rgba(26,107,60,0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(212,165,23,0.3);
}

.lobby-input {
    padding: 14px 20px;
    font-size: 1.1rem;
    border: 2px solid #555;
    background: rgba(0,0,0,0.4);
    color: #fff;
    border-radius: 8px;
    text-align: center;
    letter-spacing: 2px;
}

.lobby-input:focus {
    border-color: var(--gold);
    outline: none;
}

.lobby-section {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #333;
    border-radius: 12px;
    background: rgba(0,0,0,0.3);
    width: 320px;
}

.lobby-section h3 {
    color: var(--gold);
    margin-bottom: 12px;
    font-size: 1rem;
}

.room-list {
    max-height: 200px;
    overflow-y: auto;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #333;
}

.room-item button {
    padding: 4px 16px;
    background: var(--gold);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    color: #000;
}

/* ===== 等待室 ===== */
#waiting-room {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #0d1b0e 0%, #1a3a1f 50%, #0d1b0e 100%);
}

.waiting-info {
    text-align: center;
}

.waiting-info h2 {
    color: var(--gold);
    font-size: 2rem;
    margin-bottom: 20px;
}

.waiting-info .room-code {
    font-size: 2.5rem;
    color: #fff;
    background: rgba(0,0,0,0.4);
    padding: 10px 30px;
    border-radius: 10px;
    letter-spacing: 6px;
    margin-bottom: 20px;
    display: inline-block;
}

.player-slots {
    display: flex;
    gap: 20px;
    margin: 30px 0;
}

.player-slot {
    width: 100px;
    height: 120px;
    border: 2px dashed #555;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.player-slot.filled {
    border-color: var(--gold);
    background: rgba(26,107,60,0.3);
}

.player-slot .wind-label {
    color: var(--gold);
    font-size: 1.5rem;
    font-weight: bold;
}

.player-slot .player-name {
    color: #ccc;
    font-size: 0.85rem;
    margin-top: 8px;
}

/* ===== 遊戲桌面 ===== */
#game-board {
    display: none;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    background:
        radial-gradient(ellipse at center, var(--table-green) 0%, var(--table-dark) 80%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='1' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E");
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* 桌面邊框裝飾 */
#game-board::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 3px solid rgba(139,105,20,0.3);
    border-radius: 20px;
    pointer-events: none;
    z-index: 1;
}

/* ===== 玩家區域 ===== */
.player-area {
    position: absolute;
    display: flex;
    align-items: center;
    z-index: 10;
}

/* 自己（下方） */
.player-area.bottom {
    bottom: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    gap: 4px;
    max-width: 95vw;
}

/* 對面（上方） */
.player-area.top {
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column-reverse;
    gap: 4px;
}

/* 右方 */
.player-area.right {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: row-reverse;
    gap: 4px;
}

/* 左方 */
.player-area.left {
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: row;
    gap: 4px;
}

/* ===== 牌 ===== */
.tile {
    width: var(--tile-width);
    height: var(--tile-height);
    cursor: default;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    flex-shrink: 0;
}

.tile img {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: #fff;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
}

/* 手牌容器 */
.hand-tiles {
    display: flex;
    gap: 2px;
    align-items: flex-end;
}

/* 自己的手牌 - 可以點擊，放大 1.3 倍 */
.player-area.bottom .hand-tiles .tile {
    cursor: pointer;
    width: calc(var(--tile-width) * 1.3);
    height: calc(var(--tile-height) * 1.3);
}

.player-area.bottom .hand-tiles .tile:hover {
    transform: translateY(-12px);
    z-index: 20;
}

.player-area.bottom .hand-tiles .tile.selected {
    transform: translateY(-16px);
    box-shadow: 0 0 12px var(--gold);
}

/* 剛摸到的牌 稍微分開 */
.tile.drawn-tile {
    margin-left: 12px !important;
}

/* 摸到的牌放最右邊 */
.tile.drawn-tile-right {
    margin-left: 16px !important;
    position: relative;
}

.tile.drawn-tile-right::before {
    content: '';
    position: absolute;
    left: -9px;
    top: 5%;
    height: 90%;
    width: 2px;
    background: rgba(212,165,23,0.5);
    border-radius: 1px;
}

/* 摸牌佔位虛線牌 */
.draw-placeholder {
    margin-left: 16px !important;
    border: 2px dashed rgba(255,255,255,0.5);
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    cursor: pointer !important;
    position: relative;
    animation: draw-pulse 1.8s infinite;
}

.draw-placeholder::after {
    content: '摸';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.6);
    font-size: 1rem;
    font-weight: bold;
    pointer-events: none;
}

.draw-placeholder:hover {
    border-color: var(--gold);
    background: rgba(255,255,255,0.15);
    transform: translateY(-6px);
}

@keyframes draw-pulse {
    0%, 100% { border-color: rgba(255,255,255,0.3); }
    50% { border-color: rgba(255,255,255,0.7); }
}

/* 上方玩家的牌（較小） */
.player-area.top .tile {
    width: calc(var(--tile-width) * 0.55);
    height: calc(var(--tile-height) * 0.55);
}

/* 左右玩家的牌（旋轉） */
.player-area.left .hand-tiles,
.player-area.right .hand-tiles {
    flex-direction: column;
    gap: 1px;
}

.player-area.left .tile,
.player-area.right .tile {
    width: calc(var(--tile-height) * 0.55);
    height: calc(var(--tile-width) * 0.55);
}

.player-area.left .tile img,
.player-area.right .tile img {
    transform: rotate(90deg);
    transform-origin: center center;
    width: calc(var(--tile-width) * 0.55);
    height: calc(var(--tile-height) * 0.55);
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: calc(var(--tile-height) * -0.275);
    margin-left: calc(var(--tile-width) * -0.275);
}

/* ===== 玩家資訊框 ===== */
.player-info {
    position: absolute;
    z-index: 15;
    background: rgba(0,0,0,0.7);
    border: 2px solid rgba(139,105,20,0.6);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 110px;
    text-align: center;
}

.player-info.active {
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(212,165,23,0.4);
}

.player-info .name {
    font-size: 0.9rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 3px;
}

.player-info .wind {
    color: var(--gold);
    font-size: 1.2rem;
    font-weight: bold;
}

.player-info .score {
    font-size: 0.8rem;
    color: #8f8;
    margin-top: 2px;
}

.player-info .flower-count {
    font-size: 0.75rem;
    color: #f88;
}

/* 資訊框位置 */
.player-info.pos-bottom {
    bottom: 10px;
    left: 20px;
}

.player-info.pos-right {
    bottom: 20px;
    right: 10px;
}

.player-info.pos-top {
    top: 10px;
    right: 20px;
}

.player-info.pos-left {
    top: 20px;
    left: 10px;
}

/* ===== 桌面中央區域 ===== */
.center-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    height: 340px;
    z-index: 5;
}

/* 風位指示器 */
.wind-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    z-index: 6;
}

.wind-compass {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 3px solid var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.wind-compass .current-wind {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--gold);
}

.wind-compass .remaining {
    position: absolute;
    bottom: -24px;
    font-size: 0.75rem;
    color: #aaa;
    white-space: nowrap;
}

/* 四個方向的字 */
.wind-compass .w-top, .wind-compass .w-bottom,
.wind-compass .w-left, .wind-compass .w-right {
    position: absolute;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}
.wind-compass .w-top { top: 4px; }
.wind-compass .w-bottom { bottom: 4px; }
.wind-compass .w-left { left: 6px; }
.wind-compass .w-right { right: 6px; }
.wind-compass .w-active { color: var(--gold); font-weight: bold; }

/* ===== 棄牌區 ===== */
.discard-area {
    position: absolute;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    z-index: 4;
}

.discard-area .tile {
    width: 30px;
    height: 40px;
}

.discard-area .tile img {
    border-radius: 2px;
}

/* 下方棄牌 — 靠近下方玩家，遠離指南針 */
.discard-area.bottom-discard {
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    justify-content: center;
    align-content: flex-end;
}

/* 上方棄牌 — 靠近上方玩家 */
.discard-area.top-discard {
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    justify-content: center;
    align-content: flex-start;
}

/* 右方棄牌 — 靠近右側玩家 */
.discard-area.right-discard {
    right: 24%;
    top: 50%;
    transform: translateY(-50%);
    width: 90px;
    justify-content: center;
    align-content: center;
}

/* 左方棄牌 — 靠近左側玩家 */
.discard-area.left-discard {
    left: 24%;
    top: 50%;
    transform: translateY(-50%);
    width: 90px;
    justify-content: center;
    align-content: center;
}

/* 最後打出的牌高亮 (吃碰槓對象牌) — 鮮紅邊框 + 強烈脈動光暈 */
.discard-area .tile.last-discard {
    border-radius: 4px;
    outline: 3px solid #ff3333;
    outline-offset: 1px;
    z-index: 5;
}
.discard-area .tile.last-discard img {
    box-shadow: 0 0 0 3px #ff3333, 0 0 18px 6px rgba(255,60,60,0.85);
    animation: lastDiscardPulse 0.7s ease-in-out infinite alternate;
    border-radius: 3px;
}
@keyframes lastDiscardPulse {
    from { box-shadow: 0 0 0 3px #ff3333, 0 0 10px 3px rgba(255,60,60,0.7); }
    to   { box-shadow: 0 0 0 4px #ff8800, 0 0 22px 10px rgba(255,100,0,1.0); }
}

/* ===== 吃碰槓的明面牌 ===== */
.melds-area {
    display: flex;
    gap: 8px;
    order: -1;
}

.meld-group {
    display: flex;
    gap: 1px;
    background: rgba(0,0,0,0.2);
    padding: 2px;
    border-radius: 4px;
}

.meld-group .tile {
    width: 28px;
    height: 38px;
}

/* 下方玩家：吃碰槓在手牌上面 */
.player-area.bottom {
    flex-wrap: wrap;
    justify-content: center;
}
.player-area.bottom .melds-area {
    width: 100%;
    justify-content: center;
    margin-bottom: 2px;
}

/* 上方玩家：吃碰槓在手牌下面（靠中央） */
.player-area.top {
    flex-wrap: wrap;
    justify-content: center;
}
.player-area.top .melds-area {
    width: 100%;
    justify-content: center;
    order: -1;
    margin-bottom: 2px;
}

/* 左方玩家：吃碰槓在手牌右側（靠中央） */
.player-area.left .melds-area {
    flex-direction: column;
    gap: 4px;
    order: 1;
}

.player-area.left .meld-group {
    flex-direction: column;
}

/* 右方玩家：吃碰槓在手牌左側（靠中央） */
.player-area.right .melds-area {
    flex-direction: column;
    gap: 4px;
    order: 1;
}

.player-area.right .meld-group {
    flex-direction: column;
}

.player-area.left .meld-group .tile,
.player-area.right .meld-group .tile {
    width: calc(var(--tile-height) * 0.45);
    height: calc(var(--tile-width) * 0.45);
}

.player-area.left .meld-group .tile img,
.player-area.right .meld-group .tile img {
    width: calc(var(--tile-width) * 0.45);
    height: calc(var(--tile-height) * 0.45);
    margin-top: calc(var(--tile-height) * -0.225);
    margin-left: calc(var(--tile-width) * -0.225);
}

/* ===== 花牌展示 ===== */
.flowers-display {
    display: flex;
    gap: 2px;
    margin-top: 2px;
}

.flowers-display .tile {
    width: 22px;
    height: 30px;
}

/* ===== 操作按鈕 ===== */
.action-panel {
    position: absolute;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 30;
}

.action-btn {
    padding: 12px 28px;
    font-size: 1.2rem;
    font-weight: bold;
    border: 2px solid;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 3px;
    transition: all 0.2s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.action-btn:hover {
    transform: scale(1.05);
}

.action-btn.btn-hu {
    background: linear-gradient(135deg, #cc2222, #ff4444);
    border-color: #ff6666;
    color: #fff;
    animation: pulse-glow 1.5s infinite;
}

.action-btn.btn-pong {
    background: linear-gradient(135deg, #2266cc, #4488ff);
    border-color: #66aaff;
    color: #fff;
}

.action-btn.btn-chi {
    background: linear-gradient(135deg, #22aa44, #44cc66);
    border-color: #66ee88;
    color: #fff;
}

.action-btn.btn-kong {
    background: linear-gradient(135deg, #cc8800, #ffaa22);
    border-color: #ffcc44;
    color: #fff;
}

.action-btn.btn-skip {
    background: rgba(100,100,100,0.6);
    border-color: #888;
    color: #ccc;
}

.action-btn.btn-draw {
    background: linear-gradient(135deg, #7722cc, #9944ff);
    border-color: #bb66ff;
    color: #fff;
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255,255,255,0.3); }
    50% { box-shadow: 0 0 20px rgba(255,255,255,0.6); }
}

/* ===== 吃牌選擇面板 ===== */
.chi-select-panel {
    position: absolute;
    bottom: 240px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 16px;
    z-index: 35;
    display: none;
}

.chi-select-panel h3 {
    color: var(--gold);
    margin-bottom: 12px;
    text-align: center;
    font-size: 1rem;
}

.chi-options {
    display: flex;
    gap: 16px;
}

.chi-option {
    display: flex;
    gap: 2px;
    cursor: pointer;
    padding: 6px;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
}

.chi-option:hover {
    border-color: var(--gold);
    background: rgba(212,165,23,0.1);
}

.chi-option .tile {
    width: 36px;
    height: 50px;
}

/* ===== 遊戲訊息 ===== */
.game-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.92);
    border: 3px solid var(--gold);
    border-radius: 16px;
    padding: 24px 28px 20px;
    z-index: 50;
    text-align: center;
    display: none;
    min-width: 300px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

.game-message h2 {
    color: var(--gold);
    font-size: 2rem;
    margin-bottom: 12px;
}

.game-message .msg-details {
    color: #ccc;
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 20px;
}

.game-message .score-detail {
    color: #8f8;
    font-size: 0.9rem;
    text-align: left;
    margin: 10px 0;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.game-message button {
    padding: 12px 40px;
    font-size: 1.1rem;
    background: var(--gold);
    border: none;
    border-radius: 8px;
    color: #000;
    cursor: pointer;
    font-weight: bold;
    margin: 5px;
}

.game-message button:hover {
    background: var(--gold-light);
}

/* ===== 全員亮牌區（遊戲結束展示）===== */
.showdown-section {
    margin: 14px 0 10px;
    text-align: left;
}

.showdown-title {
    font-size: 1rem;
    color: var(--gold);
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 2px;
}

.showdown-player {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

.showdown-player.showdown-winner {
    background: rgba(212,165,23,0.18);
    border-color: var(--gold);
}

.showdown-name {
    font-size: 0.85rem;
    color: #ccc;
    font-weight: bold;
}

.showdown-player.showdown-winner .showdown-name {
    color: var(--gold-light);
}

.showdown-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
}

.showdown-tile-img {
    width: 30px;
    height: 42px;
    border-radius: 3px;
    background: #fff;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.5);
}

.showdown-meld {
    display: inline-flex;
    gap: 1px;
    margin-right: 2px;
    background: rgba(0,0,0,0.25);
    padding: 2px 3px;
    border-radius: 4px;
}

.showdown-sep {
    color: rgba(255,255,255,0.3);
    margin: 0 4px;
    font-size: 1.2rem;
    align-self: center;
}

.showdown-empty {
    color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
}

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

/* ===== 贏家光暈（玩家區） ===== */
.player-area.winner-glow .hand-tiles .tile img {
    box-shadow: 0 0 10px 3px rgba(212,165,23,0.8);
}

/* ===== 遊戲紀錄 ===== */
.game-log {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 180px;
    max-height: 300px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px;
    overflow-y: auto;
    z-index: 12;
    font-size: 0.7rem;
    color: #aaa;
    line-height: 1.6;
}

.game-log::-webkit-scrollbar {
    width: 4px;
}

.game-log::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.game-log .log-entry {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 3px 0;
}

/* ===== 狀態提示 ===== */
.status-bar {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 60px);
    z-index: 8;
    background: rgba(0,0,0,0.6);
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--gold);
    white-space: nowrap;
}

/* ===== 動畫 ===== */
.tile-appear {
    animation: tileAppear 0.3s ease-out;
}

@keyframes tileAppear {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.tile-discard-anim {
    animation: discardAnim 0.4s ease-out;
}

@keyframes discardAnim {
    from { opacity: 0; transform: translateY(-30px) scale(1.3); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 響應式 ===== */
@media (max-width: 900px) {
    :root {
        --tile-width: 32px;
        --tile-height: 44px;
    }

    .player-info { padding: 5px 8px; min-width: 80px; }
    .player-info .name { font-size: 0.75rem; }
    .player-info .wind { font-size: 1rem; }

    .action-btn { padding: 8px 16px; font-size: 0.95rem; }

    .center-area { width: 300px; height: 260px; }

    .game-log { width: 140px; font-size: 0.65rem; }

    #lobby h1 { font-size: 2rem; }
    .lobby-buttons { width: 260px; }

    .player-area.bottom { bottom: 4px; bottom: calc(4px + env(safe-area-inset-bottom, 0px)); gap: 2px; }
    .player-area.bottom .melds-area { gap: 4px; }
    .meld-group .tile { width: 24px; height: 32px; }
}

@media (max-width: 600px) {
    :root {
        --tile-width: 24px;
        --tile-height: 33px;
    }

    .action-btn { padding: 6px 12px; font-size: 0.8rem; letter-spacing: 1px; }
    .game-log { display: none; }
    .player-info { display: none; }
    .wind-indicator { width: 60px; height: 60px; }
    .wind-compass .current-wind { font-size: 1.2rem; }

    .player-area.bottom { bottom: 2px; bottom: calc(2px + env(safe-area-inset-bottom, 0px)); gap: 1px; }
    .player-area.bottom .melds-area { gap: 2px; }
    .meld-group .tile { width: 20px; height: 27px; }
    .flowers-display .tile { width: 18px; height: 24px; }
    .action-panel { bottom: 120px; }

    .draw-placeholder::after { font-size: 0.75rem; }
}

@media (max-height: 600px) {
    .player-area.bottom { bottom: 2px; gap: 1px; }
    .player-area.bottom .melds-area { gap: 2px; }
    .meld-group .tile { width: 20px; height: 27px; }
    .flowers-display { display: none; }
    .game-log { display: none; }
    .player-info { display: none; }
}

/* ===== 全螢幕按鈕 ===== */
#btn-fullscreen {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(212,165,23,0.5);
    background: rgba(0,0,0,0.5);
    color: var(--gold-light);
    font-size: 1.3rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s, background 0.3s;
    opacity: 0.6;
}

#btn-fullscreen:hover,
#btn-fullscreen:active {
    opacity: 1;
    background: rgba(26,107,60,0.8);
}

#btn-fullscreen.is-fullscreen {
    border-color: rgba(255,255,255,0.3);
}

/* 全螢幕按鈕預設隱藏，由 JS 控制顯示 */
#btn-fullscreen { display: none; }

/* ===== 全螢幕提示 overlay ===== */
#fullscreen-prompt {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.fs-prompt-box {
    text-align: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, #0d1b0e, #1a3a1f);
    border: 2px solid var(--gold);
    border-radius: 20px;
    max-width: 340px;
    box-shadow: 0 0 40px rgba(212,165,23,0.2);
}

.fs-prompt-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.fs-prompt-box p {
    font-size: 1.1rem;
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 24px;
}

.fs-prompt-box p strong {
    color: var(--gold-light);
}

.fs-prompt-box .lobby-btn {
    width: 100%;
    margin-bottom: 12px;
}

.fs-skip-btn {
    background: none;
    border: none;
    color: #777;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 16px;
    text-decoration: underline;
}

.fs-skip-btn:hover {
    color: #aaa;
}

/* iOS 加到主畫面教學 */
.a2hs-steps {
    text-align: left;
    margin: 16px 0;
}

.a2hs-step {
    color: #ccc;
    font-size: 0.95rem;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    line-height: 1.5;
}

.a2hs-step:last-child {
    border-bottom: none;
}

.a2hs-step strong {
    color: #fff;
}

.share-icon {
    display: inline-block;
    color: #4a9eff;
    font-size: 1.1rem;
}
