/* === GOOGLE FONT IMPORT === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;800;900&display=swap');

:root{
  --bg:#0b1222; --panel:#0f1732; --ink:#e5e9f5; --muted:#9aa3b2; --ring:#283155;
  --ok-bg:#144429; --warn-bg:#4a3b13; --bad-bg:#0f1938;
  --btn:#131b3a; --btn-ink:#eef2ff; --btn-border:#2c3764;
  --btn-primary:#22306a; --btn-danger:#3a1a22;
  --panel-grad: linear-gradient(145deg, #1a2347, #0f1732);
}
*{box-sizing:border-box}
body{
  margin:0;
  color:var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  background: linear-gradient(270deg, #0b1222, #131b3a, #0b1222);
  background-size: 600% 600%;
  animation: gradientBG 16s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.wrap{max-width:1100px;margin:18px auto;padding:0 12px 300px}
.hdr{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:#0e1533;border-bottom:1px solid var(--ring)}
.brand-only h1{margin:0;font-size:22px}
.brand-only .tag{color:#9aa3b2;font-size:13px}
.hdr-actions{display:flex;gap:8px}
.pill{all:unset;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;min-width:44px;height:40px;padding:0 12px;border-radius:12px;background:var(--btn);color:var(--btn-ink);border:1px solid var(--btn-border); transition: transform 0.15s ease, box-shadow 0.15s ease;}
.pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(44, 55, 100, 0.5);
}
.pill.primary{background:var(--btn-primary)}
.pill.danger{background:var(--btn-danger)}
.pill[disabled]{opacity:.5;cursor:not-allowed}

.topbar{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.chip{padding:6px 10px;border-radius:12px;background:#141d3b}

.theme{
  text-align:center;
  margin:10px auto 12px;
  padding:18px;
  background: var(--panel-grad);
  border-radius:16px;
  max-width:820px;
  border: 1px solid var(--ring);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.theme .title{font-size:12px;letter-spacing:.14em;text-transform:uppercase;color:#c9d4ff;font-weight:800}
.theme .subtitle{font-size:26px;font-weight:900;color:#fff}
.theme .tagline{font-size:12px;color:#aab3cc}

.board{display:grid;gap:14px}
.card{
  padding:14px;
  border-radius:16px;
  background: var(--panel-grad);
  border:1px solid var(--ring);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.card .q{font-weight:700;margin-bottom:8px;display:flex;align-items:center;gap:10px;justify-content:space-between}
.card .left{display:flex;gap:10px;align-items:center}
.grid{display:flex;gap:10px;flex-wrap:wrap}
.slot{width:120px;height:80px;background:#0c1328;border:1px dashed #2b355f;border-radius:12px;display:grid;place-items:center}
.tile{width:100%;height:100%;background:#161f41;border-radius:12px;display:grid;place-items:center;position:relative;border:1px solid var(--btn-border);transition:background .15s,border-color .15s, transform 0.15s ease;}
.pool .tile:hover {
    transform: translateY(-4px);
    border-color: #c9d4ff;
}
.tile .icon{position:absolute;top:6px;left:6px}
.tile .sym{font-weight:800;font-size:22px}
.tile .name{font-size:12px}
.tile .xbtn{position:absolute;right:6px;top:6px;background:transparent;border:none;color:#e7edff;font-size:16px;cursor:pointer;opacity:.85}

.ok .tile{background:var(--ok-bg);border-color:#1f7a3c}
.present .tile{background:var(--warn-bg);border-color:#7a5a15}
.bad .tile{background:var(--bad-bg);border-color:#2d364f}

/* Lab dock */
.lab-dock{position:fixed;left:0;right:0;bottom:0;background:#0f1732;border-top:1px solid var(--ring);box-shadow:0 -8px 24px rgba(0,0,0,.35);padding:10px 12px;transition:transform .25s ease;z-index:50}
.lab-dock.hide{transform:translateY(100%)}
.lab-row{display:flex;gap:10px;align-items:center;flex-direction:column}
.pool{display:flex;gap:8px;flex-wrap:wrap;align-items:stretch;width:100%}
.pool .tile{flex:1 1 calc(33.33% - 8px);height:66px}
.controls{display:grid;grid-template-columns:repeat(4, 1fr);gap:10px;width:100%}
.meter-row{display:flex;align-items:center;gap:10px;margin-top:8px}
.meter{flex:1;height:10px;border-radius:8px;background:#0d1328;border:1px solid var(--ring);position:relative;overflow:hidden}
.meter span{position:absolute;left:0;top:0;bottom:0;background:linear-gradient(90deg,#80eec0,#6dd3ff);width:100%}
.tries{color:#9aa3b2}
.lab-handle{position:fixed;left:12px;bottom:12px;z-index:51;display:none;background:#18224a;color:#fff;padding:8px 12px;border-radius:999px;border:1px solid var(--ring)}
.lab-dock.hide + .lab-handle{display:block}

/* --- Mobile tweaks --- */
@media (max-width: 540px){
  .slot{width:104px;height:72px}
  .tile .sym{font-size:20px}
  .tile .name{font-size:11px}
  .pool .tile{flex:1 1 calc(33.33% - 8px);height:64px}
  .controls{grid-template-columns:repeat(2, 1fr)}
  .wrap{padding-bottom:340px}
  .stats-grid { grid-template-columns: 1fr; }
}

/* Modals & helpers */
.modal{border:none;border-radius:16px;max-width:760px;width:min(96vw,760px);padding:18px;background:#0f1836;color:#e5e9f5;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.modal:not([open]) {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.modal[open]::backdrop {
  opacity: 1;
}

.how .row{display:grid;grid-template-columns:140px 1fr;gap:12px;margin:10px 0}
.how .lbl{color:#9aa3b2}
.badge{display:inline-block;padding:2px 8px;border-radius:10px;background:#1a2246;border:1px solid var(--ring);font-size:12px}
.badge.ok{background:#0f2a1b;border-color:#16492a;color:#bbf7d0}
.badge.warn{background:#2a210f;border-color:#5b4312;color:#fde68a}
.actions-right{display:flex;justify-content:flex-end;margin-top:12px}

/* === NEW: Styles for the enhanced horizontal stats modal === */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.stat-item {
  background: var(--bg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--ring);
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-icon {
  font-size: 24px;
}
.stat-label {
  flex-grow: 1; /* Pushes the value to the right */
  font-size: 16px;
  color: var(--muted);
}
.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

/* === Measured Lab Drawer (non-covering) === */
:root { --lab-h: 0px; }

.lab-dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

/* Only the tiles list scrolls */
#pool, .pool {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* The play area always sits above the lab */
#board, .board, #game, .game-area {
  padding-bottom: calc(var(--lab-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* === HIDE FACT ON SOLVED PUZZLES === */
.card.is-solved .blurb {
  display: none;
}
