/* =========================================================================
 * 炸飞机 · 双人棋盘对战 —— 独立样式
 * 明亮、卡片化，与 AI Plane 站点统一视觉
 * ========================================================================= */

:root {
  --ink: #1f2a44;
  --muted: #6b7689;
  --line: #e7ecf5;
  --surface: #ffffff;
  --bg: #f3f7ff;
  --accent: #3d6bff;
  --accent-2: #7a5cff;
  --pink: #ff5c8a;
  --green: #22c07a;
  --amber: #ffb020;
  --red: #ff5b5b;
  --sea: #eaf2ff;
  --sea-line: #c9daf5;
  --plane: #8fb8ff;
  --plane-head: #ff6b6b;
  --radius: 20px;
  --shadow-sm: 0 2px 8px rgba(31, 42, 68, .06);
  --shadow-md: 0 12px 34px rgba(61, 107, 255, .14);
  --shadow-lg: 0 22px 60px rgba(61, 107, 255, .22);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(720px 340px at 12% -6%, rgba(61, 107, 255, .16), transparent 60%),
    radial-gradient(640px 320px at 92% 0%, rgba(122, 92, 255, .14), transparent 55%),
    radial-gradient(560px 300px at 50% 110%, rgba(34, 192, 122, .10), transparent 60%),
    var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.game-shell { max-width: 860px; margin: 0 auto; padding: 18px 18px 56px; }

/* ============ 顶部条 ============ */
.game-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}
.topbar-brand { font-weight: 800; font-size: 17px; }
.topbar-meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  width: 34px; height: 34px; display: grid; place-items: center;
  font-size: 16px; cursor: pointer; transition: transform .12s ease;
}
.icon-btn:hover { transform: scale(1.06); }

/* ============ 画面切换 ============ */
.screen { display: none; animation: fadeUp .35s ease both; }
.screen.is-active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 通用组件 ============ */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  font-family: var(--font); font-size: 15px; font-weight: 700;
  padding: 12px 24px; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, opacity .15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.2); }
.btn-lg { padding: 15px 32px; font-size: 17px; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 10px 26px rgba(61, 107, 255, .32);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(61, 107, 255, .42); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-full { width: 100%; }

/* ============ 开始画面 ============ */
.start-hero { text-align: center; padding: 22px 4px 28px; }
.mascot { font-size: 78px; display: inline-block; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-12px) rotate(5deg); } }
.eyebrow { letter-spacing: 2px; font-size: 12px; color: var(--accent); font-weight: 700; margin: 8px 0 2px; }
.start-title { font-size: 44px; margin: 4px 0 8px; letter-spacing: 1px; }
.grad { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.start-sub { max-width: 620px; margin: 0 auto 18px; color: var(--muted); font-size: 15.5px; }
.start-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.rules-panel { margin-top: 8px; }
.rules-panel h2 { margin: 0 0 14px; font-size: 19px; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.rules-grid h3 { margin: 0 0 10px; font-size: 15px; }
.rules, .shape-note { color: var(--muted); font-size: 14px; margin: 8px 0; }
.rules { padding-left: 18px; }
.rules li { margin: 7px 0; }
.rules code, .shape-note code { background: #eef2f8; padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.hl { color: var(--accent); font-weight: 700; }

.shape-demo { display: flex; gap: 18px; align-items: flex-start; margin: 6px 0 12px; }
.mini-shape {
  display: grid; grid-template-columns: repeat(5, 22px); grid-template-rows: repeat(5, 22px);
  gap: 2px; flex: 0 0 auto;
}
.mini-shape .ms { border-radius: 4px; background: #eef2f8; }
.mini-shape .ms.hd { background: var(--plane-head); }
.mini-shape .ms.bd { background: var(--plane); }
.mini-shape .ms.wg { background: #5f8ce8; }
.mini-shape .ms.tl { background: #9aa9c9; }
.shape-legend { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.sw-head { background: var(--plane-head); }
.sw-body { background: var(--plane); }
.sw-wing { background: #5f8ce8; }
.sw-tail { background: #9aa9c9; }

.tag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 700; margin: 0 2px; }
.tag-miss { background: #eef2f8; color: var(--muted); }
.tag-hit { background: #ffe7e7; color: var(--red); }
.tag-head { background: #ffe9d6; color: #e07a1f; }

/* ============ 摆放画面 ============ */
.place-head { text-align: center; padding: 10px 0 6px; }
.place-head h2 { margin: 4px 0 2px; font-size: 26px; }
.place-sub { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.place-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
.place-left { min-width: 0; }

.dir-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.dir-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: 8px 16px; font-family: var(--font); font-size: 15px; font-weight: 700;
  color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s ease;
}
.dir-btn:hover { border-color: var(--accent); }
.dir-btn.is-active { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(61, 107, 255, .3); }

.place-right { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 60px; }
.place-count { font-size: 15px; margin-bottom: 8px; }
.place-count b { color: var(--accent); font-size: 20px; }
.plane-list { display: grid; gap: 8px; margin-bottom: 6px; }
.plane-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px;
}
.plane-item .p-name { font-weight: 700; }
.plane-item .p-pos { color: var(--muted); }
.plane-item button { border: none; background: #ffe7e7; color: var(--red); border-radius: 8px; width: 26px; height: 26px; cursor: pointer; font-size: 14px; line-height: 1; }
.place-tip { color: var(--muted); font-size: 13px; margin: 0; }
.place-actions { display: flex; gap: 10px; }
.place-actions .btn { flex: 1; }

/* ============ 棋盘 ============ */
.board-wrap { display: flex; flex-direction: column; }
.board-labels { display: flex; }
.board-labels-top { padding-left: 22px; }
.board-labels-left { flex-direction: column; width: 22px; flex: 0 0 22px; }
.board-labels span {
  display: grid; place-items: center; font-size: 11px; color: var(--muted); font-weight: 700;
}
.board-labels-top span { height: 16px; }
.board-labels-left span { flex: 1 1 0; }
.board-with-rows { display: flex; }
.board {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 3px;
  flex: 1 1 0; aspect-ratio: 1 / 1; width: 100%;
}
.board-labels-left span { height: 100%; }

.cell {
  position: relative; border-radius: 6px;
  background: linear-gradient(145deg, #f6faff, #e7f0ff);
  border: 1px solid var(--sea-line);
  display: grid; place-items: center;
  font-size: clamp(11px, 2.4vw, 16px);
  line-height: 1; user-select: none;
  transition: transform .1s ease, box-shadow .15s ease;
}
.cell.hoverable { cursor: pointer; }
.cell.hoverable:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(61, 107, 255, .25); z-index: 1; }
.cell.is-plane { background: linear-gradient(145deg, #bcd6ff, #8fb8ff); border-color: #6f9df0; }
.cell.is-head { background: linear-gradient(145deg, #ff9b9b, #ff6b6b); border-color: #f05252; }
.cell.is-head::after { content: "✈"; font-size: 70%; color: #fff; opacity: .9; }
.cell.is-reveal { border-style: dashed; opacity: .82; }
.cell.ghost { background: rgba(34, 192, 122, .28); border-color: var(--green); }
.cell.ghost-invalid { background: rgba(255, 91, 91, .22); border-color: var(--red); }
.cell.mark-miss { background: #f0f4fb; color: #aab6c9; }
.cell.mark-miss::after { content: "○"; font-size: 60%; }
.cell.mark-hit { background: linear-gradient(145deg, #ffdcdc, #ffb9b9); color: #d63c3c; border-color: #f0a0a0; }
.cell.mark-hit::after { content: "×"; font-size: 85%; font-weight: 800; }
.cell.mark-head { background: linear-gradient(145deg, #ffd9a8, #ff9d3c); color: #fff; border-color: #f0872a; animation: pop .4s ease; }
.cell.mark-head::after { content: "💥"; font-size: 85%; }
.cell.boom { animation: boom .5s ease; }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes boom { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* ============ 移交设备 ============ */
.screen#screen-handoff { display: none; }
.screen#screen-handoff.is-active {
  display: grid; place-items: center; min-height: 70vh;
}
.handoff-inner { text-align: center; padding: 30px; }
.handoff-icon { font-size: 70px; animation: bob 1.8s ease-in-out infinite; }
.handoff-inner h2 { margin: 12px 0 4px; font-size: 26px; }
.handoff-inner p { color: var(--muted); margin: 0 0 20px; }

/* ============ 对战画面 ============ */
.hud {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: rgba(255,255,255,.9);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.hud-turn { font-weight: 800; font-size: 16px; }
.hud-heads { display: flex; gap: 8px; margin-left: auto; }
.chip { padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.chip-self { background: #eaf1ff; color: var(--accent); }
.chip-enemy { background: #ffe9e9; color: var(--red); }

.boards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.board-panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-sm); min-width: 0; }
.board-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.board-panel-head h3 { margin: 0; font-size: 15px; }
.board-hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.board-panel.is-dim { opacity: .85; }

.battle-log { margin-top: 14px; font-size: 14px; color: var(--muted); }
.log-line { padding: 6px 10px; border-bottom: 1px dashed var(--line); }
.log-line:last-child { border-bottom: none; }
.log-line b { color: var(--ink); }
.log-line .l-miss { color: var(--muted); }
.log-line .l-hit { color: var(--red); }
.log-line .l-head { color: #e07a1f; font-weight: 800; }

/* ============ 结算画面 ============ */
.result-card { text-align: center; padding: 40px 26px; max-width: 560px; margin: 20px auto; }
.result-emoji { font-size: 76px; animation: bob 2.4s ease-in-out infinite; }
.result-title { font-size: 34px; margin: 10px 0 4px; }
.result-sub { color: var(--muted); margin: 0 0 22px; }
.result-stats { display: flex; gap: 14px; justify-content: center; margin-bottom: 26px; flex-wrap: wrap; }
.rstat { background: #f4f7ff; border-radius: 14px; padding: 12px 20px; min-width: 96px; }
.rstat b { display: block; font-size: 24px; color: var(--accent); }
.rstat span { font-size: 12px; color: var(--muted); }

/* 结算 · 战场复盘 */
.result-review { margin-top: 24px; }
.result-review h3 { margin: 0 0 4px; font-size: 16px; }
.review-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.review-board { max-width: 380px; margin: 0 auto; }
.review-legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--muted); }
.review-legend span { display: inline-flex; align-items: center; }
.review-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; }
.lg-plane { background: linear-gradient(145deg, #bcd6ff, #8fb8ff); border: 1px solid #6f9df0; }
.lg-head { background: linear-gradient(145deg, #ff9b9b, #ff6b6b); border: 1px solid #f05252; }
.review-legend .lg-txt { margin-left: 4px; }

/* ============ 联网对战 · 房间入口 / 大厅 ============ */
.room-head { text-align: center; padding: 16px 4px 10px; }
.room-head h2 { margin: 4px 0 2px; font-size: 28px; }
.room-sub { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.room-panel { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.room-identity {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #f7faff; font-size: 14px;
}
.room-identity .ri-avatar { font-size: 24px; }
.room-identity .ri-nick { font-weight: 700; }
.room-identity .ri-hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.room-join-row { display: flex; gap: 10px; }
.room-join-row input {
  flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 16px; outline: none; font-family: var(--font);
}
.room-join-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,107,255,.12); }
.room-list-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.room-list-head h3 { margin: 0; font-size: 15px; }
.room-list { display: grid; gap: 8px; }
.room-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 12px 0; }
.room-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.room-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.room-item .ri-code { font-weight: 800; color: var(--accent); min-width: 52px; }
.room-item .ri-host { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .ri-badge { font-size: 12px; color: var(--green); font-weight: 700; }
.room-back { text-align: center; margin-top: 16px; }

.lobby-panel { max-width: 520px; margin: 0 auto; }
.lobby-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lobby-head h2 { margin: 4px 0 0; font-size: 26px; }
.lobby-id { color: var(--accent); }
.lobby-tip { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.lobby-players { display: grid; gap: 10px; margin-bottom: 12px; }
.lobby-player {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.lobby-player .lp-avatar { font-size: 24px; }
.lobby-player .lp-main { flex: 1; min-width: 0; }
.lobby-player .lp-name { font-weight: 800; }
.lobby-player .lp-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.lp-tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 700; }
.lp-tag.host { background: #fff1d6; color: #d98a1f; }
.lp-tag.deploy { background: #e8f6ee; color: var(--green); }
.lp-tag.ready { background: #eaf1ff; color: var(--accent); }
.lp-tag.wait { background: #f1f4f9; color: var(--muted); }
.lobby-player.is-empty { border-style: dashed; color: var(--muted); }
.lobby-status { font-size: 14px; color: var(--ink); margin-bottom: 14px; text-align: center; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lobby-actions .btn { flex: 1 1 auto; }

/* ============ 飘字提示 ============ */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(20, 30, 50, .92); color: #fff; padding: 11px 20px;
  border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 99999;
  animation: toastIn .25s ease both; max-width: 86vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .rules-grid { grid-template-columns: 1fr; gap: 16px; }
  .place-layout { grid-template-columns: 1fr; }
  .place-right { position: static; order: -1; }
  .boards-grid { grid-template-columns: 1fr; gap: 14px; }
  .start-title { font-size: 34px; }
  .hud-heads { margin-left: 0; width: 100%; justify-content: space-between; }
  .chip { font-size: 12px; padding: 4px 10px; }
  .cell { border-radius: 4px; gap: 2px; }
  .mini-shape { grid-template-columns: repeat(5, 17px); grid-template-rows: repeat(5, 17px); }
}
