/**
 * 掼蛋样式文件
 * 支持江淮/简约双主题
 * 稳屏优先响应式设计
 */

:root {
    --jianghuai-bg: linear-gradient(135deg, #1a4d2e 0%, #0d3311 50%, #0a1f0a 100%);
    --jianghuai-table: #1a5c3a;
    --jianghuai-card-bg: #fffef5;
    --jianghuai-text: #f5f0e6;
    --jianghuai-accent: #c9a227;
    --jianghuai-jipai: #ffd700;
    
    --simple-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 50%, #1a252f 100%);
    --simple-table: #2c3e50;
    --simple-card-bg: #ffffff;
    --simple-text: #2c3e50;
    --simple-accent: #3498db;
    --simple-jipai: #f39c12;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    transition: background var(--transition-normal);
}

body[data-theme="jianghuai"] {
    background: var(--jianghuai-bg);
    color: var(--jianghuai-text);
}

body[data-theme="simple"] {
    background: var(--simple-bg);
    color: var(--simple-text);
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.game-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.game-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    height: 44px;
    z-index: 10;
}

body[data-theme="jianghuai"] .game-header {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(201, 162, 39, 0.3);
}

body[data-theme="simple"] .game-header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(52, 152, 219, 0.3);
}

.header-left, .header-right {
    width: 50px;
}

.header-center {
    flex: 1;
    text-align: center;
}

.game-title {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
}

.jipai-display {
    font-size: 12px;
    opacity: 0.8;
}

body[data-theme="jianghuai"] .jipai-display {
    color: var(--jianghuai-jipai);
}

body[data-theme="simple"] .jipai-display {
    color: var(--simple-jipai);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

.icon-btn:not(.active) {
    opacity: 0.5;
}

.game-controls {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 10;
}

body[data-theme="jianghuai"] .game-controls {
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(201, 162, 39, 0.3);
}

body[data-theme="simple"] .game-controls {
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(52, 152, 219, 0.3);
}

.ctrl-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

body[data-theme="jianghuai"] .ctrl-btn {
    background: linear-gradient(to bottom, #8B4513, #5D3A1A);
    color: #ffd700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

body[data-theme="simple"] .ctrl-btn {
    background: #3498db;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

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

.ctrl-btn.primary {
    padding: 12px 28px;
}

body[data-theme="jianghuai"] .ctrl-btn.primary {
    background: linear-gradient(to bottom, #c9a227, #a8841f);
}

body[data-theme="simple"] .ctrl-btn.primary {
    background: #e74c3c;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    padding: 24px;
    border-radius: 16px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

body[data-theme="jianghuai"] .modal-content {
    background: linear-gradient(to bottom, #f5f0e6, #e8dcc8);
    border: 3px solid #8b6914;
    color: #4a3728;
}

body[data-theme="simple"] .modal-content {
    background: white;
    border: 2px solid #3498db;
}

.start-modal h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.friend-actions { display: grid; gap: 12px; margin: 22px 0 12px; }
.home-nickname { width: 100%; padding: 12px 14px; border: 1px solid rgba(88, 69, 42, .25); border-radius: 10px; background: rgba(255,255,255,.78); color: #33271d; font: inherit; text-align: center; }
.join-room-row { display: flex; gap: 8px; }
.join-room-row input, .nickname-row input {
    min-width: 0;
    flex: 1;
    padding: 12px 14px;
    border: 1px solid rgba(88, 69, 42, .25);
    border-radius: 10px;
    background: rgba(255, 255, 255, .78);
    color: #33271d;
    font: inherit;
    outline-color: #a77a20;
    user-select: text;
}
.join-room-row input { text-align: center; letter-spacing: 2px; text-transform: uppercase; }
.practice-btn { border: 0; background: none; color: inherit; opacity: .7; text-decoration: underline; font: inherit; cursor: pointer; }
.game-header.in-room .game-title { font-size: 16px; letter-spacing: .5px; }
.room-modal { position: relative; max-width: 560px; max-height: min(92vh, 760px); overflow-y: auto; text-align: left; }
.room-modal h2 { margin: 2px 0 14px; text-align: center; color: #684515; }
.room-close { position: absolute; right: 12px; top: 8px; border: 0; background: transparent; font-size: 28px; cursor: pointer; color: inherit; }
.eyebrow { text-align: center; text-transform: uppercase; letter-spacing: 2px; font-size: 11px; opacity: .68; }
.room-invite { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 12px; background: rgba(139, 105, 20, .1); border-radius: 12px; }
.room-invite strong { font: 700 23px ui-monospace, monospace; letter-spacing: 3px; }
.room-invite .ctrl-btn { padding: 8px 14px; font-size: 13px; }
.nickname-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.nickname-row label { white-space: nowrap; font-size: 13px; }
.nickname-row .ctrl-btn { padding: 9px 14px; }
.room-seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.room-seat { min-width: 0; padding: 12px; display: grid; gap: 4px; border: 1px dashed rgba(91, 73, 49, .34); border-radius: 10px; background: rgba(255,255,255,.36); }
.room-seat.occupied { border-style: solid; background: rgba(255,255,255,.72); }
.room-seat.is-host { box-shadow: inset 0 0 0 1px rgba(185, 138, 39, .4); }
.room-seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-seat small, .seat-position { font-size: 11px; opacity: .68; }
.room-status { min-height: 22px; margin: 14px 0 8px; text-align: center; font-size: 14px; }
.room-actions { display: flex; justify-content: center; gap: 10px; }
.room-actions button { flex: 1; }
.room-actions .start-btn { padding: 11px 16px; border: 0; border-radius: 22px; font-family: inherit; font-size: 14px; font-weight: bold; cursor: pointer; background: linear-gradient(#a85b22, #714016); color: #ffe08a; }
.room-actions button:disabled { opacity: .45; cursor: not-allowed; }
.room-footnote { margin-top: 12px; text-align: center; font-size: 11px; opacity: .65; }
.result-player-row { display: flex; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid rgba(75, 58, 39, .12); }
.mp-controls .primary { min-width: 100px; }
.modal-content input { user-select: text; -webkit-user-select: text; }

@media (max-width: 480px) {
    .room-modal { padding: 20px 15px; width: 94%; }
    .room-invite { gap: 7px; }
    .nickname-row { flex-wrap: wrap; }
    .nickname-row label { width: 100%; text-align: left; }
    .room-seat { padding: 10px 8px; }
    .room-actions { flex-direction: column; }
}

body[data-theme="jianghuai"] .start-modal h2 {
    color: #8b4513;
}

.subtitle {
    opacity: 0.7;
    margin-bottom: 20px;
    font-size: 14px;
}

.stats-preview {
    margin-bottom: 24px;
    padding: 12px;
    border-radius: 8px;
}

body[data-theme="jianghuai"] .stats-preview {
    background: rgba(255, 255, 255, 0.2);
}

body[data-theme="simple"] .stats-preview {
    background: #f5f5f5;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.start-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 25px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
}

body[data-theme="jianghuai"] .start-btn {
    background: linear-gradient(to bottom, #c9a227, #a8841f);
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

body[data-theme="simple"] .start-btn {
    background: #e74c3c;
    color: white;
}

.start-btn:hover {
    transform: scale(1.02);
}

.settings-modal {
    text-align: left;
}

.settings-modal h3 {
    text-align: center;
    margin-bottom: 16px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.setting-item label {
    font-weight: 500;
}

.setting-item select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 14px;
    min-width: 100px;
}

.close-settings-btn {
    width: 100%;
    margin-top: 8px;
}

.result-modal {
    padding: 30px;
}

.result-modal h2 {
    font-size: 24px;
    margin-bottom: 16px;
}

.result-info {
    line-height: 1.8;
    margin-bottom: 24px;
    opacity: 0.8;
}

.modal-btns {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 15px;
    z-index: 200;
    animation: toastIn 0.3s ease;
    pointer-events: none;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

body[data-theme="jianghuai"] .toast {
    background: rgba(139, 69, 19, 0.95);
    color: #ffd700;
}

body[data-theme="simple"] .toast {
    background: rgba(44, 62, 80, 0.95);
    color: white;
}

.toast.hidden {
    display: none;
}

.bomb-effect {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px;
    z-index: 150;
    animation: bombAnim 1s ease-out forwards;
    pointer-events: none;
}

@keyframes bombAnim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
}

@media screen and (max-width: 360px) {
    .ctrl-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .game-title {
        font-size: 18px;
    }
}

@media screen and (min-width: 768px) {
    .modal-content {
        max-width: 400px;
    }
    
    .ctrl-btn {
        padding: 12px 24px;
    }
}

@supports (padding: env(safe-area-inset-top)) {
    .game-header {
        padding-top: max(8px, env(safe-area-inset-top));
    }
}
