:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #5b616b;
  --line: #e2ddd3;
  --accent: #2f6f5e;
  --accent-soft: #e3f1ec;
  --radius: 12px;
  --max: 1040px;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--accent); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.nav { display: flex; gap: 18px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--text); font-weight: 500; }
.nav a:hover { color: var(--accent); }

main { padding: 28px 0 48px; }
h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 10px; }
h2 { font-size: 1.4rem; margin: 32px 0 10px; }
h3 { font-size: 1.1rem; margin: 20px 0 6px; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 24px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.game-card { display: block; text-decoration: none; color: var(--text); transition: border-color .15s; }
.game-card:hover { border-color: var(--accent); }
.game-card h3 { margin: 6px 0; }
.game-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.soon { background: #eee9de; color: var(--muted); }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 10px; padding: 10px 18px; cursor: pointer; }
.btn.ghost { background: var(--card); color: var(--accent); }
.btn:focus-visible, select:focus-visible { outline: 3px solid #9fd3c3; outline-offset: 2px; }
select { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }

.ad-slot { margin: 24px 0; min-height: 0; }
.ad-slot:empty { display: none; }

.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.faq summary { font-weight: 600; cursor: pointer; }

.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 24px 0; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* Word search */
.ws-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.ws-status { display: flex; gap: 18px; flex-wrap: wrap; font-weight: 600; margin-bottom: 12px; }
.ws-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; align-items: start; }
.ws-grid { display: grid; gap: 2px; user-select: none; -webkit-user-select: none; touch-action: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.ws-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: clamp(14px, 3.2vw, 24px); border-radius: 6px; cursor: pointer; text-transform: uppercase; }
.ws-cell.sel { background: #ffd86b; }
.ws-cell.found { color: #fff; }
.ws-words { list-style: none; margin: 0; padding: 0; columns: 1; }
.ws-words li { padding: 4px 0; font-weight: 600; letter-spacing: .03em; }
.ws-words li.done { text-decoration: line-through; color: var(--muted); }
.ws-win { display: none; margin: 16px 0; padding: 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ws-win.show { display: block; }

@media (max-width: 760px) {
  html { font-size: 17px; }
  .ws-layout { grid-template-columns: 1fr; }
  .ws-words { columns: 2; }
  h1 { font-size: 1.6rem; }
}
@media print {
  .site-header, .site-footer, .ws-controls, .ad-slot, .no-print, .ws-status { display: none !important; }
  body { background: #fff; }
  .ws-cell.found { color: inherit; background: none !important; }
}
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* Solitaire */
.sol-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.sol-board { --cw: 80px; --gap: 8px; background: #2f6f4f; border-radius: var(--radius); padding: 12px; touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
.sol-top, .sol-tab { display: grid; gap: var(--gap); justify-content: center; }
.sol-top { margin-bottom: 14px; }
.sol-board .pile { position: relative; width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: 8px; border: 2px dashed rgba(255,255,255,.28); }
.sol-board .pile.tab { border-color: rgba(255,255,255,.16); min-height: calc(var(--cw) * 1.4); }
.sol-board .pile.found::after { content: "A"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.35); font-weight: 700; font-size: calc(var(--cw) * .35); }
.sol-board .pile.found.mini::after { content: ""; }
.sol-board .pile.found:has(.card-wrap)::after { content: none; }
.sol-board .pile.cell { border-style: solid; border-color: rgba(255,255,255,.22); }
.sol-board .spacer { width: var(--cw); }
.sol-board .count { position: absolute; bottom: -2px; right: 4px; color: #fff; font-size: 12px; font-weight: 700; }
.sol-board .redeal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.6); font-size: calc(var(--cw) * .45); cursor: pointer; }
.card-wrap { position: absolute; left: 0; width: var(--cw); }
.card { width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.35); cursor: pointer; position: relative; }
.card.back { background: #b8423a repeating-linear-gradient(45deg, rgba(255,255,255,.14) 0 4px, transparent 4px 8px); border: 3px solid #fff; }
.card.face { background: #fff; color: #1a1a1a; border: 1px solid #c9c4b8; }
.card.face.red { color: #c0262d; }
.card .ci { position: absolute; top: 3px; left: 5px; font-weight: 800; line-height: 1; font-size: calc(var(--cw) * .27); }
.card .cm { position: absolute; bottom: 4px; right: 6px; font-size: calc(var(--cw) * .42); line-height: 1; }
.card-wrap.sel .card { outline: 3px solid #ffd84a; outline-offset: -1px; }
.sol-ghost { position: absolute; z-index: 50; pointer-events: none; width: var(--cw); }
.sol-ghost .card-wrap { position: absolute; }
.sol-msg { display: none; margin: 12px 0; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sol-msg.show { display: block; }
.btn:disabled { opacity: .45; cursor: default; }
@media (max-width: 600px) { .sol-board { padding: 6px; } .card .ci { font-size: calc(var(--cw) * .32); } }

/* Shared */
.muted { color: var(--muted); }
.toast { position: fixed; left: 50%; top: 80px; transform: translateX(-50%); background: #1f2328; color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; }
.toast.show { opacity: 1; }
.game-msg { display: none; margin: 14px 0; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.game-msg.show { display: block; }
.btn.on { background: var(--accent); color: #fff; }
.center { max-width: 520px; margin: 0 auto; }
.section-title { display: flex; align-items: center; gap: 10px; }
.more-games { margin-top: 40px; }
.today { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 8px; }
.today .card { background: var(--accent); color: #fff; border: 0; }
.today .card p { color: #d9efe7; }
.today .badge { background: #fff; color: var(--accent); }
.icon { font-size: 1.8rem; line-height: 1; }

/* Daily word */
.wg-board { display: grid; gap: 6px; max-width: 330px; margin: 0 auto 18px; }
.wg-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wg-row.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.wg-tile { aspect-ratio: 1; border: 2px solid var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1.9rem; font-weight: 800; text-transform: uppercase; background: var(--card); }
.wg-tile.filled { border-color: #8a8f98; }
.wg-tile.correct, .wg-key.correct { background: #4c9a5f; border-color: #4c9a5f; color: #fff; }
.wg-tile.present, .wg-key.present { background: #c9a227; border-color: #c9a227; color: #fff; }
.wg-tile.absent, .wg-key.absent { background: #7b8088; border-color: #7b8088; color: #fff; }
.wg-kb { max-width: 520px; margin: 0 auto; }
.wg-krow { display: flex; justify-content: center; gap: 5px; margin-bottom: 6px; }
.wg-key { flex: 1; min-width: 0; height: 54px; border: 0; border-radius: 6px; background: #dcd8cf; font: inherit; font-weight: 700; text-transform: uppercase; cursor: pointer; color: var(--text); }
.wg-key.wide { flex: 1.6; font-size: .8rem; }
.wg-result { display: none; max-width: 520px; margin: 18px auto; }
.wg-result.show { display: block; }
.wg-result h2 { margin-top: 0; text-align: center; }
.wg-stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 8px; margin-bottom: 14px; font-size: .85rem; }
.wg-stats b { display: block; font-size: 1.6rem; }
.wg-dist div { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.wg-dist i { display: block; background: #7b8088; color: #fff; font-style: normal; font-weight: 700; padding: 0 8px; text-align: right; border-radius: 3px; }
.wg-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }

/* Sudoku */
.sd-wrap { display: grid; grid-template-columns: minmax(0, 480px) 240px; gap: 20px; justify-content: center; align-items: start; }
.sd-grid { display: grid; grid-template-columns: repeat(9, 1fr); border: 3px solid #1f2328; background: var(--card); user-select: none; }
.sd-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: clamp(18px, 4.6vw, 28px); font-weight: 600; color: #2f5fb0; border-right: 1px solid #c8c3b8; border-bottom: 1px solid #c8c3b8; cursor: pointer; position: relative; }
.sd-cell.given { color: #1f2328; font-weight: 700; }
.sd-cell.br { border-right: 3px solid #1f2328; }
.sd-cell.bb { border-bottom: 3px solid #1f2328; }
.sd-cell.peer { background: #eef1f5; }
.sd-cell.same { background: #d5e3f7; }
.sd-cell.sel { background: #bcd3f5; }
.sd-cell.wrong { color: #c0262d; }
.sd-notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; font-size: clamp(8px, 1.6vw, 11px); color: var(--muted); font-weight: 500; }
.sd-notes span { display: flex; align-items: center; justify-content: center; }
.sd-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.sd-pad button { height: 58px; font-size: 1.5rem; font-weight: 700; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: #2f5fb0; cursor: pointer; }
.sd-pad button.used { opacity: .3; }
.sd-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* 2048 */
.t-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.t-box { background: #bbada0; color: #fff; border-radius: 8px; padding: 6px 14px; text-align: center; font-size: .8rem; font-weight: 700; }
.t-box b { display: block; font-size: 1.3rem; }
.t-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: #bbada0; padding: 10px; border-radius: 10px; max-width: 440px; touch-action: none; user-select: none; }
.t-cell { aspect-ratio: 1; background: #cdc1b4; border-radius: 6px; }
.t-tile { width: 100%; height: 100%; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: clamp(20px, 7vw, 40px); color: #776e65; }
.t-tile.pop { animation: pop .18s; }
@keyframes pop { from { transform: scale(.5); } }
.t-tile.v2 { background: #eee4da; } .t-tile.v4 { background: #ede0c8; }
.t-tile.v8 { background: #f2b179; color: #fff; } .t-tile.v16 { background: #f59563; color: #fff; }
.t-tile.v32 { background: #f67c5f; color: #fff; } .t-tile.v64 { background: #f65e3b; color: #fff; }
.t-tile.v128 { background: #edcf72; color: #fff; font-size: clamp(18px, 6vw, 34px); } .t-tile.v256 { background: #edcc61; color: #fff; font-size: clamp(18px, 6vw, 34px); }
.t-tile.v512 { background: #edc850; color: #fff; font-size: clamp(18px, 6vw, 34px); } .t-tile.v1024 { background: #edc53f; color: #fff; font-size: clamp(14px, 5vw, 28px); }
.t-tile.v2048, .t-tile.v4096 { background: #edc22e; color: #fff; font-size: clamp(14px, 5vw, 28px); }
.t-arrows { display: none; grid-template-columns: repeat(3, 56px); gap: 6px; justify-content: center; margin-top: 12px; }
.t-arrows button { height: 48px; font-size: 1.3rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }

/* Minesweeper */
.ms-scroll { overflow-x: auto; padding-bottom: 6px; }
.ms-grid { --ms: 32px; display: grid; gap: 2px; width: max-content; background: #9aa1a9; padding: 4px; border-radius: 8px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ms-cell { width: var(--ms); height: var(--ms); border: 0; border-radius: 3px; background: #c9ced4; font: inherit; font-weight: 800; font-size: 17px; cursor: pointer; padding: 0; color: #1f2328; }
.ms-cell.open { background: #eef0f2; cursor: default; }
.ms-cell.flag { color: #c0262d; }
.ms-cell.mine { background: #e05a4f; }
.ms-cell.reveal { color: #1f2328; }
.ms-cell.n1 { color: #2f5fb0; } .ms-cell.n2 { color: #3b7d3b; } .ms-cell.n3 { color: #c0262d; } .ms-cell.n4 { color: #2b2f7a; }
.ms-cell.n5 { color: #7a2b2b; } .ms-cell.n6 { color: #2b7a7a; } .ms-cell.n7 { color: #1f2328; } .ms-cell.n8 { color: #6b6f76; }

/* Mahjong */
.mj-board { position: relative; background: #2f6f4f; border-radius: var(--radius); margin-bottom: 8px; --tw: 56px; overflow: hidden; }
.mj-tile { position: absolute; border: 1px solid #b9ab8f; border-radius: 6px; background: #f8f3e6; box-shadow: 3px 3px 0 #c9b98f, 4px 4px 0 #8b7a55; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: inherit; color: #1f2328; filter: brightness(.82); }
.mj-tile.free { filter: none; }
.mj-tile b { font-size: calc(var(--tw) * .42); line-height: 1; }
.mj-tile small { font-size: calc(var(--tw) * .22); line-height: 1.1; }
.mj-tile.dot b { color: #2f5fb0; } .mj-tile.dot small { color: #c0262d; }
.mj-tile.bam b { color: #2e7d32; } .mj-tile.bam small { color: #2e7d32; }
.mj-tile.chr b { color: #1f2328; } .mj-tile.chr small { color: #c0262d; }
.mj-tile.wind b { color: #1f2328; } .mj-tile.drg.red b { color: #c0262d; } .mj-tile.drg.grn b { color: #2e7d32; } .mj-tile.drg.wht b { color: #2f5fb0; }
.mj-tile.sel { background: #ffe58a; filter: none; }
.mj-tile.hint { background: #bfe6cf; }

@media (max-width: 760px) {
  .sd-wrap { grid-template-columns: 1fr; }
  .t-arrows { display: grid; }
  .ms-grid { --ms: 30px; }
}
@media (max-width: 600px) {
  .nav { flex-wrap: nowrap; overflow-x: auto; gap: 14px; width: 100%; padding-bottom: 2px; }
  .nav a { white-space: nowrap; }
}
