:root {
  --bg: #07131b;
  --bg2: #0d202b;
  --panel: #102a37;
  --panel2: #163746;
  --line: #234b5c;
  --text: #e5f4f2;
  --muted: #8fb6b7;
  --teal: #5ee0d0;
  --gold: #e9bd68;
  --red: #ff7f7f;
  --green: #8ee28a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, #174257 0, transparent 45%),
    linear-gradient(180deg, #07131b 0%, #0b202b 55%, #07131b 100%);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
}
button { font: inherit; }
.app { max-width: 1440px; margin: 0 auto; padding: 20px 22px 40px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 14px; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: .5px; }
.brand span { font-size: 11px; color: #06222b; background: var(--teal); padding: 3px 7px; border-radius: 20px; vertical-align: middle; margin-left: 6px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 5px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #12313e; color: var(--text); border-radius: 10px; padding: 9px 14px; cursor: pointer; }
.btn:hover { border-color: var(--teal); background: #194453; }
.btn.primary { background: var(--teal); color: #06222b; border-color: var(--teal); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card { background: linear-gradient(160deg, #143847, #0e2633); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-card .k { color: var(--muted); font-size: 12px; }
.stat-card .v { font-size: 21px; font-weight: 800; margin-top: 2px; }
.bar { height: 7px; background: #071a22; border-radius: 20px; margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--teal); border-radius: 20px; }
.bar.red i { background: var(--red); }
.bar.gold i { background: var(--gold); }
.bar.green i { background: var(--green); }
.layout { display: grid; grid-template-columns: 1.35fr .75fr; gap: 14px; margin-bottom: 14px; }
.layout.lower { grid-template-columns: 1fr 1fr 1fr; }
.panel { background: linear-gradient(170deg, rgba(19, 49, 62, .95), rgba(12, 31, 41, .95)); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.panel-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.panel-head h2 { margin: 0 0 4px; font-size: 16px; }
.hint { color: var(--muted); font-size: 11px; }
.map { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-top: 12px; }
.tile { aspect-ratio: 1; border: 1px solid #234b5c; border-radius: 9px; background: #0b202b; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; transition: .12s; user-select: none; min-height: 52px; }
.tile:hover { border-color: var(--teal); transform: translateY(-1px); }
.tile.fog { background: #0a1a23; color: #426b78; }
.tile.ocean { background: #071924; color: #3c8497; }
.tile.camp { box-shadow: inset 0 0 0 2px var(--gold); }
.tile.player { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal), 0 0 20px rgba(94,224,208,.25); }
.tile .emoji { font-size: 20px; line-height: 1; }
.tile .small { font-size: 9px; color: var(--muted); margin-top: 3px; }
.tile .badge { position: absolute; right: 3px; top: 3px; background: var(--gold); color: #1b1508; border-radius: 10px; font-size: 9px; padding: 1px 4px; font-weight: 800; }
.tile .monster { position: absolute; left: 3px; top: 3px; font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 11px; margin-top: 10px; }
.tile-info { min-height: 128px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.tile-info b { color: var(--text); }
.tile-info .cost { color: var(--gold); }
.inventory { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.inv-item { display: flex; justify-content: space-between; background: #0c222c; border: 1px solid #1d3d4a; border-radius: 8px; padding: 6px 8px; }
.tools { display: grid; gap: 6px; font-size: 13px; }
.tool { display: flex; justify-content: space-between; background: #0c222c; border: 1px solid #1d3d4a; border-radius: 8px; padding: 6px 8px; }
.cards { display: grid; gap: 7px; margin-top: 10px; max-height: 340px; overflow: auto; }
.recipe { border: 1px solid #1d3d4a; background: #0c222c; border-radius: 9px; padding: 8px 9px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.recipe .name { font-weight: 700; font-size: 13px; }
.recipe .cost { color: var(--muted); font-size: 11px; margin-top: 3px; }
.recipe button { padding: 5px 9px; border-radius: 7px; font-size: 11px; }
.quick-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.log { max-height: 260px; overflow: auto; font-size: 12px; line-height: 1.65; color: var(--muted); }
.log div { border-bottom: 1px dashed #1a3a47; padding: 5px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #173b48; color: var(--text); border: 1px solid var(--teal); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 99; }
.toast.show { opacity: 1; }
@media (max-width: 980px) {
  .layout, .layout.lower { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .map { gap: 3px; }
  .tile { min-height: 34px; border-radius: 6px; }
  .tile .emoji { font-size: 17px; }
}

/* 新版：全开放地图、放置模式、道具详情 */
.tile.cleared { opacity: .72; }
.tile.cleared .small { color: #6f9a9d; }
.tile.selected { outline: 2px solid var(--gold); outline-offset: -2px; }
.tile.preview-ok { outline: 2px solid var(--green); background: rgba(142,226,138,.16); }
.tile.preview-bad { outline: 2px solid var(--red); background: rgba(255,127,127,.16); }
.tile .building-mark { font-size: 19px; line-height: 1; }
.tile .res-line { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.tile .res-pill { font-size: 9px; background: rgba(7,19,27,.75); border-radius: 8px; padding: 0 3px; }
.tile .detail-dot { position: absolute; left: 3px; bottom: 3px; font-size: 8px; color: var(--gold); }
.recipe .need { font-size: 11px; margin-top: 3px; }
.recipe .need .ok { color: var(--green); }
.recipe .need .bad { color: var(--red); }
.recipe button:disabled { opacity: .35; }
.quick-actions { flex-wrap: wrap; }
.placement-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 80; width: min(680px, calc(100vw - 24px)); background: #102f3c; border: 1px solid var(--teal); border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.placement-bar.hidden { display: none; }
.placement-actions { display: flex; gap: 8px; }
.placement-text { font-size: 12px; color: var(--muted); }
.sheet { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet.hidden { display: none; }
.sheet-card { width: min(680px, 100vw); max-height: 82vh; overflow: auto; background: #102a37; border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.icon-btn { border: 1px solid var(--line); background: #12313e; color: var(--text); border-radius: 8px; width: 32px; height: 32px; font-size: 18px; cursor: pointer; }
.sheet-body { margin-top: 10px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.sheet-body b { color: var(--text); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
@media (max-width: 980px) {
  .app { padding: 10px 10px 96px; }
  .topbar { align-items: flex-start; }
  .brand { font-size: 21px; }
  .sub { font-size: 11px; }
  .top-actions .btn { padding: 8px 10px; font-size: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .stat-card { padding: 7px 9px; }
  .stat-card .v { font-size: 18px; }
  .panel { padding: 10px; border-radius: 11px; }
  .panel-head h2 { font-size: 14px; }
  .layout { grid-template-columns: 1fr; gap: 10px; }
  .layout.lower { grid-template-columns: 1fr; gap: 10px; }
  .map { gap: 2px; margin-top: 8px; }
  .tile { min-height: 36px; border-radius: 6px; }
  .tile .emoji { font-size: 17px; }
  .tile .small { font-size: 8px; margin-top: 1px; }
  .legend { font-size: 9px; gap: 5px; }
  .tile-info { min-height: 0; }
  .inventory { grid-template-columns: 1fr 1fr; }
  .cards { max-height: 230px; }
  .placement-bar { bottom: 8px; }
  .sheet-card { max-height: 88vh; }
}
@media (max-width: 980px) {
  .app { width: 100%; overflow-x: hidden; }
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .brand { font-size: 20px; }
  .top-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .top-actions .btn { width: 100%; padding: 8px 6px; font-size: 12px; }
  .layout, .layout.lower { min-width: 0; width: 100%; }
  .panel, .map-panel, .side-panel { min-width: 0; width: 100%; }
  .map { grid-template-columns: repeat(9, minmax(0, 1fr)); width: 100%; gap: 2px; overflow: hidden; }
  .tile { min-width: 0; min-height: 0; aspect-ratio: 1; padding: 1px; border-radius: 5px; }
  .tile .emoji { font-size: 15px; }
  .tile .building-mark { font-size: 15px; }
  .tile .small { font-size: 7px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tile .res-line { gap: 0; margin-top: 0; }
  .tile .res-pill { font-size: 7px; padding: 0 1px; }
  .tile .badge { font-size: 7px; padding: 0 2px; right: 1px; top: 1px; }
  .tile .detail-dot { font-size: 7px; }
  .panel-head { flex-wrap: wrap; gap: 4px; }
  .legend { display: none; }
  .inventory { grid-template-columns: 1fr 1fr; }
  .inventory .inv-item { font-size: 11px; padding: 5px 6px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card .v { font-size: 17px; }
}
@media (max-width: 980px) {
  html, body { overflow-x: hidden; width: 100%; }
  .app { overflow-x: hidden; }
  .map-panel { overflow: hidden; }
  .map { width: 100% !important; max-width: 100% !important; grid-template-columns: repeat(9, minmax(0, 1fr)) !important; }
  .tile { width: 100% !important; min-width: 0 !important; max-width: 100% !important; overflow: hidden; }
  .top-actions .btn { min-width: 0; white-space: normal; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
}
@media (max-width: 980px) {
  .app, .topbar, .layout, .layout.lower, .panel, .map-panel, .side-panel { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px) !important; }
  .top-actions { width: 100% !important; max-width: 100% !important; grid-template-columns: 1fr 1fr; }
  .top-actions .btn { width: 100% !important; max-width: 100% !important; font-size: 11px; padding: 7px 4px; }
  .map { width: calc(100vw - 40px) !important; max-width: calc(100vw - 40px) !important; }
}
.tool small { display:block;color:#8fb6b7;font-size:10px;margin-top:2px; }\n
.overlay { position:fixed; inset:0; z-index:120; background:rgba(0,0,0,.72); display:flex; align-items:center; justify-content:center; padding:18px; }
.overlay.hidden { display:none; }
.overlay-card { width:min(460px,100%); background:#102a37; border:1px solid var(--teal); border-radius:18px; padding:22px; box-shadow:0 20px 70px rgba(0,0,0,.6); }
.overlay-card h1 { margin:0 0 8px; font-size:24px; }
.overlay-card p { color:var(--muted); line-height:1.7; }
.overlay-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:16px; }
.code-box { margin-top:14px; background:#081a23; border:1px dashed var(--teal); border-radius:10px; padding:12px; }
.redeem-code { font:700 28px/1.2 Consolas,monospace; letter-spacing:5px; color:var(--gold); text-align:center; margin:6px 0 10px; user-select:all; }
#codeSheet { z-index: 220; }
#returnSheet, #exhaustedSheet { z-index: 210; }
#gameOver { z-index: 120; }
@media (min-width: 981px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.furnace-box { margin-top:14px; padding-top:12px; border-top:1px solid var(--line); }
.furnace-box.hidden { display:none; }
#inventory { background:#081a23; border:1px solid #1d3d4a; border-radius:10px; padding:8px; }
.inv-item { color:var(--text) !important; font:inherit; width:100%; border:1px solid #1d3d4a; }
.inv-item span { color:var(--text); }
.inv-item b { color:var(--gold); }
.inv-item small { color:var(--muted); display:block; margin-top:3px; }
.inv-item:hover { border-color:var(--teal); background:#12313e; }
.tutorial { position:fixed; inset:0; z-index:180; pointer-events:none; }
.tutorial.hidden { display:none; }
.tutorial-spot { position:fixed; border:3px solid var(--teal); border-radius:12px; box-shadow:0 0 0 5px rgba(94,224,208,.16),0 0 34px rgba(94,224,208,.45); pointer-events:none; transition:all .22s ease; z-index:181; }
.tutorial-spot.hidden { display:none; }
.tutorial-arrow { position:fixed; z-index:182; color:var(--gold); font-size:34px; line-height:1; text-shadow:0 2px 10px rgba(0,0,0,.7); pointer-events:none; transform-origin:center; }
.tutorial-card { position:fixed; left:50%; bottom:18px; transform:translateX(-50%); width:min(620px,calc(100vw - 24px)); background:#102a37; border:1px solid var(--teal); border-radius:16px; padding:16px 18px; box-shadow:0 18px 60px rgba(0,0,0,.6); pointer-events:auto; z-index:183; }
.tutorial-step { color:var(--teal); font-size:11px; letter-spacing:.08em; }
.tutorial-card h2 { margin:5px 0 6px; font-size:20px; }
.tutorial-card p { margin:0; color:var(--muted); font-size:13px; line-height:1.7; }
.tutorial-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }
.tutorial-actions .primary { margin-left:auto; }
.tutorial-focus { position:relative; z-index:181; }
@media (max-width:980px) { .tutorial-card { bottom:10px; padding:13px 14px; } .tutorial-card h2 { font-size:18px; } .tutorial-card p { font-size:12px; } }
.start-notice { position:fixed; inset:0; z-index:240; display:flex; align-items:center; justify-content:center; padding:18px; background:radial-gradient(circle at 50% 35%,rgba(94,224,208,.12),transparent 45%),rgba(2,10,15,.86); }
.start-notice.hidden { display:none; }
.start-card { width:min(520px,100%); background:linear-gradient(160deg,#123847,#0b202b); border:1px solid var(--teal); border-radius:20px; padding:28px 26px; text-align:center; box-shadow:0 25px 80px rgba(0,0,0,.65); }
.start-kicker { color:var(--teal); font-size:11px; letter-spacing:.18em; }
.start-card h1 { margin:10px 0 12px; font-size:28px; color:#fff; }
.start-card p { color:var(--muted); line-height:1.8; margin:0 0 10px; }
.start-card .start-maint { color:var(--gold); font-size:12px; margin-top:14px; }
.start-enter { margin-top:12px; min-width:180px; }
@media (max-width:600px) { .start-card { padding:22px 18px; } .start-card h1 { font-size:23px; } }
.start-warning { color:#ffb4a8; font-weight:800; font-size:13px; margin-top:6px !important; }\n
