/* Make 24 — Playnesta-original stylesheet (MIT). */

:root {
  --bg: #101a24;
  --panel: #17242f;
  --panel-2: #1d2d3a;
  --ink: #eaf1f6;
  --dim: #93a6b4;
  --line: #2c3d4c;
  --accent: #4bc2a2;
  --accent-ink: #08130f;
  --bad: #e2654f;
  --good: #57c785;
  --gold: #e6c15a;
  --pn-vh: 1vh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { min-height: 100vh; }

#app {
  min-height: calc(var(--pn-vh) * 100);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 8px 10px 10px;
  gap: 6px;
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.title { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; white-space: nowrap; }
.title small { color: var(--dim); font-weight: 500; font-size: 11px; margin-left: 4px; }
.spacer { flex: 1 1 auto; }
.hud { display: flex; align-items: baseline; gap: 4px; color: var(--dim); font-size: 11px; white-space: nowrap; }
.hud b { color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; }
.hud .opt { margin-left: 4px; }

/* ---------- board ---------- */
#board {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 460px;
}

.tile {
  appearance: none;
  border: 2px solid #31465a;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: clamp(20px, 7vw, 40px);
  line-height: 1;
  padding: 0;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  font-variant-numeric: tabular-nums;
}
.tile.fraction { font-size: clamp(15px, 5vw, 28px); }
.tile.negative { color: #ffb7a8; }
.tile.sel { border-color: var(--accent); box-shadow: 0 0 0 2px #4bc2a255 inset; transform: translateY(-2px); }
.tile.hinted { border-color: var(--gold); box-shadow: 0 0 0 2px #e6c15a44 inset; }
.tile.moved { animation: pop 0.18s ease; }
.tile.invalid { animation: shake 0.22s ease; border-color: var(--bad); }
.tile.done { border-color: var(--good); box-shadow: 0 0 0 2px #57c78555 inset; }
.tile.spent { opacity: 0.28; }

@keyframes pop { 0% { transform: scale(0.92); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.steps {
  width: 100%;
  max-width: 460px;
  min-height: 16px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  color: var(--dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.steps .step {
  background: #16232e;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.steps .step.latest { color: var(--ink); border-color: #3c5568; }

#ops {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 460px;
}
.op {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1b2a36;
  color: var(--ink);
  font: inherit;
  font-size: clamp(17px, 4.6vw, 22px);
  font-weight: 700;
  padding: 6px 0;
  min-height: 38px;
  cursor: pointer;
  touch-action: manipulation;
}
.op.armed { background: #21424a; border-color: var(--accent); color: #d7fff4; }
.op:disabled { opacity: 0.45; cursor: default; }

/* ---------- status bar ---------- */
#statusbar { display: flex; flex-direction: column; gap: 5px; }
#status { font-size: 11.5px; color: var(--dim); min-height: 15px; line-height: 1.25; }
#status[data-mode="sel"] { color: #cfe9ff; }
#status[data-mode="win"] { color: var(--good); }
#status[data-mode="bad"] { color: var(--bad); }

.actions { display: flex; gap: 5px; }
.actions .btn { flex: 1 1 0; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1b2a36;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 6px;
  min-height: 34px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:hover { background: #233543; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- win overlay ---------- */
#win {
  position: fixed;
  inset: 0;
  background: #05090dcc;
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 14px;
}
#win.hidden { display: none; }
.win-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}
.win-label { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--dim); }
.win-stars { font-size: 26px; color: var(--gold); margin: 4px 0 2px; letter-spacing: 3px; }
.win-body { font-size: 13px; color: #cfe0ea; margin-bottom: 12px; line-height: 1.4; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #05090dcc;
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 14px;
}
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}
.modal h2 { margin: 2px 0 8px; font-size: 16px; }
.modal h3 { margin: 12px 0 4px; font-size: 13px; color: var(--accent); }
.modal p { margin: 0 0 6px; font-size: 12.5px; line-height: 1.5; color: #cfe0ea; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%) translateY(6px);
  background: #0c161e;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 25;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-height: 320px) {
  #app { padding: 5px 8px 6px; gap: 4px; }
  .title small { display: none; }
  #tiles { max-width: 340px; }
  .tile { border-radius: 9px; }
  .op { min-height: 32px; font-size: 16px; }
  .actions .btn { min-height: 30px; padding: 4px 4px; font-size: 11px; }
  #status { font-size: 10.5px; }
  .steps { min-height: 14px; font-size: 10px; }
}
