/* Playnesta shell stylesheet for Code Break (Playnesta-original MIT).
   A 4-digit code puzzle with bulls/cows feedback: secret slots, entry slots,
   a guess history list and a 3x4 on-screen keypad. No sprites, fonts or
   network assets.

   The layout is a two-column flex row (panel left, keypad right) so it fits
   the two production stages — a 894x670 desktop stage and a 348x261 phone
   stage — with no overflow in either axis. Heights are viewport-relative and
   every row is allowed to shrink, so nothing ever spills. */

* { box-sizing: border-box; }

:root {
  --bg: #101a24;
  --panel: #18242f;
  --panel-2: #1f2d3a;
  --ink: #eaf2f8;
  --muted: #93a8ba;
  --accent: #55d6a8;
  --bull: #55d6a8;
  --cow: #f0b429;
  --key: #223140;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  min-height: 0;
}

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.title { font-weight: 700; font-size: 14px; white-space: nowrap; }
.title small { font-weight: 500; color: var(--muted); font-size: 10px; }
.spacer { flex: 1; }
.hud {
  display: flex; align-items: baseline; gap: 5px; font-size: 11px;
  background: var(--panel); padding: 3px 8px; border-radius: 8px;
}
.hud b { font-size: 14px; color: var(--accent); }
.hud .opt { color: var(--muted); }

/* ---- stage: panel + keypad ---- */
.stage-row {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 6px;
}

.panel {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--panel);
  border: 1px solid rgba(85, 214, 168, 0.16);
  border-radius: 10px;
  padding: 6px;
}

/* ---- secret code row ---- */
.secret { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.secret-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.secret-slots { display: flex; gap: 4px; }
.secret-slots span {
  width: 20px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px dashed rgba(147, 168, 186, 0.5);
  color: var(--muted);
  font-weight: 700; font-size: 14px;
}
.secret-slots span.revealed {
  border-style: solid;
  border-color: rgba(85, 214, 168, 0.6);
  color: var(--accent);
}

/* ---- entry slots + last feedback ---- */
.entry { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.slots { display: flex; gap: 4px; }
.slots span {
  width: 26px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid rgba(147, 168, 186, 0.35);
  font-weight: 700; font-size: 17px;
}
.slots span.filled { border-color: var(--accent); color: var(--accent); }
.feedback { color: var(--muted); font-size: 11px; min-height: 14px; }
.feedback b.bull { color: var(--bull); }
.feedback b.cow { color: var(--cow); }

/* ---- guess history ---- */
.history-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.history-head {
  display: flex; gap: 6px; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); flex: 0 0 auto;
}
.history-head span:first-child { flex: 1 1 auto; }
.history-head .opt { width: 38px; text-align: right; }
.history {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.history .row {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(147, 168, 186, 0.12);
}
.history .row .digits { flex: 1 1 auto; letter-spacing: 0.12em; }
.history .row .b { color: var(--bull); }
.history .row .c { color: var(--cow); }
.history .row .count { width: 38px; text-align: right; }
.history .empty { color: var(--muted); font-size: 11px; padding: 4px 0; }

/* ---- keypad ---- */
.keypad {
  flex: 0 0 auto;
  width: 108px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  align-content: stretch;
}
.key {
  appearance: none;
  border: 1px solid rgba(147, 168, 186, 0.25);
  background: var(--key);
  color: var(--ink);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  min-height: 30px;
  cursor: pointer;
  padding: 0;
}
.key:active { background: var(--panel-2); }
.key.wide { font-size: 13px; }
.key.go { background: var(--accent); color: #06251b; border-color: transparent; font-size: 13px; }
.key.go:disabled { background: var(--panel-2); color: var(--muted); }
.key:disabled { opacity: 0.45; cursor: default; }

/* ---- status bar ---- */
#statusbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); padding: 4px 8px; border-radius: 8px;
}
#status { flex: 1 1 auto; font-size: 11px; color: var(--muted); }
.actions { display: flex; gap: 5px; flex: 0 0 auto; }
.btn {
  appearance: none; cursor: pointer;
  border: 1px solid rgba(147, 168, 186, 0.3);
  background: var(--panel-2); color: var(--ink);
  border-radius: 999px; padding: 4px 10px; font-size: 11px;
}
.btn.primary { background: var(--accent); color: #06251b; border-color: transparent; font-weight: 700; }
.btn:active { opacity: 0.8; }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 10, 16, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 20;
}
.modal {
  background: var(--panel);
  border: 1px solid rgba(85, 214, 168, 0.35);
  border-radius: 12px;
  padding: 14px 16px;
  max-width: 420px; width: 100%;
  max-height: 90%;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--ink); }
.modal ul { margin: 0 0 8px; padding-left: 16px; font-size: 12px; line-height: 1.5; }
.modal .code-line { font-size: 22px; font-weight: 700; letter-spacing: 0.2em; color: var(--accent); }
.modal .legend { color: var(--muted); font-size: 11px; }
.modal .legend b.bull { color: var(--bull); }
.modal .legend b.cow { color: var(--cow); }
.modal .actions { margin-top: 10px; justify-content: flex-end; }

#toast {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  background: var(--panel-2); color: var(--ink);
  border: 1px solid rgba(85, 214, 168, 0.35);
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
  opacity: 0; pointer-events: none; transition: opacity 0.15s linear;
  z-index: 30;
}
#toast.show { opacity: 1; }

/* ---- wider stages (desktop): bigger keys, roomier rows ---- */
@media (min-width: 620px) {
  #app { padding: 10px; gap: 8px; }
  .title { font-size: 17px; }
  .secret-slots span { width: 30px; height: 34px; font-size: 18px; }
  .slots span { width: 38px; height: 46px; font-size: 24px; }
  .keypad { width: 190px; gap: 6px; }
  .key { min-height: 44px; font-size: 21px; }
  .key.wide, .key.go { font-size: 16px; }
  .history { font-size: 14px; }
  .feedback, #status { font-size: 13px; }
}
