/* Game surfaces for the Simulatos games. Loaded after hub.css, so it only
   adds board and tile styling; typography, layout and colours come from the hub. */

.gamewrap { padding: 16px; }
.gamebar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.gamebar .stats { min-width: 0; flex: 1 1 240px; }
.gamebar .row { margin: 0; }
.gamebar .btn, .btn.sm { padding: 7px 13px; font-size: 0.86rem; }
.msg { min-height: 1.4em; font-size: 0.9rem; color: var(--muted); margin: 10px 0 0; }
.msg.win { color: var(--ok); font-weight: 500; }
.msg.bad { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.85rem; padding: 7px 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.footnote { font-size: 0.78rem; color: var(--muted); }

/* ------------------------------------------------------------ solitaire */
.deal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.slot { position: relative; border-radius: 7px; border: 1px dashed var(--line); aspect-ratio: 5 / 7; }
.slot.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.column { position: relative; min-height: 64px; }
.column.over .slot { border-color: var(--accent); }
.card {
  position: absolute; left: 0; width: 100%; aspect-ratio: 5 / 7;
  border-radius: 7px; border: 1px solid #cfc9bf; background: #fffdf8; color: #1c1b19;
  padding: 3px 4px; text-align: left; cursor: pointer; overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.12); font: inherit;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 0; transition: box-shadow 0.15s ease, outline-color 0.15s ease;
}
.card .rk { font-size: clamp(0.72rem, 3.1vw, 1rem); line-height: 1.05; font-weight: 600; padding: 2px 0 0 3px; }
.card .su { font-size: clamp(0.85rem, 3.4vw, 1.15rem); line-height: 1; padding: 0 0 2px 3px; }
.card.red { color: #b42318; }
.card.down { background: repeating-linear-gradient(135deg, #2f5d50 0 5px, #295246 5px 10px); border-color: #22453b; }
.card.down::after { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(255,255,255,0.28); border-radius: 4px; }
.card.sel { outline: 3px solid var(--accent); outline-offset: -2px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card.win { animation: pop 0.5s ease both; }
@keyframes pop { 50% { transform: scale(1.12); } }
.slot .hint { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.7rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.slot.stock { cursor: pointer; background: var(--bg); }
.slot.stock.empty::before { content: "↻"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.2rem; color: var(--muted); }
.wastefan { position: absolute; inset: 0; }

/* ------------------------------------------------------------ mahjong */
.mj-outer { display: block; overflow: hidden; }
.mj-board { position: relative; transform-origin: top left; }
.mj-tile {
  position: absolute; width: 40px; height: 50px;
  border-radius: 6px; border: 1px solid #c9c2b4;
  background: linear-gradient(#fffef9, #f3efe4);
  box-shadow: 2px 3px 0 #d8d2c4, 3px 4px 0 #c3bcac;
  color: #2a2925; font: inherit; cursor: pointer; padding: 0;
  display: grid; place-items: center; line-height: 1;
}
.mj-tile .f { display: grid; place-items: center; gap: 1px; }
.mj-tile .n { font-size: 17px; font-weight: 600; }
.mj-tile .s { font-size: 11px; }
.mj-tile .big { font-size: 20px; font-weight: 600; }
.mj-tile.free:hover { border-color: var(--accent); }
.mj-tile.blocked { filter: brightness(0.9); cursor: default; }
.mj-tile.gone { visibility: hidden; pointer-events: none; }
.mj-tile.hint { outline: 3px solid #d97706; }
.mj-tile.sel { outline: 3px solid var(--accent); background: #eef6f2; }
.mj-tile.red { color: #b42318; }
.mj-tile.green { color: #1f6b45; }
.mj-tile.blue { color: #1d4e89; }
.mj-tile:focus-visible { outline: 3px solid var(--accent); }

/* ------------------------------------------------------------ word search */
.ws-board { display: grid; gap: 2px; margin: 0 auto; max-width: 100%; user-select: none; touch-action: none; }
.ws-cell {
  aspect-ratio: 1; display: grid; place-items: center; font: inherit;
  font-size: clamp(0.6rem, 2.5vw, 0.95rem); font-weight: 500; letter-spacing: 0;
  border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--ink);
  cursor: pointer; padding: 0; min-width: 0;
}
.ws-cell:hover { background: var(--bg); }
.ws-cell.sel { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.ws-cell.found { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--muted); }
.ws-cell.found.mark { background: color-mix(in srgb, #d97706 26%, transparent); color: var(--ink); }
.ws-cell:focus-visible { outline: 2px solid var(--accent); }
.ws-words { display: flex; flex-wrap: wrap; gap: 6px 12px; list-style: none; padding: 0; margin: 12px 0 0; font-size: 0.85rem; }
.ws-words li { color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ws-words li.done { color: var(--ink); text-decoration: line-through; }

/* ------------------------------------------------------------ word games */
.answers { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.ch { width: 34px; height: 44px; display: grid; place-items: center; border-bottom: 2px solid var(--line); font-size: 1.2rem; font-weight: 500; text-transform: uppercase; }
.ch.reveal { border-color: var(--ink); }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 8px; }
.ltile { width: 42px; height: 46px; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 1.25rem; font-weight: 500; text-transform: uppercase; }
.kbd { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 16px; }
.kbd button { appearance: none; font: inherit; font-size: 0.85rem; padding: 8px 0; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 6px; cursor: pointer; text-transform: uppercase; }
.kbd button:disabled { opacity: 0.35; cursor: default; }
.kbd button.hit { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.kbd button.miss { background: var(--line); color: var(--muted); text-decoration: line-through; }
.gallows { display: block; margin: 0 auto; width: 180px; height: 140px; }
.ladder { display: grid; gap: 6px; max-width: 320px; margin: 12px auto; }
.ladder .row-word { display: flex; gap: 6px; align-items: center; justify-content: center; }
.ladder .w { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.28em; font-size: 1.05rem; text-transform: uppercase; }
.ladder .arrow { color: var(--muted); font-size: 0.8rem; }

/* ------------------------------------------------------------ 2048 */
.g2048 { position: relative; width: 100%; max-width: 420px; margin: 0 auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; aspect-ratio: 1; padding: 8px; touch-action: none; }
.g2048 .bg, .g2048 .layer2048 { position: absolute; inset: 8px; }
.g2048 .bg { display: grid; gap: 8px; }
.g2048 .bg div { background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 6px; }
.t2 { background: #eee9df; } .t4 { background: #e8e0ce; } .t8 { background: #f0c987; } .t16 { background: #f0b573; }
.t32 { background: #ef9f62; } .t64 { background: #e8794a; } .t128 { background: #d9b34a; } .t256 { background: #d3a233; }
.t512 { background: #c98f22; } .t1024 { background: #b97d18; } .t2048 { background: #a96b10; }
.t4096, .t8192 { background: #7b4b0a; }
.tile2048 { position: absolute; border-radius: 6px; display: grid; place-items: center; font-weight: 600; color: #3a352b; transition: transform 0.11s ease, background 0.11s ease; will-change: transform; font-variant-numeric: tabular-nums; }
.tile2048.hi { color: #fffdf8; }
.tile2048.new { animation: appear 0.16s ease both; }
@keyframes appear { from { opacity: 0; transform: scale(0.6); } }
.tile2048.pop { animation: pop 0.16s ease both; }

/* ------------------------------------------------------------ board games */
.bd { display: grid; gap: 4px; margin: 0 auto; width: 100%; max-width: 420px; }
.bd button { appearance: none; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; cursor: pointer; font: inherit; color: var(--ink); display: grid; place-items: center; padding: 0; }
.bd button:disabled { cursor: default; }
.ttt { grid-template-columns: repeat(3, 1fr); max-width: 300px; }
.ttt button { aspect-ratio: 1; font-size: clamp(2rem, 12vw, 3rem); font-weight: 300; }
.ttt button.x { color: var(--accent); }
.ttt button.o { color: var(--bad); }
.ttt button.win { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.c4 { grid-template-columns: repeat(7, 1fr); max-width: 400px; gap: 5px; }
.c4 .col { display: grid; gap: 5px; background: transparent; border: 0; padding: 0; }
.c4 .cell { aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.c4 .cell.r { background: var(--bad); border-color: var(--bad); }
.c4 .cell.y { background: #d9a520; border-color: #d9a520; }
.c4 .cell.r.win, .c4 .cell.y.win { outline: 3px solid var(--ink); outline-offset: -3px; }
.c4 .col:hover .cell:not(.r):not(.y):last-of-type { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chk { grid-template-columns: repeat(8, 1fr); max-width: 400px; gap: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.chk button { aspect-ratio: 1; border: 0; border-radius: 0; }
.chk .dark { background: #6b6357; }
.chk .light { background: #efe9dd; }
.chk .piece { width: 66%; height: 66%; border-radius: 50%; background: #f7f3ea; border: 2px solid #4a443b; }
.chk .piece.w { background: #fbf8f0; }
.chk .piece.b { background: #2f2c27; border-color: #111; }
.chk .piece.king::after { content: "♔"; color: #b42318; font-size: 0.8rem; position: absolute; }
.chk button { position: relative; }
.chk .piece.king { position: relative; display: grid; place-items: center; color: #b42318; font-size: 0.85rem; }
.chk button.sel { outline: inset 0 0 0 3px var(--accent); }
.chk button.mv::before { content: ""; width: 30%; height: 30%; border-radius: 50%; background: color-mix(in srgb, var(--accent) 55%, transparent); position: absolute; }
.chk button.cap::before { width: 72%; height: 72%; border: 3px solid var(--bad); background: transparent; border-radius: 50%; position: absolute; }
.rv { grid-template-columns: repeat(8, 1fr); max-width: 400px; gap: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.rv button { aspect-ratio: 1; border: 0; border-radius: 0; background: #4b7a5a; padding: 0; position: relative; }
.rv button .d { width: 78%; height: 78%; border-radius: 50%; display: grid; place-items: center; }
.rv .b .d { background: #26241f; }
.rv .w .d { background: #fbf8f0; border: 1px solid #c9c2b4; }
.rv .mv::after { content: ""; width: 22%; height: 22%; border-radius: 50%; background: rgba(255,255,255,0.45); position: absolute; }
.rv .last { outline: 2px solid #d9a520; outline-offset: -2px; }

/* ------------------------------------------------------------ quiz */
.quiz-q { font-size: 1.1rem; font-weight: 500; margin: 6px 0 14px; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; padding: 11px 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; font: inherit; cursor: pointer; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.dots { display: flex; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.ok { background: var(--ok); } .dot.no { background: var(--bad); } .dot.now { background: var(--accent); }

/* ------------------------------------------------------------ print */
@media print {
  header.site, footer.site, .nav, .crumbs, .below, .related, .gamebar, .no-print, .content h2:first-of-type { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .tool { border: 0; padding: 0; }
  .ws-board { gap: 0; max-width: 100%; }
  .ws-cell { border: 1px solid #ddd; font-size: 11pt; color: #000; }
  .ws-cell.found { background: transparent; color: #000; }
  .ws-cell.mark { background: #ffe9a8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ws-words { font-size: 11pt; }
  .ws-words li { color: #000; }
  .lede, .msg, .print-note { display: none; }
}
@media (max-width: 620px) {
  .gamewrap { padding: 12px; }
  .kbd { grid-template-columns: repeat(7, 1fr); }
  .mj-tile .n { font-size: 15px; }
  .gamebar { align-items: stretch; }
  .gamebar .stats { flex: 1 1 100%; max-width: none; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
}
