* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #0a0a0a;
  color: #d8d8d8;
  font-family: "Courier New", ui-monospace, monospace;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.screen {
  line-height: 0;
  border: 2px solid #2a2a2a;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(232, 197, 71, 0.08), 0 8px 32px rgba(0, 0, 0, 0.6);
  background: #000;
  overflow: hidden;
}

canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  max-width: 100%;
  height: auto;
}

.help {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: center;
  font-size: 12px;
  color: #7a7a7a;
  letter-spacing: 0.3px;
}

.help b {
  color: #e8c547;
  font-weight: 700;
}

/* 静音按钮：放在画布下方参与正常布局，
   固定在右上角会压住画布里的 ENEMY 计数，所以不用 fixed。 */
.mute {
  flex: none;
  padding: 5px 14px;
  font-size: 12px;
  font-family: inherit;
  letter-spacing: 0.5px;
  color: #b8b8b8;
  background: #141414;
  border: 1px solid #2e2e2e;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.mute:hover {
  background: #1e1e1e;
  border-color: #e8c547;
  color: #e8c547;
}

.mute:active { transform: scale(0.97); }

.mute.off {
  color: #6a6a6a;
  border-color: #262626;
}

/* 触屏控制区：桌面默认隐藏 */
.pad {
  display: none;
  width: 100%;
  max-width: 420px;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  user-select: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
}

.key {
  border: 1px solid #333;
  background: #161616;
  color: #b8b8b8;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  touch-action: none;
  cursor: pointer;
  transition: background 0.06s, color 0.06s;
}

.key:active,
.key.on {
  background: #e8c547;
  color: #111;
  border-color: #e8c547;
}

.dpad .up    { grid-area: 1 / 2; }
.dpad .left  { grid-area: 2 / 1; }
.dpad .down  { grid-area: 2 / 2; }
.dpad .right { grid-area: 2 / 3; }

.key.fire {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  font-size: 13px;
  letter-spacing: 1px;
  border-color: #8a6a1a;
  color: #e8c547;
}

/* 技能（K）/ 道具（F）：和 FIRE 并排的小圆钮，颜色区分 */
.key.skill,
.key.spit {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 12px;
  letter-spacing: 0;
  padding: 0;
}

.key.skill {
  border-color: #2f6f8f;
  color: #7fc8f0;
}

.key.spit {
  border-color: #2f8f2f;
  color: #8ce88c;
}

/* 触屏设备才显示方向盘 */
@media (hover: none) and (pointer: coarse) {
  .pad { display: flex; }
  .help { display: none; }
}

@media (max-width: 640px) {
  .wrap { padding: 8px; gap: 8px; }
}

/* ---------------- 联机大厅 ---------------- */

.hidden { display: none !important; }

.lobby {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 6, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  z-index: 10;
}

.panel {
  width: 100%;
  max-width: 380px;
  background: #121212;
  border: 1px solid #262626;
  border-radius: 12px;
  padding: 24px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.panel h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 2px;
  color: #e8c547;
  text-align: center;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #e8c547;
  text-align: center;
  font-weight: 700;
}

.panel .sub {
  margin: 6px 0 20px;
  text-align: center;
  font-size: 12px;
  color: #7a7a7a;
}

.panel .code {
  color: #fff;
  letter-spacing: 3px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 11px;
  color: #8a8a8a;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.panel input[type="text"] {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  color: #e8e8e8;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.panel input[type="text"]:focus {
  border-color: #e8c547;
}

#code-input {
  text-align: center;
  letter-spacing: 8px;
  font-size: 20px;
  text-transform: uppercase;
}

button.big {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 1px;
  color: #d8d8d8;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

button.big:hover:not(:disabled) {
  background: #262626;
  border-color: #4a4a4a;
}

button.big.primary {
  color: #111;
  background: #e8c547;
  border-color: #e8c547;
}

button.big.primary:hover:not(:disabled) {
  background: #f0d066;
}

button.big:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.link {
  width: 100%;
  margin-top: 14px;
  padding: 8px;
  background: none;
  border: none;
  color: #7a7a7a;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

button.link:hover { color: #e8c547; }

/* 模式选择：两张卡片，标题 + 一句话说明 */
button.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 10px;
  letter-spacing: 0;
}

button.mode-btn .mtitle {
  font-size: 15px;
  letter-spacing: 1px;
}

button.mode-btn .mdesc {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.72;
}

button.mode-btn.dm {
  color: #ffd9d9;
  background: #241417;
  border-color: #4a2a2e;
}

button.mode-btn.dm:hover:not(:disabled) {
  background: #2e1a1e;
  border-color: #6d3a40;
}

/* 选坦克：2x2 的卡片，选中项用该坦克的颜色描边 */
.picker {
  margin: 4px 0 14px;
}

.picker-title {
  font-size: 11px;
  color: #8a8a8a;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.picker-hint {
  color: #5a5a5a;
  letter-spacing: 0;
}

.tank-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tank-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  text-align: left;
  letter-spacing: 0;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

/* 头像：圆形裁切，边框色跟着坦克配色走 */
.tank-card .tface {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
}

.tank-card .tface img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid #2a2a2a;
  box-sizing: border-box;
}

.tank-card .tinfo {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tank-card:hover {
  background: #1b1b1b;
}

.tank-card.on {
  background: #1d1d16;
}

.tank-card .tname {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
}

.tank-card .tskill {
  font-size: 10px;
  color: #b8b8b8;
}

.tank-card .tdesc {
  font-size: 10px;
  color: #6f6f6f;
  line-height: 1.35;
}

.or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: #444;
  font-size: 11px;
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #242424;
}

.share {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.share input {
  flex: 1;
  font-size: 11px !important;
  padding: 10px !important;
}

.share button {
  padding: 0 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #111;
  background: #e8c547;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.players {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: 8px;
  font-size: 13px;
}

.prow.empty {
  color: #4a4a4a;
  border-style: dashed;
}

.prow.me {
  border-color: #e8c547;
}

.prow .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.prow .pname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prow .tag {
  font-size: 10px;
  color: #e8c547;
  border: 1px solid #6a5a1a;
  border-radius: 4px;
  padding: 1px 5px;
}

.hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11px;
  color: #5a5a5a;
}

.err {
  margin-top: 14px;
  padding: 10px;
  font-size: 12px;
  text-align: center;
  color: #ff9a9a;
  background: rgba(255, 80, 80, 0.08);
  border: 1px solid rgba(255, 80, 80, 0.25);
  border-radius: 8px;
}
