* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  font-family: "PingFang TC", "Microsoft JhengHei", -apple-system, sans-serif;
  background: linear-gradient(160deg, #1d2b3a 0%, #14202c 100%);
  color: #f3f7fb;
  -webkit-tap-highlight-color: transparent;
}
#app {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.screen {
  width: 100%; max-width: 640px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.hidden { display: none !important; }

.title { font-size: 56px; text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.subtitle { color: #9fb3c8; font-size: 15px; }
.title-sm { font-size: 30px; margin-bottom: 4px; }
.foot { color: #6b8096; font-size: 13px; margin-top: 8px; }

.menu-btns { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }

.btn {
  font-family: inherit; font-size: 16px; font-weight: 700;
  color: #fff; background: #3a4a5c; border: none; border-radius: 14px;
  padding: 12px 18px; cursor: pointer; transition: transform .08s, filter .15s;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn.big { font-size: 20px; padding: 16px; }
.btn.small { font-size: 14px; padding: 8px 14px; }
.btn.primary { background: linear-gradient(180deg, #ff8a3d, #f5701c); }
.btn.ghost { background: #2a3744; color: #c7d6e3; }
.btn:hover { filter: brightness(1.08); }

.setting { width: 100%; max-width: 420px; background: #22303d; border-radius: 14px; padding: 14px 16px; }
.setting .label { font-weight: 700; margin-bottom: 10px; color: #cfe0ee; }
.opts { display: flex; flex-wrap: wrap; gap: 10px; }
.opts label {
  display: inline-flex; align-items: center; gap: 6px;
  background: #2e3e4d; padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 15px;
}
.opts input { accent-color: #ff8a3d; transform: scale(1.2); }

.help { background: #22303d; border-radius: 14px; padding: 18px 20px; max-width: 480px; line-height: 1.7; font-size: 15px; }
.help p { margin-bottom: 10px; }
.help b { color: #ffb37d; }

#hud {
  display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center;
  font-size: 13px; max-width: 640px;
}
#hud .lvl { font-weight: 800; color: #ffd27d; font-size: 15px; width: 100%; text-align: center; }
#hud .pstat { background: #22303d; padding: 4px 10px; border-radius: 9px; }
#hud .pstat b { color: #ffce8a; font-weight: 700; margin-left: 2px; }
#hud .pstat.dead { opacity: .35; text-decoration: line-through; }

#game {
  background: #16222e; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  max-width: 100%; height: auto; touch-action: none;
}

/* 線上對戰 */
.text-input {
  width: 100%; font-family: inherit; font-size: 16px;
  color: #fff; background: #1b2733; border: 2px solid #38495a; border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.text-input:focus { border-color: #ff8a3d; }
.text-input.code { letter-spacing: 6px; text-align: center; font-size: 22px; font-weight: 800; }
.join-row { display: flex; gap: 10px; align-items: stretch; }
.join-row .text-input { flex: 1; }
.err-msg { color: #ff6b6b; font-size: 14px; min-height: 18px; text-align: center; }
.room-code { font-size: 18px; color: #cfe0ee; }
.room-code b { font-size: 40px; color: #ffd27d; letter-spacing: 8px; display: block; margin-top: 4px; }
.lobby-players { display: flex; flex-direction: column; gap: 8px; }
.lobby-players .lp {
  background: #2e3e4d; border-radius: 10px; padding: 8px 12px; font-size: 16px;
  display: flex; align-items: center; gap: 8px;
}
.lobby-players .lp.host b { color: #ffd27d; }

/* 手機觸控 */
.touch {
  width: 100%; max-width: 480px; margin-top: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  user-select: none; -webkit-user-select: none;
}
/* 虛擬搖桿 */
.joystick {
  position: relative; width: 168px; height: 168px; flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #2c3e4e 0%, #202e3a 72%);
  box-shadow: inset 0 5px 16px rgba(0,0,0,.5), 0 2px 0 rgba(255,255,255,.04);
  touch-action: none; cursor: grab;
}
.stick {
  position: absolute; top: 50%; left: 50%;
  width: 72px; height: 72px; margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #6e8aa6, #41607a 70%, #38505f);
  box-shadow: 0 5px 12px rgba(0,0,0,.45), inset 0 2px 4px rgba(255,255,255,.25);
  transition: transform .06s ease-out;
  pointer-events: none;
}
.tbtn {
  font-family: inherit; color: #fff; background: #33475a; border: none;
  border-radius: 14px; font-size: 26px; font-weight: 800;
  box-shadow: 0 4px 0 rgba(0,0,0,.3); touch-action: none; cursor: pointer;
}
.tbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.3); background: #41607a; }
.tbtn.bomb {
  width: 96px; height: 96px; border-radius: 50%; font-size: 44px;
  background: linear-gradient(180deg, #ff8a3d, #f5701c); flex-shrink: 0;
}

.overlay {
  position: fixed; inset: 0; background: rgba(8,14,20,.78);
  align-items: center; justify-content: center; z-index: 10;
}
.over-card {
  background: #1f2d3a; border-radius: 20px; padding: 30px 28px;
  display: flex; flex-direction: column; gap: 18px; align-items: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.over-text { font-size: 26px; font-weight: 800; text-align: center; }
