/* ==========================================================================
   SUPPLY CHINESE CHESS GUIDE - THEMED SYSTEM
   ========================================================================== */

:root {
  --bg-dark: #101827;
  --table-felt-1: #2b1a0d;
  --table-felt-2: #1a1109;
  --table-felt-3: #101827;
  --panel-bg: rgba(20, 15, 10, 0.88);
  --panel-border: rgba(255, 255, 255, 0.18);
  
  --wood-dark: #5d371a;
  --wood-mid: #8a5a2b;
  --wood-light: #d7a45f;
  
  --gold: #f5c451;
  --crimson: #b91c1c;
  --blue: #38bdf8;
  --green: #51cf66;
  --yellow: #fcc419;
  --ink: #f4f0e7;
  --muted: #aab8c6;
  
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --header-height: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body.supply-app {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 50% 10%, var(--table-felt-1) 0%, var(--table-felt-2) 47%, var(--table-felt-3) 100%);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

.app-header { position: sticky; top: 0; z-index: 100; height: var(--header-height); background: rgba(16, 24, 39, 0.94); backdrop-filter: blur(16px); border-bottom: 1px solid var(--panel-border); }
.header-inner { max-width: 1400px; margin: 0 auto; height: 100%; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-tile { font-size: 2rem; background: var(--blue); border: 2px solid var(--gold); border-radius: 10px; width: 46px; height: 46px; display: grid; place-items: center; color: #fff; }
.brand-text h1 { font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.brand-text .badge { font-size: 0.72rem; font-weight: 900; background: var(--gold); color: #151b1a; padding: 2px 8px; border-radius: 99px; }
.brand-text .subtitle { font-size: 0.8rem; color: var(--muted); }

.header-search { flex: 0 1 400px; position: relative; display: flex; align-items: center; }
.header-search input { width: 100%; padding: 10px 16px 10px 42px; background: rgba(3, 15, 12, 0.75); border: 1px solid var(--panel-border); border-radius: 99px; color: var(--ink); }
.search-icon { position: absolute; left: 14px; opacity: 0.6; }

.table-outer-wrapper { max-width: 1400px; margin: 20px auto; padding: 0 20px; }
.table-wood-frame { position: relative; background: linear-gradient(145deg, var(--wood-dark), var(--wood-mid), var(--wood-dark)); border-radius: 28px; padding: 18px; border: 4px solid var(--wood-light); box-shadow: 0 28px 80px rgba(0,0,0,0.75); }
.table-corner { position: absolute; width: 28px; height: 28px; border: 3.5px solid var(--gold); }
.corner-tl { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.corner-tr { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.corner-br { bottom: 12px; right: 12px; border-left: none; border-top: none; }
.table-felt-mat { background: linear-gradient(135deg, rgba(43,26,13,0.95), rgba(26,17,9,0.98)); border-radius: 20px; padding: 24px; border: 1px solid var(--panel-border); }

.table-mode-tabs { display: flex; flex-wrap: wrap; gap: 8px; background: rgba(3, 15, 12, 0.85); border: 1px solid var(--panel-border); padding: 10px; border-radius: 16px; margin-bottom: 24px; }
.table-tab { flex: 0 0 auto; padding: 9px 16px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-border); color: var(--muted); font-weight: 800; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
.table-tab.active { background: var(--gold); color: #151b1a; border-color: var(--gold); box-shadow: 0 4px 14px rgba(255, 201, 90, 0.4); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }
.content-block { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 20px; padding: 28px; }
.tool-block { border-color: rgba(255, 201, 90, 0.4); background: radial-gradient(circle at 50% 20%, rgba(26,50,72,0.95), rgba(14,28,42,0.98)); }

.block-header { margin-bottom: 20px; }
.header-tag { font-size: 0.72rem; font-weight: 900; color: var(--gold); text-transform: uppercase; }
.block-header h2 { font-size: 1.55rem; font-weight: 900; color: var(--ink); }
.block-header p { color: var(--muted); font-size: 0.92rem; }

/* Hangar Box */
.board-container { display: flex; justify-content: center; margin: 20px 0; }
.aeroplane-board-box { width: 100%; max-width: 460px; aspect-ratio: 1; border: 4px solid var(--wood-light); border-radius: 16px; background: #0c1824; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }
.hangar-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; width: 100%; height: 100%; position: relative; }
.hangar { border-radius: 12px; padding: 16px; display: grid; place-items: center; font-weight: 900; font-size: 1.1rem; }
.hangar.red { background: rgba(228, 91, 85, 0.25); border: 2px solid var(--crimson); color: #ff8787; }
.hangar.yellow { background: rgba(252, 196, 25, 0.25); border: 2px solid var(--yellow); color: var(--gold); }
.hangar.blue { background: rgba(51, 154, 240, 0.25); border: 2px solid var(--blue); color: #74c0fc; }
.hangar.green { background: rgba(81, 207, 102, 0.25); border: 2px solid var(--green); color: #69db7c; }

.center-target { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--panel-bg); border: 2px solid var(--gold); border-radius: 50%; padding: 16px; font-weight: 900; font-size: 0.85rem; color: var(--gold); text-align: center; box-shadow: 0 0 20px rgba(255, 201, 90, 0.4); }

.piece-selector-grid { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.piece-btn { padding: 8px 14px; border-radius: 8px; background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); color: var(--muted); font-weight: 800; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
.piece-btn.active { background: var(--gold); color: #151b1a; border-color: var(--gold); }

.piece-detail-card { background: rgba(9, 23, 36, 0.8); border: 1px solid var(--panel-border); border-radius: 14px; padding: 20px; }
.detail-header { display: flex; align-items: center; gap: 14px; }
.piece-avatar { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; background: var(--blue); border: 2px solid var(--gold); color: #fff; }

.callout-box { display: flex; gap: 14px; padding: 18px; border-radius: 14px; }
.danger-callout { background: rgba(255, 201, 90, 0.12); border: 1px solid rgba(255, 201, 90, 0.35); }
.callout-icon { font-size: 1.8rem; }

.text-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.info-card { background: rgba(9, 23, 36, 0.7); border: 1px solid var(--panel-border); border-radius: 14px; padding: 18px; }
.info-card.highlight-card { background: rgba(26, 50, 72, 0.4); border-color: rgba(255, 201, 90, 0.4); }

.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: rgba(9, 23, 36, 0.7); border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px 16px; }
.faq-item summary { font-weight: 800; color: var(--ink); cursor: pointer; }
.faq-item p { margin-top: 8px; font-size: 0.88rem; color: var(--muted); }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }

/* ---- Phones. Added after a measured audit: these pages had no media query, so
   the nested table chrome took 180px of a 390px screen and the diagrams
   overflowed the page. Give the content its width back. ---- */
@media (max-width: 720px) {
  .header-inner { padding: 0 12px; gap: 10px; }
  .table-outer-wrapper { margin: 12px auto; padding: 0 10px; }
  .table-wood-frame { padding: 8px; }
  .table-felt-mat { padding: 12px; }
  .table-content-area { padding: 0; }
  .content-block { padding: 14px; }
  .block-header h2 { font-size: 1.15rem; }
  .text-card-grid { grid-template-columns: 1fr; gap: 12px; }
  .table-mode-tabs { padding: 6px; gap: 6px; }
}


/* ==========================================================================
   SUPPLY CHINESE CHESS ONLY
   ========================================================================== */

.two-boards { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; margin: 18px 0; }
.mini-board { background: var(--wood-light); border: 2px solid var(--wood-dark); border-radius: 12px; padding: 12px 10px; text-align: center; color: #2a1a0c; }
.mini-board h3 { font-family: var(--font-sans); font-size: .95rem; margin-bottom: 6px; color: #2a1a0c; }
.mini-seat { display: block; padding: 5px 8px; margin: 5px 0; border-radius: 8px; font-weight: 800; font-size: .82rem; }
.mini-seat.red { background: var(--crimson); color: #fff; }
.mini-seat.black { background: #1f2937; color: #fff; }
.supply-arrow { display: grid; place-items: center; gap: 4px; color: var(--gold); font-weight: 900; font-size: .74rem; text-align: center; line-height: 1.3; }
.supply-arrow span { font-size: 1.5rem; line-height: 1; }
@media (max-width: 720px) {
  .two-boards { grid-template-columns: 1fr; }
  .supply-arrow { transform: rotate(90deg); padding: 6px 0; }
}

.drop-demo { display: grid; grid-template-columns: minmax(0,1fr); gap: 14px; margin-top: 14px; }
.piece-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.piece-picker button {
  min-height: 44px; min-width: 44px; padding: 8px 14px; cursor: pointer;
  font: 800 1rem var(--font-sans); color: var(--ink);
  background: var(--wood-mid); border: 2px solid var(--wood-dark); border-radius: 10px;
}
.piece-picker button.active { background: var(--gold); color: #2a1a0c; border-color: var(--gold); }
.xq-grid {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px;
  background: var(--wood-dark); padding: 6px; border-radius: 10px;
  /* An explicit width, not max-width plus auto margins: as a grid item with
     margin:0 auto this box sizes to its content, and repeat(9,1fr) contributes
     no intrinsic width, so it collapsed to 0x0 at every viewport while still
     reporting all 90 cells to a querySelectorAll. */
  width: min(430px, 100%); justify-self: center; aspect-ratio: 9 / 10;
}
.xq-pt { background: var(--wood-light); border-radius: 3px; display: grid; place-items: center; font-size: .7rem; color: #6b4a24; }
.xq-pt.river { background: #b98f52; }
.xq-pt.ok { background: var(--green); color: #06210d; font-weight: 900; }
.xq-pt.palace { outline: 1px dashed rgba(0,0,0,.35); outline-offset: -2px; }
.drop-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .82rem; color: var(--muted); margin-top: 10px; }
.drop-legend b { color: var(--ink); }
.drop-note { margin-top: 10px; font-size: .9rem; color: var(--muted); min-height: 2.6em; }

.no-results { padding: 18px; text-align: center; color: var(--muted); }
mark.hit { background: var(--gold); color: #2a1a0c; border-radius: 3px; padding: 0 2px; }
