/* 花园守卫战 · 样式（纯手写，无框架） */
:root {
  --bg: #0d1a12;
  --bg2: #12241a;
  --panel: #16291e;
  --panel2: #1c3427;
  --line: #2a4636;
  --text: #e8f3e9;
  --muted: #8fa899;
  --sun: #ffd257;
  --sun2: #ffb020;
  --p1: #6fd0e8;
  --p2: #f79ac0;
  --ok: #7ed957;
  --warn: #ffb020;
  --bad: #ef5b5b;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, #1d3b28 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #1a2f3a 0%, transparent 55%),
    var(--bg);
  min-height: 100%;
  overflow-x: hidden;
}

#app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(28, 52, 39, .95), rgba(18, 36, 26, .95));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.logo {
  width: 44px; height: 44px; display: grid; place-items: center;
  font-size: 26px; background: radial-gradient(circle at 35% 30%, #3d6b48, #1b3524);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}
.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: .5px; }
.brand-text p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }

.room-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px dashed var(--line); border-radius: 10px;
  background: rgba(0, 0, 0, .2);
}
.room-chip .label { font-size: 11px; color: var(--muted); }
.room-chip strong { font-size: 17px; letter-spacing: 2px; color: var(--sun); font-family: ui-monospace, Consolas, monospace; }

.hud { display: flex; align-items: center; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.sun-box {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 10px; border-radius: 999px;
  background: radial-gradient(circle at 20% 20%, #4a3c12, #2a2410);
  border: 1px solid #6b5a1e; min-width: 104px;
}
.sun-icon { font-size: 20px; color: var(--sun); filter: drop-shadow(0 0 6px rgba(255, 210, 87, .55)); }
.sun-box strong { font-size: 21px; font-variant-numeric: tabular-nums; color: #fff3c4; }
.sun-delta {
  position: absolute; right: 8px; top: -14px; font-size: 12px; color: var(--sun);
  opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s;
}
.sun-delta.show { opacity: 1; transform: translateY(0); }

.wave-box { min-width: 170px; }
.wave-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.wave-line .muted { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; margin-top: 5px; border-radius: 4px; background: #0e1d15; overflow: hidden; border: 1px solid #24402f; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #7ed957, #ffd257); transition: width .3s; }

.lives { display: flex; gap: 4px; font-size: 17px; }
.lives span { filter: grayscale(1) opacity(.35); transition: filter .25s, transform .25s; }
.lives span.on { filter: none; }
.lives span.breaking { transform: scale(1.35); }

.net { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.net i { width: 8px; height: 8px; border-radius: 50%; background: #5a6b60; box-shadow: 0 0 0 3px rgba(90, 107, 96, .15); }
.net.on i { background: var(--ok); box-shadow: 0 0 0 3px rgba(126, 217, 87, .18); }
.net.warn i { background: var(--warn); }
.net.off i { background: var(--bad); }

/* ---------- 舞台 ---------- */
.stage {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) 268px;
  gap: 12px;
  align-items: start;
}
.seedbar, .side {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}
.seedbar { display: flex; flex-direction: column; gap: 8px; }
.seedbar-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.seeds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.seed {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px;
  background: linear-gradient(180deg, #24402f, #1a3123);
  border: 1px solid #2f513c;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s, filter .12s;
  user-select: none;
}
.seed:hover { transform: translateY(-2px); border-color: #4d7d5f; }
.seed canvas { width: 38px; height: 38px; }
.seed .name { font-size: 11.5px; color: #d8ebd9; }
.seed .cost {
  display: flex; align-items: center; gap: 2px; font-size: 11px; color: var(--sun);
  font-variant-numeric: tabular-nums;
}
.seed .hot { position: absolute; top: 3px; left: 5px; font-size: 9.5px; color: #6f8b78; }
.seed.selected {
  border-color: var(--sun); box-shadow: 0 0 0 2px rgba(255, 210, 87, .22), 0 8px 20px rgba(0, 0, 0, .35);
  transform: translateY(-2px);
}
.seed.poor { filter: grayscale(.55) brightness(.75); }
.seed.poor .cost { color: #b98a2d; }
.seed.shovel-on { outline: 2px solid var(--sun); }

.seedbar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.5; }

.board-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #0a1710;
  line-height: 0;
}
#board { display: block; width: 100%; height: auto; touch-action: manipulation; cursor: crosshair; outline: none; }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  padding: 10px 22px; border-radius: 12px;
  background: rgba(8, 20, 12, .82); border: 1px solid #3c6449;
  font-size: 20px; letter-spacing: 1px; color: #fff8d9; line-height: 1.4;
  text-align: center; pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: bannerIn .25s ease-out;
}
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -42%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.banner small { display: block; margin-top: 4px; font-size: 12px; color: #b9d6bd; letter-spacing: 0; }

.ghost-cursor {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; pointer-events: none; transition: transform .12s linear;
  border: 2px solid currentColor; opacity: .85;
}
.ghost-cursor span {
  position: absolute; left: 12px; top: -2px; font-size: 10px; white-space: nowrap;
  background: rgba(0, 0, 0, .5); padding: 1px 5px; border-radius: 6px; line-height: 1.4;
}
.ghost-cursor.p1 { color: var(--p1); }
.ghost-cursor.p2 { color: var(--p2); }

.phase-strip {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--ok), var(--sun)) no-repeat;
  transform-origin: left center; transform: scaleX(0); transition: transform .2s linear;
}

.vote-chip {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  z-index: 8;
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; color: #1a2412;
  background: linear-gradient(180deg, #ffd257, #f0a828);
  border: 1px solid #ffe08a; box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
  animation: chipIn .2s ease-out;
}
.vote-chip b { font-variant-numeric: tabular-nums; }
.vote-chip:hover { filter: brightness(1.06); }
@keyframes chipIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

.floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 14px; font-weight: 700; color: var(--sun); text-shadow: 0 2px 6px rgba(0, 0, 0, .7);
  animation: floatUp .9s ease-out forwards; pointer-events: none;
}
.floater.bad { color: #ff8a8a; }
.floater.good { color: #b6ff9b; }
@keyframes floatUp {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.9); }
  to { opacity: 0; transform: translate(-50%, -130%) scale(1.1); }
}

/* ---------- 右栏 ---------- */
.side { display: flex; flex-direction: column; gap: 10px; min-height: 520px; }
.team { display: flex; flex-direction: column; gap: 8px; }
.mate {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 10px; background: rgba(0, 0, 0, .18);
  border: 1px solid #27432f;
}
.mate.you { border-color: #3a6a4c; }
.mate .dot { width: 8px; height: 8px; border-radius: 50%; background: #5a6b60; }
.mate.online .dot { background: var(--ok); box-shadow: 0 0 8px rgba(126, 217, 87, .6); }
.mate .who { flex: 1; min-width: 0; }
.mate .who b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mate .who small { font-size: 10.5px; color: var(--muted); }
.mate .badge {
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: #2b4a37; color: #cbe6cf; white-space: nowrap;
}
.mate.p1 .badge { background: rgba(111, 208, 232, .16); color: var(--p1); }
.mate.p2 .badge { background: rgba(247, 154, 192, .16); color: var(--p2); }

.chat { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.chat-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.chat-log {
  flex: 1; min-height: 120px; max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 5px; padding-right: 2px;
  font-size: 12px; line-height: 1.45;
}
.msg { padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, .18); word-break: break-word; }
.msg b { font-size: 11px; margin-right: 5px; }
.msg.p1 b { color: var(--p1); }
.msg.p2 b { color: var(--p2); }
.msg.sys { background: none; color: var(--muted); font-size: 11px; padding-left: 2px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input, .field input, .join-row input {
  flex: 1; min-width: 0; padding: 8px 10px; font-size: 12.5px;
  color: var(--text); background: #0f2016; border: 1px solid #2b4835; border-radius: 8px;
  outline: none; font-family: inherit;
}
.chat-form input:focus, .field input:focus, .join-row input:focus { border-color: #4d7d5f; box-shadow: 0 0 0 2px rgba(77, 125, 95, .2); }
button { font-family: inherit; cursor: pointer; }
.chat-form button, .btn {
  padding: 8px 12px; font-size: 12.5px; color: #0c1a11; font-weight: 600;
  background: linear-gradient(180deg, #9ee18a, #6fbf58);
  border: 1px solid #8fd07c; border-radius: 8px; transition: filter .15s, transform .1s;
}
.chat-form button:hover, .btn:hover { filter: brightness(1.06); }
.chat-form button:active, .btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #ffd257, #f0a828); border-color: #ffd97a; }
.btn:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; }

.emotes { display: flex; flex-wrap: wrap; gap: 4px; }
.emotes button {
  font-size: 10.5px; padding: 3px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .06); color: #cfe3d3; border: 1px solid #2b4835;
}
.emotes button:hover { background: rgba(255, 255, 255, .12); }

.mini {
  padding: 3px 8px; font-size: 11px; border-radius: 7px;
  background: rgba(255, 255, 255, .08); color: #dbe9df; border: 1px solid #35553f;
}
.mini:hover { background: rgba(255, 255, 255, .16); }
.mini.ghost { background: transparent; }
.mini.on { background: rgba(255, 210, 87, .18); border-color: #8c7420; color: #ffe8a2; }

.side-foot { display: flex; gap: 6px; justify-content: space-between; }

/* ---------- 遮罩层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(4, 10, 7, .72);
  backdrop-filter: blur(3px);
  animation: fadeIn .18s ease-out;
}
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(560px, 100%);
  max-height: min(88vh, 780px);
  overflow-y: auto;
  padding: 22px 24px;
  background: linear-gradient(180deg, #1b3325, #13241a);
  border: 1px solid #2f513c;
  border-radius: 18px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .6);
}
.panel h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: .5px; }
.panel .lead { margin: 0 0 16px; font-size: 13px; line-height: 1.7; color: #b9d1bd; }
.muted { color: var(--muted); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.field input { width: 100%; }

.lobby-actions { display: flex; flex-direction: column; gap: 10px; }
.lobby-actions .btn { padding: 11px; font-size: 14px; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 3px; font-family: ui-monospace, Consolas, monospace; }

.linklike {
  background: none; border: 0; padding: 2px 0; text-align: left;
  font-size: 11.5px; color: #9ec4a8; text-decoration: underline; text-underline-offset: 3px;
}
.linklike:hover { color: #d6f0dc; }

.api-line { margin-top: 12px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.api-line code { color: #cfe3d3; background: rgba(255, 255, 255, .06); padding: 1px 5px; border-radius: 5px; }
.api-line.err { color: #ff9a9a; }

.rules { margin-top: 14px; font-size: 12px; color: #b9d1bd; }
.rules summary { cursor: pointer; color: #dcecdf; font-size: 12.5px; }
.rules ul { margin: 10px 0 0; padding-left: 18px; line-height: 1.75; }
.rules b { color: var(--sun); font-weight: 600; }

.vote-cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
.vote-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(255, 255, 255, .04); border: 1px solid #2f513c; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.vote-card:hover { border-color: #55876a; background: rgba(255, 255, 255, .07); }
.vote-card .ico { font-size: 22px; width: 34px; text-align: center; }
.vote-card .txt { flex: 1; }
.vote-card .txt b { display: block; font-size: 13.5px; }
.vote-card .txt small { color: var(--muted); font-size: 11.5px; }
.vote-card .votes { font-size: 11px; color: var(--muted); min-width: 54px; text-align: right; }
.vote-card.mine { border-color: var(--sun); box-shadow: 0 0 0 2px rgba(255, 210, 87, .18); }
.vote-card.mate { border-color: rgba(247, 154, 192, .6); }
.vote-status { margin-top: 12px; font-size: 12px; color: var(--muted); }
.panel .linklike { margin-top: 10px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.result-grid div {
  padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, .22);
  border: 1px solid #2b4835; font-size: 12px; color: var(--muted);
}
.result-grid b { display: block; font-size: 18px; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.closest {
  padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.6;
  background: rgba(255, 176, 32, .08); border: 1px solid rgba(255, 176, 32, .3); color: #ffe0a8;
  margin-bottom: 14px;
}
.board-list { font-size: 12px; }
.board-head { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.board-list ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; }
.board-list li { color: #cfe3d3; font-variant-numeric: tabular-nums; }
.result-actions { display: flex; gap: 8px; margin-top: 16px; }
.result-actions .btn { flex: 1; padding: 11px; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none;
}
.toast {
  padding: 9px 16px; border-radius: 999px; font-size: 12.5px;
  background: rgba(12, 26, 18, .94); border: 1px solid #3a5f45; color: #e5f2e7;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
  animation: toastIn .18s ease-out;
}
.toast.bad { border-color: #7a3a3a; color: #ffbcbc; }
.toast.good { border-color: #4c7a3d; color: #d6ffc8; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 窄屏 ---------- */
@media (max-width: 1080px) {
  .stage { grid-template-columns: 176px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; min-height: 0; flex-direction: row; flex-wrap: wrap; }
  .chat { flex: 1 1 320px; }
  .team { flex-direction: row; flex: 1 1 260px; }
  .mate { flex: 1; }
}
@media (max-width: 820px) {
  #app { padding: 8px 8px 20px; gap: 8px; }
  .topbar { gap: 10px; padding: 8px 10px; }
  .brand-text p { display: none; }
  .stage { grid-template-columns: 1fr; }
  .seedbar { order: 2; }
  .seeds { grid-template-columns: repeat(4, 1fr); }
  .seed canvas { width: 30px; height: 30px; }
  .board-wrap { order: 1; }
  .side { order: 3; }
  .hud { width: 100%; margin-left: 0; justify-content: space-between; gap: 10px; }
  .wave-box { min-width: 120px; flex: 1; }
}
