:root {
  --accent: #ffcc33;
  --accent2: #ff6699;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14111f;
  font-family: "Baloo 2", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; /* iOS 长按不弹菜单 */
  touch-action: none;
  overscroll-behavior: none;   /* 禁止橡皮筋回弹 */
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* 竖屏提示:触屏设备 + 竖屏才显示(纯 CSS,零 JS 依赖) */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(10, 8, 20, 0.96);
  color: #ffe9a8;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  line-height: 1.8;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#rotate-hint .rotate-icon { font-size: 52px; animation: rotateNudge 1.6s ease-in-out infinite; }
@keyframes rotateNudge {
  0%, 60%, 100% { transform: rotate(0); }
  30% { transform: rotate(-90deg); }
}
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint { display: flex; }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 居中但溢出安全:首尾 auto 边距,内容超高时自动贴顶、可滚动(justify-center 会裁掉顶部) */
  justify-content: flex-start;
  gap: 10px;
  /* 三层:顶部紫罗兰环境光 + 极淡扫描纹 + 纵向夜色渐变 */
  background:
    radial-gradient(circle at 50% 26%, rgba(96, 66, 142, 0.50), rgba(10, 8, 20, 0) 58%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, #231a3a, #130e22 68%, #0c0918);
  z-index: 10;
  text-align: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 24px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

/* 缓慢上浮的气泡层(纯装饰,穿透点击) */
.overlay::before {
  content: "";
  position: absolute;
  inset: -12% 0;
  pointer-events: none;
  background:
    radial-gradient(circle 22px at 12% 82%, rgba(255,255,255,0.045) 62%, transparent 63%),
    radial-gradient(circle 13px at 26% 34%, rgba(255,255,255,0.035) 62%, transparent 63%),
    radial-gradient(circle 30px at 78% 70%, rgba(255,255,255,0.04) 62%, transparent 63%),
    radial-gradient(circle 10px at 88% 26%, rgba(255,255,255,0.05) 62%, transparent 63%),
    radial-gradient(circle 17px at 55% 88%, rgba(255,255,255,0.035) 62%, transparent 63%);
  animation: bubbleRise 22s ease-in-out infinite alternate;
}
@keyframes bubbleRise {
  from { transform: translateY(3.5%); }
  to   { transform: translateY(-3.5%); }
}

/* 打开任意界面时,内容自下淡入(逐项错峰) */
.overlay > * { animation: fadeUp 0.45s ease both; position: relative; flex-shrink: 0; }
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
.overlay > *:nth-child(2) { animation-delay: 0.06s; }
.overlay > *:nth-child(3) { animation-delay: 0.12s; }
.overlay > *:nth-child(4) { animation-delay: 0.18s; }
.overlay > *:nth-child(5) { animation-delay: 0.24s; }
.overlay > *:nth-child(6) { animation-delay: 0.30s; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.overlay.hidden { display: none; }

/* 半透明浮层(暂停菜单/联机离开确认):底下画面仍可见,联机时对局照常进行 */
.overlay.dim {
  background: rgba(12, 9, 24, 0.62);
}

.logo {
  font-size: clamp(40px, 9vw, 96px);
  color: #ffd76a;
  letter-spacing: 4px;
  /* 像素游戏式八向描边 + 双层落影 */
  text-shadow:
    3px 0 0 #5a3808, -3px 0 0 #5a3808, 0 3px 0 #5a3808, 0 -3px 0 #5a3808,
    3px 3px 0 #5a3808, -3px 3px 0 #5a3808, 3px -3px 0 #5a3808, -3px -3px 0 #5a3808,
    0 8px 0 #8a5a10, 0 14px 30px rgba(0, 0, 0, 0.65);
}

.subtitle {
  font-size: clamp(15px, 2.6vw, 24px);
  color: var(--accent2);
  letter-spacing: 8px;
  margin-bottom: 10px;
}

/* 矮窗口(游戏常见 16:10 内嵌)整体收紧,保证主菜单一屏放下 */
@media (max-height: 860px) {
  .logo { font-size: clamp(34px, 7.2vh, 72px); }
  .subtitle { margin-bottom: 4px; }
  .hint { margin-top: 6px; }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(340px, 80vw);
}

/* 主菜单模式按钮:双列网格分组(主行动 wide 独占整行) */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(410px, 88vw);
}
.menu-grid .wide { grid-column: 1 / -1; }
/* 德语/俄语词长,双列小按钮收紧字号防换行(<html lang> 随语言切换) */
:lang(de) .menu-grid button:not(.wide),
:lang(ru) .menu-grid button:not(.wide) {
  font-size: clamp(13px, 2.2vw, 16px);
}
.menu-grid button {
  font-size: clamp(15px, 2.6vw, 19px);
  padding: 10px 10px;
}
.menu-grid .primary {
  font-size: clamp(18px, 3.4vw, 24px);
  padding: 13px 12px;
  color: #032535;
  background: linear-gradient(180deg, #9ceeff 0%, #45bdf5 52%, #1f92d8 100%);
  border-color: #093f5e;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.6),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 5px 0 #10608f;
}
.menu-grid .primary:active {
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 0 0 #10608f;
}

/* 人机难度选择 */
.difficulty-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.difficulty-picker .diff-label {
  font-size: 13px;
  color: #cfc6e6;
  margin-right: 2px;
}
.diff-btn {
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.05));
  border: 2px solid rgba(255, 255, 255, 0.22);
  color: #e8e2f5;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.10), 0 3px 0 rgba(0,0,0,0.35);
}
.diff-btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.10), 0 0 0 rgba(0,0,0,0.35); }
.diff-btn.active {
  background: linear-gradient(180deg, #ffe08a, var(--accent));
  color: #2a2036;
  border-color: var(--accent);
  font-weight: 700;
}

/* 角色选择器 */
.char-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.char-arrow {
  width: 46px;
  height: 46px;
  border-radius: 5px;
  font-size: 18px;
  padding: 0;
}

.char-info {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  padding: 8px 16px;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(74, 58, 116, 0.72), rgba(32, 24, 58, 0.78));
  border: 3px solid #2a2040;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14), inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 4px 0 rgba(0, 0, 0, 0.4);
  text-align: left;
}
/* 四角护角:两条 L 形金边(卷轴/铭牌的通用语汇)。用两个伪元素各画两角 */
.char-info::before, .char-info::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  border: 2px solid rgba(255, 215, 106, 0.55);
  pointer-events: none;
}
.char-info::before { top: 3px; left: 3px; border-right: none; border-bottom: none; }
.char-info::after { bottom: 3px; right: 3px; border-left: none; border-top: none; }

#char-preview {
  width: 68px;
  height: 68px;
  image-rendering: pixelated;
  flex-shrink: 0;
  /* 展示台:暖金底光 + 硬边内嵌框(和场内的"内嵌石板"同一个语汇)*/
  background:
    radial-gradient(circle at 50% 68%, rgba(255, 215, 106, 0.26), rgba(255, 255, 255, 0.03) 70%),
    linear-gradient(180deg, rgba(12, 9, 24, 0.5), rgba(12, 9, 24, 0.2));
  border: 2px solid rgba(255, 215, 106, 0.35);
  border-radius: 4px;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35), inset 0 -2px 0 rgba(255, 255, 255, 0.08);
}

#char-name {
  font-size: 19px;
  font-weight: 700;
  color: #fff;
}

.char-extra { opacity: 0.75; font-size: 11px; white-space: pre-line; } /* J/K 双大招各一行 */
.char-desc {
  font-size: 12px;
  color: #cfc6e6;
  margin-top: 2px;
}

/* 地图选择器(复用角色选择器布局,略紧凑) */
.map-picker .char-arrow {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.map-picker .char-info {
  padding: 6px 16px;
}

#map-preview {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

#map-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

/* 结算 MVP 播报行 */
.mvp-row {
  text-align: center;
  color: #ffd76a;
  font-weight: 700;
  font-size: 15px;
  padding: 4px 0 6px;
  border-bottom: 1px solid rgba(255, 215, 106, 0.25);
  margin-bottom: 4px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* 局后结算战绩表 */
.result-stats {
  position: relative;
  min-width: min(360px, 84vw);
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(74, 58, 116, 0.72), rgba(32, 24, 58, 0.80));
  border: 3px solid #2a2040;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14), inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 4px 0 rgba(0, 0, 0, 0.4);
  padding: 10px 16px;
  margin-bottom: 8px;
}

.stat-row {
  display: grid;
  /* 名字 + 击落/输出/承伤 + 连段/极限/救场(对局数据面板 D9) */
  grid-template-columns: 1fr 44px 52px 52px 40px 40px 40px;
  gap: 6px;
  padding: 4px 2px;
  font-size: 14px;
  color: #e8e2f4;
  text-align: right;
  align-items: center;
}

.stat-row .stat-name {
  text-align: left;
  font-weight: 700;
}

.stat-row.head {
  font-size: 11px;
  color: #9a90b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 2px;
}

.stat-row.winner {
  background: linear-gradient(90deg, rgba(255, 215, 106, 0.18), rgba(255, 215, 106, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.35);
  border-radius: 8px;
}

.elo-badge {
  font-size: 12px;
  font-weight: 700;
}
.elo-badge.up { color: #7de89b; }
.elo-badge.down { color: #ff8a8a; }

/* 天梯排行榜行 */
#ladder-list .player-row {
  display: grid;
  grid-template-columns: 40px 1fr 84px 96px;
  gap: 8px;
  align-items: center;
}
.ladder-rank { font-size: 16px; }
.ladder-name {
  text-align: left;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ladder-rating { color: #ffcc33; font-weight: 700; text-align: right; }
.ladder-record { color: #9a90b8; font-size: 12px; text-align: right; }

.team-tag {
  font-size: 12px;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 1px 7px;
}

/* 成就页 */
.ach-row {
  display: grid;
  grid-template-columns: 36px 1fr 64px;
  gap: 10px;
  align-items: center;
  opacity: 0.55;
}
.ach-row.done { opacity: 1; }
.ach-icon { font-size: 20px; }
.ach-body { text-align: left; display: flex; flex-direction: column; }
.ach-body small { color: #9a90b8; font-size: 11px; }
.ach-state { color: #ffcc33; font-weight: 700; text-align: right; font-size: 13px; }

/* 成就解锁横幅 */
#ach-toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 16, 34, 0.95);
  border: 2px solid #ffcc33;
  color: #ffcc33;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 12px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#ach-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 按钮/面板走**硬边像素框**(2026-07-25 UI 与场内画质对齐):
   模糊阴影 + 大圆角 = 网页控件;硬边描边 + 无模糊的落差 = 游戏控件。
   一律 border-radius 5px(不是 0:纯直角在高 DPI 下反而显得廉价)、3px 深色描边、
   顶部一道内高光、底部一道内暗边、外加一层不带模糊的立面落差。 */
button {
  font-family: inherit;
  font-size: clamp(18px, 3.4vw, 24px);
  font-weight: 700;
  color: #2a1c00;
  background: linear-gradient(180deg, #ffe08a 0%, var(--accent) 52%, #e0a91f 100%);
  border: 3px solid #4a3208;
  border-radius: 5px;
  padding: 12px 20px;
  cursor: pointer;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(0, 0, 0, 0.20),
    0 5px 0 #7a5408;
  transition: transform .07s steps(2), box-shadow .07s steps(2), filter .07s ease;
}

@media (hover: hover) {
  button:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow:
      inset 0 3px 0 rgba(255, 255, 255, 0.55),
      inset 0 -3px 0 rgba(0, 0, 0, 0.20),
      0 7px 0 #7a5408;
  }
}

button:active {
  transform: translateY(5px);
  filter: none;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.4),
    inset 0 -3px 0 rgba(0, 0, 0, 0.20),
    0 0 0 #7a5408;
}

.hint {
  margin-top: 10px;
  color: #cfc6e6;
  font-size: clamp(13px, 2.4vw, 16px);
  max-width: 460px;
  line-height: 1.6;
}

.logo.small {
  font-size: clamp(28px, 6vw, 56px);
}

#result-title {
  font-size: clamp(36px, 8vw, 80px);
  color: var(--accent);
  text-shadow:
    3px 0 0 #5a3808, -3px 0 0 #5a3808, 0 3px 0 #5a3808, 0 -3px 0 #5a3808,
    0 7px 0 #8a5a10, 0 12px 26px rgba(0, 0, 0, 0.6);
  animation: popIn 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.45); }
  to   { opacity: 1; transform: scale(1); }
}

/* 次级按钮:同一套硬边框,只换材质(石板)—— 一眼看出是"同一个 UI 的不同档位",
   而不是"另一个网站的控件" */
button.ghost {
  background: linear-gradient(180deg, #5b5177 0%, #443c60 52%, #332c4c 100%);
  color: #efe9ff;
  border: 3px solid #221c34;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.16),
    inset 0 -3px 0 rgba(0, 0, 0, 0.25),
    0 5px 0 #201a30;
}
@media (hover: hover) {
  button.ghost:hover {
    box-shadow:
      inset 0 3px 0 rgba(255, 255, 255, 0.16),
      inset 0 -3px 0 rgba(0, 0, 0, 0.25),
      0 7px 0 #201a30;
  }
}
button.ghost:active {
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 0 rgba(0, 0, 0, 0.25),
    0 0 0 #201a30;
}


.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 84vw);
  margin-bottom: 8px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: #cfc6e6;
  font-size: 14px;
}

.form label.adv { opacity: 0.7; font-size: 12px; }

.form input {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 4px;
  border: 3px solid #221c34;
  background: linear-gradient(180deg, rgba(10, 8, 20, 0.75), rgba(24, 18, 42, 0.6));
  color: #fff;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.35);
}

.form input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 3px 0 rgba(0,0,0,0.35), 0 0 0 2px rgba(255,204,51,0.28); }

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, 86vw);
  margin: 8px 0 12px;
  max-height: 46vh;
  overflow-y: auto;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 16px;
}

.player-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.player-row .ready-tag {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.player-row .ready-tag.yes { background: #2f9e4f; color: #fff; }
.player-row .ready-tag.no { background: rgba(255,255,255,0.15); color: #cfc6e6; }
.player-row .host-tag { font-size: 12px; color: var(--accent); }
.player-row.you { outline: 2px solid var(--accent); }

/* 语言选择列表:每行一种语言(以其本名显示),当前项高亮 */
.lang-row {
  cursor: pointer;
  justify-content: center;
  position: relative;
  font-size: 17px;
  padding: 8px 14px;
  user-select: none;
}
.lang-row .lang-check { position: absolute; right: 14px; color: var(--accent); font-weight: 700; }
#lang-list { max-height: 60vh; }
@media (hover: hover) {
  .lang-row:hover { border-color: var(--accent); }
}
.lang-row:active { transform: translateY(1px); }

/* 触屏控制 */
#touch-controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#touch-controls.hidden { display: none; }

.touch-zone {
  position: absolute;
  /* iOS 刘海/圆角安全区(viewport-fit=cover 后由 env() 提供) */
  left: calc(24px + env(safe-area-inset-left, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 156px;
  height: 156px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  pointer-events: auto;
}

#touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 204, 51, 0.7);
}

#touch-buttons {
  position: absolute;
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 18px;
  pointer-events: auto;
}

.touch-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 28px;
  box-shadow: 0 4px 0 #b8860b;
  opacity: 0.92;
}

#btn-attack {
  background: linear-gradient(180deg, #ff99bb, var(--accent2));
  box-shadow: 0 4px 0 #b03060;
}

.player-row .char-tag {
  font-size: 12px;
  opacity: 0.85;
}

.touch-btn.small-btn {
  width: 72px;
  height: 72px;
  font-size: 22px;
  align-self: flex-start;
  margin-top: -14px; /* 拇指弧:闪避在攻击左上方,顺着拇指划弧的自然位 */
  background: linear-gradient(180deg, #ffe9a0, #ffd76a);
  box-shadow: 0 4px 0 #b8860b;
}

/* 自定义按键 */
.keys-row { display: flex; justify-content: space-between; align-items: center; }
/* 音量滑杆:与 .key-btn 同一金色语言 */
.vol-row input[type="range"] {
  width: 150px;
  height: 20px;
  accent-color: #ffd76a;
  cursor: pointer;
  background: transparent;
}
.key-btn {
  min-width: 96px; padding: 6px 12px; font: inherit; cursor: pointer;
  background: #262040; color: #ffe14d; border: 1px solid #4a4370; border-radius: 8px;
}
.key-btn.waiting { background: #4a3a10; color: #fff; border-color: #ffd76a; animation: pulse 0.8s infinite alternate; }
.key-btn.active { background: #ffd76a; color: #201a10; border-color: #ffd76a; font-weight: bold; }
.scheme-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
#keys-list { max-height: 52vh; overflow-y: auto; }
@keyframes pulse { from { opacity: 0.7; } to { opacity: 1; } }

/* 按钮上的像素图标(替代系统 emoji;src/ui-icons.js 程序生成) */
.btn-ico {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  margin-right: 0.42em;
  image-rendering: pixelated;
  flex-shrink: 0;
}
