/* Tailwind CSS CDN（辅助工具类） */
@import url('https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css');

/* ============ 设计令牌：王者荣耀竞技风 ============ */
:root {
  --gold: #C8A24B;
  --gold-light: #E4C580;
  --gold-dark: #8A6D2E;
  --bg-0: #0D1117;
  --bg-1: #1A2230;
  --bg-2: #232C3D;
  --text: #F2E6C9;
  --text-dim: #B8C0CE;
  --cat: #D94141;
  --mouse: #3E8ED0;
  --ok: #4CAF50;
  --warn: #FFB300;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app, .screen { position: fixed; inset: 0; }
.screen { display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ============ 通用组件 ============ */
.panel {
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--gold-dark);
  border-radius: 14px;
  box-shadow: 0 0 40px rgba(200, 162, 75, .12), inset 0 0 30px rgba(0, 0, 0, .5);
  padding: 28px 24px;
}

.btn-gold {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 18px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #1a1206;
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-dark));
  border: 1px solid var(--gold-light);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(200, 162, 75, .35);
  cursor: pointer;
  transition: transform .1s, filter .15s;
}
.btn-gold:active { transform: scale(.97); filter: brightness(1.15); }

.hint { font-size: 13px; color: var(--text-dim); margin-top: 12px; }
.hint.center { text-align: center; margin-top: auto; padding-bottom: 24px; }
.gold { color: var(--gold-light); }
.hidden { display: none !important; }

/* ============ 登录页 ============ */
#screen-login {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #1A2230 0%, #0D1117 65%);
}
.login-bg { position: absolute; inset: 0; overflow: hidden; }
.glow { position: absolute; top: 12%; width: 45%; height: 40%; filter: blur(60px); opacity: .35; }
.glow-left { left: 0; background: radial-gradient(circle, var(--cat), transparent 70%); }
.glow-right { right: 0; background: radial-gradient(circle, var(--mouse), transparent 70%); }
.vs-sil {
  position: absolute; top: 14%; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 26px;
  font-size: 64px;
  animation: bob 3s ease-in-out infinite;
}
.vs-text {
  font-size: 22px; font-weight: 900; color: var(--gold-light);
  text-shadow: 0 0 18px rgba(200, 162, 75, .8);
  letter-spacing: 2px;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.login-panel { position: relative; width: min(86vw, 360px); z-index: 1; }
.game-title {
  font-size: 34px; font-weight: 900; text-align: center; letter-spacing: 6px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 20px rgba(200, 162, 75, .25);
}
.subtitle { text-align: center; color: var(--text-dim); font-size: 14px; margin: 8px 0 22px; letter-spacing: 3px; }

#name-input {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  color: var(--text);
  background: rgba(13, 17, 23, .8);
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#name-input:focus { border-color: var(--gold); box-shadow: 0 0 12px rgba(200, 162, 75, .3); }
#login-msg { color: var(--cat); min-height: 18px; text-align: center; }

/* ============ 等待大厅（老鼠场地） ============ */
#screen-lobby { background: #05080d; padding: 0; }
#lobby-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#screen-lobby .lobby-head {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(5, 8, 13, .85), transparent);
  z-index: 5;
}
#screen-lobby .lobby-head h2 { font-size: 22px; letter-spacing: 4px; color: var(--gold-light); }
#screen-lobby .hint.center { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; pointer-events: none; }
#lobby-joy {
  position: absolute; left: 0; bottom: 0;
  width: 45%; height: 50%;
  z-index: 6;
}
#lobby-joy-base {
  position: absolute; left: 26px; bottom: 110px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(26, 34, 48, .45);
  border: 2px solid rgba(200, 162, 75, .4);
  backdrop-filter: blur(2px);
}
#lobby-joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold-dark));
  box-shadow: 0 0 16px rgba(200, 162, 75, .55);
}
#lobby-aim-hint {
  position: absolute; top: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(13, 17, 23, .9);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  color: var(--warn);
  z-index: 7;
}
.lobby-card { display: none; } /* 旧名片样式保留兼容 */
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============ 对局页 ============ */
#screen-game { background: #05080d; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

#hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(5, 8, 13, .85), transparent);
  z-index: 9; /* 高于开局黑屏，准备倒计时始终可见 */
}
#hud-timer {
  font-size: 26px; font-weight: 900; letter-spacing: 2px;
  color: var(--gold-light);
  text-shadow: 0 0 14px rgba(200, 162, 75, .6);
}
#hud-score { font-size: 16px; font-weight: 700; }
#hud-prep {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  padding: 5px 16px; border-radius: 999px;
  background: rgba(13, 17, 23, .92);
  border: 1px solid var(--gold);
  color: var(--gold-light);
  font-size: 14px; font-weight: 700; white-space: nowrap;
  z-index: 9;
}
/* 奶酪进度条（老鼠胜利目标） */
#hud-cheese {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(13, 17, 23, .88);
  border: 1px solid rgba(200, 162, 75, .6);
  font-size: 10px; font-weight: 700; color: var(--gold-light);
  white-space: nowrap; z-index: 9;
}
.cheese-bar {
  width: 56px; height: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); overflow: hidden;
}
#cheese-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #FFB300, #FFE082);
  transition: width .25s;
}
/* 猫排行榜（右上角，前三） */
#hud-cat-rank {
  position: absolute; top: 48px; right: 8px;
  min-width: 66px; padding: 3px 6px;
  border-radius: 8px;
  background: rgba(13, 17, 23, .88);
  border: 1px solid rgba(217, 65, 65, .55);
  font-size: 10px; color: #ffd9d9;
  z-index: 9;
}
#hud-cat-rank .rank-title {
  font-weight: 700;
  color: #ff9d9d;
  border-bottom: 1px solid rgba(217, 65, 65, .4);
  padding-bottom: 2px;
  margin-bottom: 2px;
  white-space: nowrap;
}
#hud-cat-rank .rank-row { padding: 1px 0; white-space: nowrap; }
#hud-cat-rank .rank-n { color: var(--gold-light); font-weight: 700; }
#hud-cat-rank .dim { color: var(--text-dim); }

/* 管理端阵营名单 */
.camp { padding: 6px 0; font-size: 14px; line-height: 1.6; }
.camp.cat { color: #ffd9d9; }
.camp.mouse { color: #d9ecff; }
.camp b {
  color: var(--gold-light);
  margin-right: 10px;
  white-space: nowrap;
}
.camp span { opacity: .95; }

/* 管理端数字输入框：与控制面板同风格的深色金边样式 */
.admin-card input[type="number"] {
  width: 76px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(200, 162, 75, .5);
  color: var(--gold-light);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color .15s;
  -moz-appearance: textfield;
  appearance: textfield;
}
.admin-card input[type="number"]::-webkit-inner-spin-button,
.admin-card input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.admin-card input[type="number"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(200, 162, 75, .18);
}
#prep-overlay {
  position: absolute; inset: 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  z-index: 6; /* 挡住摇杆和技能按钮，但 HUD 在其上方 */
}
#prep-text {
  color: #f2e6c9; font-size: 20px; font-weight: 700;
  letter-spacing: 2px; text-align: center; padding: 0 24px;
}
.role-badge {
  font-size: 13px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid;
}
.role-badge.cat { color: #ffd9d9; border-color: var(--cat); background: rgba(217, 65, 65, .25); }
.role-badge.mouse { color: #d9ecff; border-color: var(--mouse); background: rgba(62, 142, 208, .25); }

#minimap {
  position: absolute; top: 56px; left: 12px;
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  background: rgba(10, 14, 22, .8);
  z-index: 5;
}

/* 摇杆 */
#joystick-zone {
  position: absolute; left: 0; bottom: 0;
  width: 45%; height: 50%;
  z-index: 6;
}
#joystick-base {
  position: absolute; left: 26px; bottom: 110px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(26, 34, 48, .45);
  border: 2px solid rgba(200, 162, 75, .4);
  backdrop-filter: blur(2px);
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold-dark));
  box-shadow: 0 0 16px rgba(200, 162, 75, .55);
}

/* 技能轮盘：两列——最右列主技能竖排，打洞在其左侧一列（右往左数第二列），按钮更大，位置比变身高一排 */
#skill-bar, #lobby-skills {
  position: absolute; right: 26px; bottom: 20px;
  display: flex; flex-direction: row; align-items: stretch; gap: 12px;
  z-index: 6;
}
.skill-col { display: flex; flex-direction: column; gap: 10px; }
.skill-col.main-col { flex-direction: column-reverse; }  /* 第一个主技能在底部 */
.skill-col.tel-col { justify-content: flex-start; position: relative; top: -62px; } /* 打洞比变身高一排 */
/* 打洞选点模式：摇杆保持可用（拖拽定方向，松开发射） */
.skill-btn {
  position: relative;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bg-2), var(--bg-1));
  border: 2px solid var(--gold);
  box-shadow: 0 0 12px rgba(200, 162, 75, .3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .08s;
  overflow: hidden;
  touch-action: none;
}
.skill-btn.big { width: 72px; height: 72px; }
.skill-btn:active, .skill-btn.pressed { transform: scale(1.12); filter: brightness(1.3); }
.skill-btn .icon { font-size: 22px; line-height: 1; }
.skill-btn .label { font-size: 10px; color: var(--gold-light); margin-top: 2px; }
.skill-btn .cd-mask {
  position: absolute; inset: 0; border-radius: 50%;
  pointer-events: none;
}
.skill-btn.aiming { border-color: var(--warn); box-shadow: 0 0 18px rgba(255, 179, 0, .7); animation: pulse .8s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

#aim-hint {
  position: absolute; top: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(13, 17, 23, .9);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  color: var(--warn);
  z-index: 7;
}
#aim-cancel { text-decoration: underline; }

/* 提示浮层 */
#toasts {
  position: absolute; top: 150px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 8; pointer-events: none;
}
.toast {
  background: rgba(13, 17, 23, .85);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  animation: toastIn 2.4s ease forwards;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateY(-8px); }
  10% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#flash {
  position: absolute; inset: 0;
  background: rgba(217, 65, 65, .45);
  opacity: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity .15s;
}
#flash.on { opacity: 1; }

#net-warn {
  position: absolute; top: 56px; right: 12px;
  background: rgba(217, 65, 65, .85);
  color: #fff; font-size: 12px;
  border-radius: 6px; padding: 4px 10px;
  z-index: 9;
}

/* ============ 结算页 ============ */
#screen-result {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 13, .88);
  z-index: 20;
}
.result-panel {
  width: min(86vw, 380px); text-align: center;
  padding: 22px 18px; border-radius: 16px;
  background: rgba(13, 18, 27, .96);
  border: 1px solid var(--gold-dark);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .6);
}
#result-title { font-size: 40px; font-weight: 900; letter-spacing: 6px; }
#result-title.cat-win { color: var(--cat); text-shadow: 0 0 30px rgba(217, 65, 65, .6); }
#result-title.mouse-win { color: var(--mouse); text-shadow: 0 0 30px rgba(62, 142, 208, .6); }
#result-sub { font-size: 16px; margin-top: 8px; }
#result-list {
  margin: 14px 0 18px; padding: 10px 12px;
  background: rgba(255, 255, 255, .04);
  border-radius: 10px; text-align: left;
  max-height: 34vh; overflow-y: auto;
}
.result-list-head {
  font-size: 13px; color: var(--gold-light); font-weight: 700;
  padding-bottom: 6px; margin-bottom: 6px;
  border-bottom: 1px solid rgba(200, 162, 75, .25);
}
.result-list-row { font-size: 14px; color: var(--text); padding: 3px 0; }

/* ============ 管理端 ============ */
.admin-body { overflow: auto; touch-action: pan-y; }
#screen-admin { padding: 16px; gap: 14px; background: radial-gradient(ellipse at 50% 0%, #1A2230 0%, #0D1117 70%); overflow-y: auto; }
.admin-title { font-size: 22px; font-weight: 900; letter-spacing: 4px; color: var(--gold-light); }
.admin-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin-card {
  background: var(--bg-2);
  border: 1px solid var(--gold-dark);
  border-radius: 12px;
  padding: 14px;
}
.admin-card h3 { font-size: 15px; color: var(--gold-light); margin-bottom: 10px; }
.btn-dark {
  padding: 10px 16px; font-size: 14px; font-weight: 700;
  color: var(--text); background: var(--bg-1);
  border: 1px solid var(--gold-dark); border-radius: 8px; cursor: pointer;
}
.btn-dark.danger { border-color: var(--cat); color: #ffb3b3; }
.btn-dark.primary { background: linear-gradient(180deg, var(--gold-light), var(--gold-dark)); color: #1a1206; }
#spectate-canvas { width: 100%; border: 1px solid var(--gold-dark); border-radius: 8px; background: #05080d; }
table.player-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.player-table th, .player-table td { padding: 6px 8px; border-bottom: 1px solid var(--bg-1); text-align: left; }
.player-table th { color: var(--text-dim); font-weight: 400; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid; }
.tag.cat { color: #ffb3b3; border-color: var(--cat); }
.tag.mouse { color: #d9ecff; border-color: var(--mouse); }
#admin-log {
  font-family: monospace; font-size: 11px; color: var(--text-dim);
  max-height: 180px; overflow-y: auto; line-height: 1.7;
}
input[type=range] { accent-color: var(--gold); }
/* 管理端下拉框：深色主题 + 自定义箭头，选项列表同色避免白底刺眼 */
#screen-admin select {
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(180deg, #1c2536, #131a26);
  color: #f2e6c9;
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
  padding: 10px 34px 10px 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 2px 6px rgba(0,0,0,.35);
  transition: border-color .15s, box-shadow .15s;
}
#screen-admin select:hover { border-color: var(--gold); }
#screen-admin select:focus {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 3px rgba(200, 162, 75, .18), 0 2px 6px rgba(0,0,0,.35);
}
#screen-admin select option {
  background: #131a26;
  color: #f2e6c9;
  font-size: 15px;
  padding: 8px 14px;
}
#screen-admin select:disabled { opacity: .5; cursor: not-allowed; }
/* 自定义下拉箭头 */
#screen-admin select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23c8a24b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
/* 地图选择加宽，文字更醒目 */
#screen-admin #map-select { min-width: 190px; font-size: 16px; color: var(--gold-light); }
