/* Who Did What? (logic) */
.g-logic { display: flex; flex-direction: column; gap: 12px; max-width: 520px; margin: 0 auto; padding-bottom: 16px; }

.g-logic-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.g-logic-clock { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Story */
.g-logic-story { padding: 12px 16px; }
.g-logic-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 21px; line-height: 1.2; }
.g-logic-intro { margin: 4px 0 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.45; }

/* Clues */
.g-logic-clues { padding: 10px 8px 8px; }
.g-logic-clues-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 8px 4px; }
.g-logic-clues-tip { font-size: 12.5px; }
.g-logic-cluelist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.g-logic-clue {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; min-height: 44px; padding: 8px 8px; text-align: left;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer; font-size: 15px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .15s ease, opacity .2s ease, box-shadow .2s ease;
}
.g-logic-clue:hover { background: var(--surface); }
.g-logic-clue:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.g-logic-clue-n {
  flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent);
}
.g-logic-clue-t { flex: 1; min-width: 0; }
.g-logic-clue.is-struck { opacity: .45; }
.g-logic-clue.is-struck .g-logic-clue-t { text-decoration: line-through; text-decoration-thickness: 2px; }
.g-logic-clue.is-struck .g-logic-clue-n { background: var(--line); color: var(--ink-3); }
.g-logic-clue.is-hint { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold); opacity: 1; }
.g-logic-clue.is-hint .g-logic-clue-n { background: var(--gold); color: var(--card); }

/* Board */
.g-logic-board { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; transition: border-color .3s ease, box-shadow .3s ease; }
.g-logic-board.is-solved { border-color: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }

.g-logic-tabs { display: flex; gap: 6px; }
.g-logic-tab {
  position: relative; flex: 1; min-width: 0; min-height: 48px; padding: 4px 6px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; gap: 5px; font-weight: 700; font-size: 14px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.g-logic-tab:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.g-logic-tab.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.g-logic-tab-e { font-size: 17px; line-height: 1; }
.g-logic-tab-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-logic-tab-n { font-family: var(--font-mono); font-size: 11px; font-weight: 700; opacity: .7; }
.g-logic-tab-n.is-full { color: var(--ok); opacity: 1; }
.g-logic-tab.is-on .g-logic-tab-n.is-full { color: var(--ok); }
.g-logic-tab-bad {
  position: absolute; top: -7px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--bad); color: var(--card); font-family: var(--font-mono); font-size: 11px; line-height: 20px; text-align: center;
}

.g-logic-grid {
  display: grid; grid-template-columns: minmax(58px, 84px) repeat(var(--n, 4), minmax(44px, 1fr)); gap: 5px;
  user-select: none; -webkit-user-select: none;
}
.g-logic-corner { min-height: 0; }
.g-logic-colh {
  display: flex; align-items: flex-end; justify-content: center; text-align: center; padding: 0 1px 2px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-2); line-height: 1.15; overflow-wrap: anywhere; min-width: 0;
}
.g-logic-rowh {
  display: flex; align-items: center; padding-right: 4px; font-weight: 700; font-size: 14.5px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.g-logic-cell {
  min-height: 48px; aspect-ratio: 1 / 0.86; width: 100%; padding: 0; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--card-border); background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 22px; font-weight: 700; line-height: 1;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease, transform .1s ease;
}
.g-logic-cell:active { transform: scale(.94); }
.g-logic-cell:hover { border-color: var(--ink-3); }
.g-logic-cell:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.g-logic-cell.is-x { background: var(--bad-soft); border-color: var(--bad-soft); color: var(--bad); }
.g-logic-cell.is-tick { background: var(--ok); border-color: var(--ok); color: var(--card); box-shadow: 0 0 0 3px var(--ok-soft); }
.g-logic-cell.is-implied { background: var(--surface); color: var(--ink-3); box-shadow: none; border-style: dashed; }
.g-logic-cell.is-wrong { background: var(--bad); border-color: var(--bad); color: var(--card); box-shadow: 0 0 0 3px var(--bad-soft); }
.g-logic-cell.is-locked { cursor: default; pointer-events: none; }
.g-logic-hinted { animation: g-logic-hinted 1.4s ease-out 1; }
@keyframes g-logic-hinted {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--gold); }
  30% { transform: scale(1.12); box-shadow: 0 0 0 8px var(--gold-soft); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 var(--gold-soft); }
}

.g-logic-legend { margin: 0; text-align: center; font-size: 12.5px; color: var(--ink-3); }
.g-logic-legend b { color: var(--ink-2); }

/* "Case closed" stamp */
.g-logic-stamp {
  position: absolute; left: 50%; top: 50%; pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%) rotate(-14deg) scale(2.4);
  padding: 10px 22px; border: 5px double var(--accent); border-radius: 14px; color: var(--accent);
  background: var(--surface); font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.02;
  text-transform: uppercase; letter-spacing: .06em; text-align: center; box-shadow: var(--shadow-lift);
}
.g-logic-board.is-solved .g-logic-stamp { animation: g-logic-stamp .5s cubic-bezier(.2,.8,.2,1.2) .15s forwards; }
@keyframes g-logic-stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(2.4); }
  70% { opacity: 1; transform: translate(-50%, -50%) rotate(-10deg) scale(.94); }
  100% { opacity: .94; transform: translate(-50%, -50%) rotate(-10deg) scale(1); }
}

/* Answer summary */
.g-logic-summary { display: flex; flex-direction: column; gap: 6px; }
.g-logic-sumrow { display: flex; align-items: center; gap: 8px; }
.g-logic-sumname { flex: none; width: 58px; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-logic-sumchips { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.g-logic-sumchip {
  min-height: 44px; padding: 2px 10px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--ok); background: var(--ok-soft); color: var(--ink); white-space: nowrap;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.g-logic-sumchip.is-empty { border: 1.5px dashed var(--line); background: transparent; color: var(--ink-3); }
.g-logic-sumchip.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.g-logic-sumchip:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Messages and actions */
.g-logic-msg {
  margin: 0; min-height: 44px; text-align: center; font-size: 14.5px; color: var(--ink-2); padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
}
.g-logic-msg--bad { color: var(--bad); font-weight: 600; }
.g-logic-msg--good { color: var(--ok); font-weight: 700; font-size: 17px; }
.g-logic-msg--hint {
  color: var(--ink); font-weight: 600; background: var(--gold-soft); border: 1.5px solid var(--gold);
  border-radius: 14px; padding: 8px 12px;
}

.g-logic-actions { display: grid; grid-template-columns: 1fr 1.25fr 1.25fr; gap: 8px; }
.g-logic-actions .btn { min-height: 48px; padding: 0 8px; font-size: 14.5px; white-space: nowrap; }
.g-logic-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
.g-logic-hint { font-variant-numeric: tabular-nums; }
.g-logic-hint:not(:disabled) { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.g-logic-check:not(.is-ready) { opacity: .7; box-shadow: none; }

.g-logic-card { display: flex; flex-direction: column; gap: 10px; align-items: stretch; animation: g-logic-in .3s ease; }
@keyframes g-logic-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.g-logic-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 28px; }
.g-logic-chip { font-family: var(--font-mono); font-size: 13.5px; }
.g-logic-note { margin: 0; text-align: center; color: var(--ink-2); font-size: 14.5px; }

@media (max-width: 380px) {
  .g-logic-tab-n { display: none; }
  .g-logic-grid { gap: 4px; }
  .g-logic-actions .btn { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .g-logic-board.is-solved .g-logic-stamp { opacity: .94; transform: translate(-50%, -50%) rotate(-10deg); }
}
