body {
  margin:0;
  padding:8px;
  font-family:Arial, sans-serif;
  background:#111;
  color:#fff;
}
h2 {
  text-align:center;
  margin:4px 0 8px;
  font-size: 1.2rem;
}
#top-info {
  text-align:center;
  font-size:12px;
  opacity:0.8;
  margin-bottom:8px;
}
#main {
  display:flex;
  justify-content:center;
  align-items:flex-start;
  gap:8px;
  width:100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing:border-box;
  flex-wrap: wrap;
}

.panel {
  box-sizing:border-box;
  padding:10px;
  background:#222;
  border-radius:8px;
}

#left-panel, #right-panel {
  width: 280px; 
}
#center-panel {
  width: 420px;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding: 5px;
}

@media (max-width: 900px) {
    #main {
        flex-direction: column;
        align-items: center;
    }
    #center-panel {
        width: 100%; 
        order: 1; 
        background: transparent;
        padding: 0;
    }
    #left-panel {
        width: 100%;
        order: 2;
        margin-top: 10px;
    }
    #right-panel {
        width: 100%;
        order: 3;
        margin-top: 10px;
    }
}

#game-wrapper {
  width: 400px;
  height: 500px;
  position: relative;
  max-width: 100%;
  overflow: hidden; 
  margin: 0 auto;
}

#game {
  position:absolute;
  top: 0;
  left: 0;
  width:400px;
  height:500px;
  background:#000;
  border:2px solid #555;
  border-radius:10px;
  overflow:hidden;
  transform-origin: top left;
}

.lane-bg { position:absolute; top:0; bottom:0; width:0; opacity:0.4; display:none; transition:left 0.4s ease, width 0.4s ease, background-color 0.4s ease; }
#centerCountdown { position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); font-size:60px; font-weight:bold; color:#fff; text-shadow:0 0 10px #000; pointer-events:none; z-index:8; }
#x2Text { position:absolute; top:50%; left:50%; transform:translate(-50%, -50%); font-size:36px; font-weight:bold; color:yellow; text-shadow:0 0 10px #000; display:none; pointer-events:none; z-index:9; }

#pongEffect { position:absolute; width:80px; height:80px; background-image:url("assets/pong.png"); background-size:contain; background-repeat:no-repeat; background-position:center; display:none; pointer-events:none; z-index:10; }

.car { position:absolute; width:40px; height:80px; background-size:contain; background-repeat:no-repeat; background-position:center; z-index:2; }
#player { background-image:url("assets/redcar.png"); bottom:10px; transform-origin:center bottom; transition:filter 0.2s ease, opacity 0.2s ease; }
.enemy { background-image:url("assets/greencar.png"); }
#player.invincible { filter:drop-shadow(0 0 12px yellow); opacity:0.8; }
.powerup { position:absolute; width:80px; height:80px; background-image:url("assets/x2.png"); background-size:contain; background-repeat:no-repeat; background-position:center; z-index:3; pointer-events:none; }

#hud { margin-bottom:8px; width:400px; font-size:14px; text-align:center;}
#message { margin-top:8px; text-align:center; min-height:20px; width:100%; max-width:400px;}

.rank-panel h3 { margin: 0 0 8px; text-align: center; border-bottom: 1px solid #444; padding-bottom: 5px; }

.rank-container {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px;
    transition: all 0.3s ease;
}

.active-rank-bg {
    border-color: #aaa;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
    background: #2a2a2a;
}

.rank-list { 
    list-style:none; 
    margin:0; 
    padding:0; 
    font-size:13px; 
}
.rank-list li { 
    padding:6px 4px;
    border-bottom:1px solid rgba(255,255,255,0.1); 
    display:flex; 
    justify-content:space-between; 
    gap:4px; 
}
.rank-list li span:nth-child(1){ width:25px; text-align:left; }
.rank-list li span:nth-child(2){ flex:1; text-align:center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-list li span:nth-child(3){ width:50px; text-align:right; color: #ffeb3b; }
.rank-list li span:nth-child(4){ width:75px; text-align:right; font-size:11px; color: #888; }

/* 玩家高亮樣式 */
.rank-list li.me { 
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid #ffeb3b; 
    border-radius: 4px;
    color: #fff;
    font-weight: bold; 
}
.rank-list li.me span:nth-child(3) {
    color: #ffff00; 
    text-shadow: 0 0 5px #ffeb3b;
}

#infoArea { 
    margin-top: 10px;
    min-height: 40px; 
    width: 100%;
    max-width: 400px;
    display:flex; 
    align-items:center; 
    justify-content:center; 
    text-align:center; 
}
#infoArea.big-message { font-size:32px; font-weight:bold; color:#ffeb3b; text-shadow:0 0 10px #000; }
#infoArea.blink { animation: blink 0.5s steps(1) infinite; }
@keyframes blink { 50% { opacity:0; } }

#mobile-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-top: 10px;
    gap: 10px;
}
.ctrl-btn {
    flex: 1;
    height: 60px;
    background: #444;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    user-select: none; 
    -webkit-user-select: none;
    touch-action: manipulation;
}
.ctrl-btn:active {
    background: #666;
    transform: translateY(2px);
}
.start-btn {
    background: #2196F3;
    flex: 2; 
    font-size: 18px;
}
.start-btn:active { background: #1976D2; }

/* 透明觸控區樣式 */
.touch-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 100;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#touch-left { left: 0; }
#touch-right { right: 0; }

/* 登入彈窗樣式 */
.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-box {
  background: #333;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  width: 85%;
  max-width: 320px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  border: 1px solid #555;
}
.modal-box h3 { margin-top: 0; color: #ffeb3b; }
.modal-box p { font-size: 14px; color: #ccc; margin-bottom: 10px; }
.modal-box input[type="text"] {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  margin-bottom: 15px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #222;
  color: #fff;
  font-size: 16px;
  text-align: center;
}

/* ★★★ 新增：彈窗內的按鈕群組 ★★★ */
.modal-btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.big-start-btn {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 15px 5px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}
.big-start-btn:active { transform: scale(0.96); }

.big-start-btn.normal {
    background: linear-gradient(to bottom, #2196F3, #1976D2);
    border: 1px solid #2196F3;
}
.big-start-btn.pro {
    background: linear-gradient(to bottom, #FFD700, #FFA000);
    border: 1px solid #FFD700;
    color: #000; /* Pro版文字用黑色比較清楚 */
}

/* 模式按鈕樣式 (側邊欄) */
.full-width-btn {
  width: 100%;
  margin-bottom: 10px;
  border-radius: 4px;
}
.mode-btn {
  background: #444;
  color: #aaa;
  border: 1px solid #555;
  padding: 10px 0;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.mode-btn:hover { background: #555; color: #fff; }

.mode-btn.active[data-mode="normal"] {
  background: #2196F3;
  color: #fff;
  border-color: #2196F3;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
}

.mode-btn.active[data-mode="pro"] {
  background: #FFD700;
  color: #000;
  border-color: #FFD700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}