/* --- 基础与重置 --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root { --bg:#0d0d12; --cvs:#16161d; --p1:#ff4757; --p2:#3e93ff; --p3:#f1c40f; --p4:#1abc9c; --pt:#9b59b6; --ac:#2ed573; }
body { display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: system-ui, -apple-system, sans-serif; user-select: none; padding: 2vh 0; background: var(--bg); color: #eee; margin: 0; min-height: 100vh;}

#mainMenu, #recordPanel { background: #1a1a24; padding: 25px 5vw; border-radius: 16px; box-shadow: 0 15px 50px rgba(0,0,0,0.9); width: 92vw; max-width: 420px; max-height: 95vh; overflow-y: auto; }
h1 { font-size: 28px; margin: 0 0 20px 0; text-align: center; }
.section-title { font-size: 14px; color: #aaa; margin-bottom: 10px; font-weight: bold; display: block; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.toggle-btn { flex: 1; min-width: calc(25% - 8px); padding: 14px 6px; background: #262633; border: 2px solid #333; color: #aaa; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; text-align: center; }
.toggle-btn.selected { background: rgba(46,213,115,0.1); border-color: var(--ac); color: var(--ac); }
#startBtn { width: 100%; padding: 18px; background: var(--ac); color: #000; font-size: 20px; font-weight: 900; border-radius: 10px; border: none; cursor: pointer; transition: 0.2s; margin-top: 5px; letter-spacing: 2px;}
#startBtn:hover { background: #26b361; transform: translateY(-2px); }

#connectionPanel { display: none; margin-top: 10px; padding: 15px; background: rgba(0,0,0,0.3); border-radius: 8px; border: 1px dashed #555; }
input { width: 100%; padding: 16px; margin-top: 8px; border-radius: 8px; border: 1px solid #555; background: #111; color: #fff; text-align: center; font-size: 18px; outline: none; }
input:focus { border-color: var(--ac); }

#roomList { margin-top: 15px; background: #1a1a24; border-radius: 8px; border: 1px solid #333; padding: 10px; max-height: 120px; overflow-y: auto; }
.room-item { background: #262633; color: var(--ac); padding: 10px; border-radius: 6px; margin-bottom: 6px; font-size: 14px; font-weight: bold; cursor: pointer; text-align: center; border: 1px solid #444; }
.room-item:hover { background: #333; }

#gameContainer { display: none; flex-direction: column; align-items: center; width: 96vw; max-width: 600px; }
.header { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding: 0 2vw; }
#status { font-size: 24px; font-weight: bold; flex-grow: 1; }
.p1-text { color: var(--p1); } .p2-text { color: var(--p2); } .p3-text { color: var(--p3); } .p4-text { color: var(--p4); } .portal-text { color: var(--pt); }
.header-btns { display: flex; gap: 8px; }
.header-btns button { background: #2f3542; color: #fff; border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-weight: bold; transition: 0.2s; font-size: 15px; }
.header-btns button:hover { background: #57606f; }
#backMenuBtn { background: #e74c3c !important; }

.canvas-wrapper { position: relative; width: 100%; display: flex; justify-content: center; }
canvas { width: 100%; height: auto; aspect-ratio: 1 / 1; background: var(--cvs); border: 3px solid #333; border-radius: 10px; cursor: crosshair; box-shadow: 0 10px 40px rgba(0,0,0,0.8); touch-action: none; }

#statsOverlay { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); border-radius: 10px; flex-direction: column; justify-content: center; align-items: center; z-index: 10;}
.stat-box { background: rgba(26,26,36,0.95); border: 1px solid #555; padding: 25px; border-radius: 12px; width: 88%; max-width: 380px; box-shadow: 0 15px 40px rgba(0,0,0,0.9); backdrop-filter: blur(8px);}
.stats-btns { display: flex; gap: 10px; margin-top: 25px; width: 100%; }
.stats-btns button { flex: 1; padding: 16px; border: none; border-radius: 8px; font-weight: bold; font-size: 16px; cursor: pointer; color: #fff; background: #444; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
#btnEnterReplay { background: #9b59b6 !important; }

#replayControls { display: none; width: 100%; justify-content: center; align-items: center; gap: 8px; margin-top: 15px; background: rgba(0,0,0,0.5); padding: 15px 10px; border-radius: 10px; border: 1px solid #333; flex-wrap: wrap; }
#replayControls button { padding: 12px 16px; font-size: 15px; background: #2f3542; border: none; border-radius: 8px; color: #fff; cursor: pointer; font-weight: bold; }
#btnReplayPlay { background: #2ecc71 !important; color: #000 !important; width: 90px; }
#btnExitReplay { background: #e74c3c !important; }
#replayStep { font-family: monospace; font-size: 18px; color: var(--ac); width: 80px; text-align: center; }
#replaySpeedSelect { background: #222; color: var(--ac); border: 1px solid #444; border-radius: 8px; padding: 12px; font-weight: bold; font-size: 15px; outline: none; }
#gameHint { color: #888; font-size: 14px; margin-top: 15px; text-align: center; line-height: 1.5; padding: 0 10px; }

details > summary { list-style: none; cursor: pointer; color: #aaa; font-size: 15px; font-weight: bold; text-align: center; padding: 14px; background: #2a2a35; border-radius: 8px; margin-bottom: 5px; transition: 0.2s;}
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { background: #1a1a24; color: var(--ac); border: 1px solid #333; }

.record-overview { display: flex; justify-content: space-around; background: #22222d; padding: 15px; border-radius: 12px; margin-bottom: 20px; border: 1px solid #333; text-align: center; font-weight: bold; }
#matchHistoryList { display: flex; flex-direction: column; gap: 10px; max-height: 40vh; overflow-y: auto; padding-right: 5px; }
#matchHistoryList::-webkit-scrollbar { width: 6px; }
#matchHistoryList::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
.match-item { background: #262633; padding: 12px; border-radius: 8px; border-left: 5px solid #555; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #ccc; }
.match-item.win { border-left-color: var(--ac); }
.match-item.loss { border-left-color: var(--p1); }
.match-header { display: flex; justify-content: space-between; align-items: center; font-weight: bold; }
.match-res { font-size: 16px; }
.match-res.win { color: var(--ac); }
.match-res.loss { color: var(--p1); }
.match-params { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.param-tag { background: #1a1a24; padding: 3px 6px; border-radius: 4px; border: 1px solid #333; }

#tutorialPanel { display: none; background: #1a1a24; padding: 25px 5vw; border-radius: 16px; box-shadow: 0 15px 50px rgba(0,0,0,0.9); width: 92vw; max-width: 420px; max-height: 95vh; overflow-y: auto; }
#tutorialPanel h2 { font-size: 22px; margin: 0 0 15px 0; text-align: center; color: #fff; }
.tutorial-content { font-size: 14px; color: #ccc; line-height: 1.6; }
.tut-intro { background: #22222d; padding: 14px; border-radius: 8px; border-left: 4px solid var(--ac); margin-bottom: 15px; font-size: 13px;}
.tutorial-content h3 { font-size: 16px; color: var(--p2); margin: 18px 0 8px 0; border-bottom: 1px dashed #444; padding-bottom: 5px;}
.tutorial-content ul { margin: 0; padding-left: 20px; }
.tutorial-content li { margin-bottom: 8px; }
.tutorial-content b { color: #eee; }

/* --- 联机大厅与列表结算 UI --- */
.lobby-item { display: flex; justify-content: space-between; padding: 12px; background: #262633; border-radius: 6px; font-weight: bold; border: 1px solid #444; }
.player-stat-card { display: flex; justify-content: space-between; align-items: center; background: #262633; padding: 15px; border-radius: 8px; margin-bottom: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }