/* ================= 恶魔轮盘赌 · 2D 双人联机版 ================= */
:root {
  --bg: #0b0908;
  --panel: #17120f;
  --panel2: #1f1713;
  --line: #3a2a22;
  --red: #e5372e;
  --red-dim: #a32219;
  --gold: #d8a54a;
  --text: #e8ded2;
  --dim: #8d7f70;
  --live: #e5372e;
  --blank: #3f7fd4;
  --unk: #55504a;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 42%, rgba(120, 30, 20, .18), transparent 60%),
    radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0,0,0,.75) 100%);
}
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; }

/* ---------------- 标题 / 大厅 ---------------- */
#screen-title { background: linear-gradient(180deg, #170e0c 0%, #0b0908 70%); }
.title-card {
  width: min(420px, 92vw);
  padding: 34px 30px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(0,0,0,.8), inset 0 0 40px rgba(229,55,46,.05);
  text-align: center;
}
.title-card h1 { font-size: 44px; letter-spacing: 8px; color: var(--text); text-shadow: 0 0 24px rgba(229,55,46,.55); }
.title-card h1 span { color: var(--red); }
.sub { color: var(--dim); font-size: 12px; letter-spacing: 3px; margin: 8px 0 24px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; }
input {
  flex: 1; min-width: 0;
  background: #0e0b09; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; font-size: 15px; outline: none;
  text-align: center; letter-spacing: 2px;
}
input:focus { border-color: var(--red-dim); }
#inp-code { text-transform: uppercase; font-weight: 700; letter-spacing: 6px; }
.or { color: var(--dim); font-size: 12px; margin: 2px 0; }
.btn {
  background: #2a1d16; color: var(--text);
  border: 1px solid #54372b; border-radius: 8px;
  padding: 11px 16px; font-size: 15px; cursor: pointer;
  transition: transform .06s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #c22a20, #7e1811); border-color: #e5372e55; box-shadow: 0 0 18px rgba(229,55,46,.25); }
.btn.big { font-size: 17px; padding: 13px; }
.btn.danger { background: linear-gradient(180deg, #8e1c14, #57100a); }
.link { background: none; border: none; color: var(--dim); cursor: pointer; margin-top: 16px; font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.link:hover { color: var(--text); }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------------- 对局布局 ---------------- */
#screen-game { flex-direction: column; align-items: stretch; }
#hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: rgba(12,9,8,.9); border-bottom: 1px solid var(--line);
  z-index: 5;
}
.hud-left, .hud-mid { display: flex; align-items: center; gap: 10px; }
.hud-room b { color: var(--gold); letter-spacing: 3px; font-size: 16px; }
#hud-round { font-weight: 700; }
#hud-mode { color: var(--dim); font-size: 12px; }
#hud-score { color: var(--gold); letter-spacing: 2px; }
.mini {
  background: #241a14; border: 1px solid var(--line); color: var(--dim);
  border-radius: 6px; padding: 4px 9px; font-size: 12px; cursor: pointer;
}
.mini:hover { color: var(--text); border-color: #5a4032; }
.mini.danger:hover { color: #ff8a80; border-color: #7e1811; }

#layout { flex: 1; display: flex; gap: 10px; padding: 10px; min-height: 0; }
#table-col { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* 玩家面板 */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px 10px; position: relative;
  transition: box-shadow .3s, border-color .3s;
}
.panel.active { border-color: var(--red); box-shadow: 0 0 22px rgba(229,55,46,.28), inset 0 0 24px rgba(229,55,46,.05); }
.panel.me { margin-top: auto; }
.p-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.p-name { font-weight: 700; font-size: 15px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 20px; }
.tag.cuff { background: #3a2f14; color: var(--gold); border: 1px solid #6b5416; }
.tag.off { background: #2a1414; color: #ff8a80; border: 1px solid #5c211b; }
.p-ready { color: #79c26b; font-size: 12px; }
.p-body { display: flex; align-items: center; gap: 10px; }
.hp-label { color: var(--dim); font-size: 12px; white-space: nowrap; }
.hp-label b { color: var(--text); font-size: 14px; }
.hp-pips { display: flex; gap: 4px; }
.pip {
  width: 17px; height: 24px; border-radius: 3px;
  background: linear-gradient(180deg, #2c2320, #1a1512);
  border: 1px solid #4a3b32; transform: skewX(-8deg);
  transition: background .25s, box-shadow .25s;
}
.pip.on {
  background: linear-gradient(180deg, #ff5f4e, #a32219);
  border-color: #ff8a80; box-shadow: 0 0 8px rgba(229,55,46,.6);
}
.pip.hit { animation: pipHit .5s; }
@keyframes pipHit { 0%,100% { transform: skewX(-8deg);} 30% { transform: skewX(-8deg) scale(1.3); filter: brightness(2);} }

/* 道具槽 */
.items { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.slot {
  width: 42px; height: 42px; border-radius: 8px; position: relative;
  background: #120d0a; border: 1px dashed #3a2a22;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.slot.filled {
  border-style: solid; border-color: #5a4032; background: linear-gradient(180deg, #241b14, #171008);
  box-shadow: inset 0 0 8px rgba(0,0,0,.6);
}
#me-items .slot.filled { cursor: pointer; }
#me-items .slot.filled:hover { border-color: var(--gold); filter: brightness(1.2); }
#me-items .slot.filled:active { transform: scale(.94); }
#me-items.locked .slot.filled { cursor: not-allowed; opacity: .75; }
#opp-items .slot.filled.stealable, #me-items .slot.filled.stealable {
  cursor: pointer; border-color: #ff5f4e;
  animation: stealPulse 1s infinite;
}
@keyframes stealPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,55,46,.5);} 50% { box-shadow: 0 0 0 6px rgba(229,55,46,0);} }
.slot .cnt { position: absolute; right: 2px; bottom: 1px; font-size: 9px; color: var(--dim); }
.slot .tip {
  position: absolute; bottom: 105%; left: 50%; transform: translateX(-50%);
  background: #000; border: 1px solid var(--line); color: var(--text);
  font-size: 11px; line-height: 1.5; padding: 7px 10px; border-radius: 8px;
  width: max-content; max-width: 200px; text-align: left;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 30;
}
.slot:hover .tip { opacity: 1; }
.turn-mark {
  position: absolute; top: -10px; right: 12px; font-size: 11px;
  background: var(--red); color: #fff; padding: 2px 9px; border-radius: 20px;
  opacity: 0; transition: opacity .25s;
}
.panel.active .turn-mark { opacity: 1; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .55; } }

/* 中央桌面 */
#table {
  flex: 1; min-height: 150px; position: relative;
  background:
    radial-gradient(ellipse 70% 90% at 50% 50%, #241812 0%, #140e0b 55%, #0d0a08 100%);
  border: 1px solid #33231b; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; overflow: hidden;
}
#table.shake { animation: shake .45s; }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-8px, 4px) rotate(-.6deg); }
  35% { transform: translate(7px, -3px) rotate(.5deg); }
  55% { transform: translate(-5px, 2px); }
  75% { transform: translate(4px, -2px); }
}
#gun-wrap { position: relative; width: 190px; height: 190px; display: flex; align-items: center; justify-content: center; }
#gun { width: 190px; transition: transform .32s cubic-bezier(.6,-.3,.3,1.4); transform: rotate(0deg); }
#gun svg { width: 100%; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }
#gun.aim-opp { transform: rotate(-90deg) translateX(14px); }
#gun.aim-me  { transform: rotate(90deg) translateX(-14px); }
#gun.recoil { animation: recoil .28s; }
@keyframes recoil { 0%{} 30% { margin-left: 10px; } 100% { margin-left: 0; } }
#flash {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd28a 35%, rgba(255,120,40,.6) 60%, transparent 75%);
  opacity: 0; pointer-events: none; z-index: 3;
}
#flash.bang { animation: bang .4s ease-out; }
@keyframes bang {
  0% { opacity: 0; transform: scale(.2); }
  12% { opacity: 1; transform: scale(2.6); }
  100% { opacity: 0; transform: scale(4); }
}
#flash.at-opp { top: -4px; left: 50%; margin-left: -13px; }
#flash.at-me { bottom: -4px; left: 50%; margin-left: -13px; }

#shell-counts { font-size: 14px; letter-spacing: 1px; }
#shell-counts .lv { color: #ff7b6f; font-weight: 700; }
#shell-counts .bl { color: #7fb3ff; font-weight: 700; }
#shell-strip { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; max-width: 90%; min-height: 34px; }
.shell {
  width: 15px; height: 30px; border-radius: 4px 4px 3px 3px; position: relative;
  border: 1px solid rgba(0,0,0,.5); box-shadow: inset 0 -6px 4px rgba(0,0,0,.35);
  transition: transform .2s;
}
.shell::after {
  content: ""; position: absolute; left: -1px; right: -1px; bottom: 0; height: 7px;
  background: linear-gradient(180deg, #d8a54a, #8a6420); border-radius: 0 0 3px 3px;
}
.shell.live { background: linear-gradient(180deg, #ff5f4e, #8e1c14); }
.shell.blank { background: linear-gradient(180deg, #5f97e8, #274f8e); }
.shell.unk { background: linear-gradient(180deg, #4a423b, #2b2520); }
.shell.unk::before { content: "?"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9c8f80; font-size: 11px; font-weight: 700; }
.shell.spent { background: #17120e; opacity: .45; height: 22px; }
.shell.spent::before { content: "×"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #6b5a4a; font-size: 11px; }
.shell.pop { animation: shellPop .4s; }
@keyframes shellPop { 0% { transform: translateY(-14px) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }

#banner {
  position: absolute; left: 0; right: 0; top: 34%; text-align: center;
  font-size: 24px; font-weight: 800; letter-spacing: 4px;
  color: var(--red); text-shadow: 0 0 18px rgba(229,55,46,.8);
  opacity: 0; pointer-events: none; z-index: 4;
}
#banner.show { animation: bannerIn 1.6s ease-out; }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(.7); }
  15% { opacity: 1; transform: scale(1.05); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}
#actions { display: flex; gap: 12px; margin-top: 2px; }
.btn.action { font-size: 16px; padding: 13px 22px; }
#adrenaline-tip {
  position: absolute; bottom: 8px; left: 0; right: 0; text-align: center;
  color: var(--gold); font-size: 13px; animation: blink 1.2s infinite;
}

/* 日志 */
#logbox {
  width: 250px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
}
.log-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--dim); }
#chat-inp { flex: 1; padding: 6px 8px; font-size: 12px; text-align: left; letter-spacing: 0; }
#log { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 12px; line-height: 1.7; color: #b7a897; }
#log div { animation: logIn .25s; }
@keyframes logIn { from { opacity: 0; transform: translateY(4px);} }
#log .sys { color: var(--gold); }
#log .self { color: #e8ded2; }

/* ---------------- 等待房间 ---------------- */
#screen-wait { background: rgba(8,6,5,.94); z-index: 10; }
#wait-code {
  font-size: 58px; font-weight: 900; letter-spacing: 16px; color: var(--gold);
  text-shadow: 0 0 30px rgba(216,165,74,.4); margin: 6px 0 4px; padding-left: 16px;
}
.wait-hint { color: var(--dim); font-size: 13px; margin-bottom: 16px; }
#wait-players { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 15px; }
#wait-players .seat { background: #120d0a; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
#mode-pick { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; font-size: 14px; text-align: left; }
#mode-pick label { cursor: pointer; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
#mode-pick label:has(input:checked) { border-color: var(--red-dim); background: #221410; }
#mode-pick input { accent-color: var(--red); width: auto; margin-right: 8px; }

/* ---------------- 弹窗 / 提示 ---------------- */
#modal-root {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5,3,3,.8); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: min(430px, 92vw); max-height: 84vh; overflow-y: auto;
  background: var(--panel2); border: 1px solid #54372b; border-radius: 14px;
  padding: 26px; text-align: center; box-shadow: 0 0 70px rgba(0,0,0,.9);
  animation: modalIn .25s;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.9); } }
.modal h2 { font-size: 24px; margin-bottom: 8px; letter-spacing: 3px; }
.modal h2.win { color: #ffcf6b; text-shadow: 0 0 20px rgba(255,207,107,.5); }
.modal h2.lose { color: #ff6b5e; }
.modal .big-score { font-size: 40px; font-weight: 900; color: var(--gold); margin: 10px 0; letter-spacing: 6px; }
.modal .desc { color: var(--dim); font-size: 14px; line-height: 1.8; margin-bottom: 18px; }
.modal .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal .rules { text-align: left; font-size: 13px; line-height: 1.9; color: #cbbfae; }
.modal .rules h3 { color: var(--gold); font-size: 14px; margin: 12px 0 4px; }
.modal .rules b { color: var(--text); }

#toast {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%);
  background: #2a1414; border: 1px solid #7e1811; color: #ffb4ab;
  padding: 9px 18px; border-radius: 10px; font-size: 13px; z-index: 40;
  animation: toastIn .2s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

#reconnect {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(5,3,3,.85); color: var(--gold); font-size: 17px; letter-spacing: 2px;
}

/* ---------------- 移动端 ---------------- */
@media (max-width: 760px) {
  #layout { flex-direction: column; padding: 6px; gap: 6px; }
  #logbox { width: 100%; height: 110px; order: 3; }
  #table { min-height: 130px; }
  #gun-wrap { width: 130px; height: 130px; }
  #gun { width: 130px; }
  .btn.action { font-size: 14px; padding: 11px 14px; }
  .slot { width: 36px; height: 36px; font-size: 18px; }
  #wait-code { font-size: 44px; letter-spacing: 10px; }
  .hud-left .mini { display: none; }
}
