/* Budi Games — folha de estilo unica.
   Todas as cores ficam nas variaveis abaixo: para um reskin completo,
   altere apenas o bloco :root (e o [data-theme="dark"] logo em seguida).

   Identidade: papel. Fundo creme, verde-petroleo como marca, ambar como
   acento, titulos em serifa e cantos bem arredondados. */

:root {
  /* superficies */
  --bg: #f7f4ec;
  --bg-soft: #efe9dc;
  --surface: #fffdf8;
  --surface-2: #f6f2e8;
  --border: #e2dbc9;
  --border-strong: #cabfa6;

  /* texto */
  --text: #221d17;
  --text-soft: #524839;
  --text-mute: #83786a;

  /* marca */
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #dcf0ec;
  --accent: #b45309;
  --accent-soft: #fbecd6;
  --gold: #ca8a04;
  --mint: #2f9e6f;
  --sky: #0e7490;

  /* estado */
  --ok: #15803d;
  --ok-soft: #e2f4e4;
  --warn: #a16207;
  --warn-soft: #faf0d7;
  --danger: #b91c1c;

  /* cores usadas pelos jogos (lidas tambem pelo JS via getComputedStyle) */
  --tile-1: #e8f2ec;
  --tile-2: #d3e8de;
  --tile-3: #aed6c8;
  --tile-4: #7fbfae;
  --tile-5: #4c9f8d;
  --tile-6: #0f766e;
  --tile-7: #b45309;
  --tile-8: #ca8a04;
  --board: #ece5d5;
  --board-line: #d5cab2;

  /* forma e ritmo */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow: 0 1px 2px rgba(34, 29, 23, .05), 0 8px 22px rgba(34, 29, 23, .07);
  --shadow-lg: 0 18px 46px rgba(34, 29, 23, .16);
  --ring: 0 0 0 3px rgba(15, 118, 110, .3);
  --max: 1120px;
  --gap: 24px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #14120e;
  --bg-soft: #1b1813;
  --surface: #211d17;
  --surface-2: #2a251d;
  --border: #383126;
  --border-strong: #4d4433;

  --text: #f4efe4;
  --text-soft: #ccc2b0;
  --text-mute: #9c9282;

  --brand: #5eead4;
  --brand-strong: #99f6e4;
  --brand-soft: #13332f;
  --accent: #fbbf24;
  --accent-soft: #3a2c10;
  --gold: #facc15;
  --mint: #4ade80;
  --sky: #38bdf8;

  --ok: #4ade80;
  --ok-soft: #14301d;
  --warn: #facc15;
  --warn-soft: #362b0f;
  --danger: #fca5a5;

  --tile-1: #21332f;
  --tile-2: #26433c;
  --tile-3: #2c5a4f;
  --tile-4: #337466;
  --tile-5: #3f9c88;
  --tile-6: #5eead4;
  --tile-7: #fbbf24;
  --tile-8: #facc15;
  --board: #1e1b15;
  --board-line: #342e23;

  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 26px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 54px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(94, 234, 212, .38);
}

/* ---------------------------------------------------------------- base ---- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 460px;
  background:
    radial-gradient(60% 100% at 12% 0%, rgba(79, 70, 229, .16), transparent 70%),
    radial-gradient(50% 100% at 88% 6%, rgba(240, 53, 110, .13), transparent 72%);
  pointer-events: none;
  z-index: 0;
}

img, svg, canvas { max-width: 100%; }
canvas { display: block; touch-action: none; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; letter-spacing: -.015em; }
h1 { font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.85rem); }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.85rem); }
h3 { font-size: 1.18rem; }
p { margin: 0 0 1.05em; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 60;
  background: var(--surface);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.skip:focus { left: 12px; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; position: relative; z-index: 1; }
.narrow { max-width: 760px; }

/* ------------------------------------------------------------- topbar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.bar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.06rem;
  color: var(--text);
  letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand .logo { width: 32px; height: 32px; flex: none; border-radius: 9px; }
.brand small {
  display: block;
  font-weight: 500;
  font-size: .705rem;
  color: var(--text-mute);
  letter-spacing: 0;
  line-height: 1.3;
}

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a {
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: .94rem;
  font-weight: 600;
}
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 11px;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 19px; height: 19px; }
.burger { display: none; }

[data-theme="dark"] .sun, .moon { display: none; }
[data-theme="dark"] .moon { display: block; }

@media (max-width: 860px) {
  .burger { display: grid; }
  .brand small { display: none; }
  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 16px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 14px; border-radius: var(--radius-sm); }
}

/* --------------------------------------------------------------- hero ---- */

main { flex: 1 0 auto; position: relative; z-index: 1; }

.hero { padding: 52px 0 30px; }
.hero p.lede { font-size: 1.13rem; color: var(--text-soft); max-width: 62ch; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--brand-strong);
  background: var(--brand-soft);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: .96rem;
  cursor: pointer;
}
.btn:hover { background: var(--brand-strong); color: #fff; text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 8px 15px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* -------------------------------------------------------------- cards ---- */

section { padding: 30px 0; }
.section-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.section-head p { margin: 4px 0 0; color: var(--text-soft); font-size: .97rem; }
.section-head .count { margin-left: auto; color: var(--text-mute); font-size: .88rem; white-space: nowrap; }

.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
a.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  text-decoration: none;
  color: inherit;
}
.card h3 { margin: 0; font-size: 1.08rem; }
.card p { margin: 0; color: var(--text-soft); font-size: .93rem; line-height: 1.55; }
.card .thumb {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 1.35rem;
  font-weight: 800;
}
.card .meta { margin-top: auto; padding-top: 6px; color: var(--text-mute); font-size: .82rem; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: .76rem;
  font-weight: 600;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* --------------------------------------------------------------- game ---- */

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 0 0 26px;
}
.stage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.stage-head .spacer { margin-left: auto; }

.scores { display: flex; flex-wrap: wrap; gap: 10px; }
.score {
  min-width: 84px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.score b { display: block; font-size: 1.22rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.score span { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mute); }

.board-wrap { display: flex; justify-content: center; }
.status {
  min-height: 1.6em;
  margin: 14px 0 0;
  text-align: center;
  font-weight: 600;
  color: var(--text-soft);
}
.status.win { color: var(--ok); }
.status.lose { color: var(--danger); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; }
.controls label { font-size: .9rem; color: var(--text-soft); font-weight: 600; }

select, input[type="text"], input[type="email"], input[type="number"], textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 150px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0;
  background: none;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-soft);
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }

.hint { color: var(--text-mute); font-size: .86rem; text-align: center; margin: 10px 0 0; }
.keys { font-family: var(--mono); font-size: .82em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }

/* -------------------------------------------------------------- prose ---- */

.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.7em; }
.prose h3 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.15em; }
.prose li { margin-bottom: .5em; }
.prose li::marker { color: var(--brand); }
.prose strong { color: var(--text); }

.byline { color: var(--text-mute); font-size: .88rem; margin: -4px 0 22px; }

.breadcrumb { font-size: .87rem; color: var(--text-mute); padding: 22px 0 0; }
.breadcrumb a { color: var(--text-soft); }

.callout {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  margin: 0 0 1.3em;
  font-size: .95rem;
  color: var(--text-soft);
}
.callout.estimate { border-left-color: var(--gold); }
.callout p:last-child { margin-bottom: 0; }

.faq { margin: 1.4em 0; }
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 16px;
  margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--brand); font-weight: 700; }
.faq details[open] summary::after { content: "\2013"; }
.faq details > p:last-child { margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; margin: 0 0 1.3em; font-size: .94rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-mute); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }

.next-read { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--border); }

/* --------------------------------------------------------------- form ---- */

.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .92rem; }
.field .help { color: var(--text-mute); font-size: .83rem; }
.field.full { grid-column: 1 / -1; }

.notice { padding: 14px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: .95rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.bad { background: var(--accent-soft); color: var(--danger); }

/* ------------------------------------------------------------- footer ---- */

.footer {
  margin-top: 56px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 0 28px;
  font-size: .92rem;
  color: var(--text-soft);
  position: relative;
  z-index: 1;
}
.footer h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-mute); margin-bottom: 12px; }
.footer .cols { display: grid; gap: 28px; grid-template-columns: 1.4fr repeat(3, 1fr); }
.footer ul { list-style: none; margin: 0; padding: 0; }
.footer li { margin-bottom: 8px; }
.footer a { color: var(--text-soft); }
.footer a:hover { color: var(--brand); }
.footer .legal {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  font-size: .86rem;
  color: var(--text-mute);
}
.footer .legal .sep { margin-left: auto; }
.disclaimer { margin: 14px 0 0; font-size: .84rem; color: var(--text-mute); max-width: 90ch; }

@media (max-width: 760px) {
  .footer .cols { grid-template-columns: 1fr 1fr; }
  .hero { padding: 34px 0 22px; }
  body { font-size: 16.5px; }
  .stage { padding: 15px; border-radius: var(--radius); }
}

/* --------------------------------------------------- jogos: 2048 ------- */

.g2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  width: min(420px, 100%);
  aspect-ratio: 1 / 1;
  padding: 9px;
  background: var(--board);
  border-radius: var(--radius);
  outline: none;
}
.g2048 .tile {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: clamp(1.1rem, 4.6vw, 1.9rem);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: background-color .11s ease, color .11s ease;
}
.g2048 .tile.small { font-size: clamp(.95rem, 3.7vw, 1.5rem); }
.g2048 .tile.tiny { font-size: clamp(.8rem, 3vw, 1.15rem); }
.g2048 .tile.v2 { background: var(--tile-1); }
.g2048 .tile.v4 { background: var(--tile-2); }
.g2048 .tile.v8 { background: var(--tile-3); }
.g2048 .tile.v16 { background: var(--tile-4); color: #fff; }
.g2048 .tile.v32 { background: var(--tile-5); color: #fff; }
.g2048 .tile.v64 { background: var(--tile-6); color: #fff; }
.g2048 .tile.v128 { background: var(--sky); color: #fff; }
.g2048 .tile.v256 { background: var(--mint); color: #fff; }
.g2048 .tile.v512 { background: var(--tile-8); color: #23201a; }
.g2048 .tile.v1024 { background: var(--tile-7); color: #fff; }
.g2048 .tile.v2048,
.g2048 .tile.v4096 { background: var(--text); color: var(--bg); }
.g2048 .tile.pop { animation: pop .16s ease-out; }

@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }

/* ----------------------------------------------- jogos: minesweeper ---- */

.ms-board {
  display: grid;
  gap: 3px;
  padding: 8px;
  background: var(--board);
  border-radius: var(--radius-sm);
  max-width: 100%;
  overflow: auto;
}
.ms-cell {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 5px;
  background: var(--border-strong);
  font: inherit;
  font-weight: 800;
  font-size: .92rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  user-select: none;
}
.ms-cell:hover:not(.open) { background: var(--brand-soft); }
.ms-cell.open { background: var(--surface-2); cursor: default; }
.ms-cell.flag { background: var(--warn-soft); }
.ms-cell.boom { background: var(--accent); color: #fff; }
.ms-cell.n1 { color: var(--sky); }
.ms-cell.n2 { color: var(--ok); }
.ms-cell.n3 { color: var(--accent); }
.ms-cell.n4 { color: var(--brand); }
.ms-cell.n5 { color: var(--warn); }
.ms-cell.n6 { color: #0d9488; }
.ms-cell.n7 { color: var(--text); }
.ms-cell.n8 { color: var(--text-mute); }

@media (max-width: 560px) {
  .ms-cell { width: 26px; height: 26px; font-size: .84rem; }
}

/* --------------------------------------------------- jogos: sudoku ----- */

.sudoku {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(460px, 100%);
  aspect-ratio: 1 / 1;
  background: var(--board-line);
  border: 2px solid var(--text-soft);
  border-radius: 8px;
  overflow: hidden;
}
.sd-cell {
  border: 0;
  background: var(--surface);
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  font-size: clamp(.95rem, 3.4vw, 1.35rem);
  text-align: center;
  padding: 0;
  outline: none;
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  -moz-appearance: textfield;
}
.sd-cell::-webkit-outer-spin-button,
.sd-cell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sd-cell:focus { background: var(--brand-soft); }
.sd-cell.fixed { color: var(--text); background: var(--surface-2); font-weight: 800; }
.sd-cell.bad { background: var(--accent-soft); color: var(--danger); }
.sd-cell.col3 { border-right: 2px solid var(--text-soft); }
.sd-cell.row3 { border-bottom: 2px solid var(--text-soft); }

/* -------------------------------------------- jogos: sliding puzzle ---- */

.slide-board {
  display: grid;
  gap: 7px;
  width: min(420px, 100%);
  aspect-ratio: 1 / 1;
  padding: 7px;
  background: var(--board);
  border-radius: var(--radius);
}
.sl-tile {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: clamp(1rem, 4vw, 1.6rem);
  cursor: pointer;
  padding: 0;
  transition: transform .08s ease;
}
.sl-tile:hover { transform: scale(1.03); }
.sl-tile.blank { background: transparent; cursor: default; }
.sl-tile.blank:hover { transform: none; }
.sl-tile.home { background: var(--mint); }

/* --------------------------------------------- jogos: memory match ---- */

.mem-grid { display: grid; gap: 10px; width: min(520px, 100%); }
.mem-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  cursor: pointer;
  font-size: clamp(1.3rem, 5vw, 2rem);
  display: grid;
  place-items: center;
  color: transparent;
}
.mem-card::after {
  content: "?";
  position: absolute;
  color: rgba(255, 255, 255, .7);
  font-weight: 800;
  font-size: 1.2rem;
}
.mem-card.up, .mem-card.done { background: var(--surface-2); color: var(--text); }
.mem-card.up::after, .mem-card.done::after { content: none; }
.mem-card.done { background: var(--ok-soft); cursor: default; opacity: .75; }

/* -------------------------------------------------- jogos: simon ------ */

.simon {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: min(360px, 100%);
  aspect-ratio: 1 / 1;
}
.simon-pad {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  opacity: .45;
  transition: opacity .1s ease, transform .1s ease;
}
.simon-pad.lit, .simon-pad:active { opacity: 1; transform: scale(1.02); }
.simon-pad[data-pad="0"] { background: var(--mint); }
.simon-pad[data-pad="1"] { background: var(--accent); }
.simon-pad[data-pad="2"] { background: var(--sky); }
.simon-pad[data-pad="3"] { background: var(--gold); }

/* -------------------------------------------- jogos: connect four ----- */

.c4-wrap { display: inline-block; max-width: 100%; }
.c4-drop { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.c4-drop button {
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: 7px;
  padding: 4px 0;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}
.c4-drop button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.c4-drop button:disabled { opacity: .35; cursor: not-allowed; }
.c4 {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 8px;
  background: var(--brand);
  border-radius: var(--radius);
  width: min(440px, 100%);
}
.c4 .slot { aspect-ratio: 1 / 1; border-radius: 50%; background: var(--bg); }
.c4 .slot.p1 { background: var(--accent); }
.c4 .slot.p2 { background: var(--gold); }
.c4 .slot.line { box-shadow: 0 0 0 3px var(--text) inset; }

/* ------------------------------------------- jogos: reaction time ----- */

.rt-pad {
  width: 100%;
  min-height: 260px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}
.rt-pad.wait { background: var(--warn-soft); color: var(--warn); }
.rt-pad.go { background: var(--ok); color: #fff; }
.rt-pad.early { background: var(--accent-soft); color: var(--danger); }
.rt-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.rt-list span {
  padding: 5px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-size: .88rem;
}

/* --------------------------------------------------- canvas frames ---- */

.canvas-frame {
  background: var(--board);
  border-radius: var(--radius);
  padding: 8px;
  display: inline-block;
  max-width: 100%;
}
.canvas-frame canvas { border-radius: var(--radius-sm); width: 100%; height: auto; }

/* ------------------------------------------------------- utilitarios ---- */

.center { text-align: center; }
.mt0 { margin-top: 0; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* ------------------------------------------------------ identidade Budi ---- */
/* Papel: titulos em serifa, colunas de leitura mais estreitas, tudo
   arredondado e um degrade quente no topo da pagina. */

h1, h2, h3, h4,
.card h3 { font-family: var(--font-display); letter-spacing: 0; }
.hero { padding: 44px 0 26px; }
.hero p.lede { font-size: 1.09rem; max-width: 58ch; }
.prose { max-width: 68ch; }
.eyebrow { letter-spacing: .06em; font-size: .78rem; }
.card .thumb { border-radius: 50%; }
body {
  background-image: linear-gradient(180deg, var(--bg-soft) 0, var(--bg) 320px);
  background-repeat: no-repeat;
}

/* --------------------------------------------- jogos: crate push ------ */
/* Sokoban em grade de divs. Caixa, alvo e jogador sao pseudo-elementos
   pintados com as variaveis do tema: nenhuma imagem, e o modo escuro
   sai de graca. */

.cp-board {
  display: grid;
  gap: 2px;
  width: 100%;
  margin: 0 auto;
  padding: 8px;
  background: var(--board);
  border-radius: var(--radius);
  touch-action: none;
}
.cp-board:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.cp-cell { position: relative; aspect-ratio: 1 / 1; border-radius: 4px; }
.cp-cell.floor { background: var(--surface-2); }
.cp-cell.wall { background: var(--border-strong); }
.cp-cell.goal::before {
  content: "";
  position: absolute;
  inset: 33%;
  border-radius: 50%;
  background: var(--brand);
  opacity: .6;
}
.cp-cell.crate::after {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 5px;
  background: var(--accent);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .14);
}
.cp-cell.crate.set::after { background: var(--mint); }
.cp-cell.you::after {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  background: var(--brand-strong);
  box-shadow: 0 0 0 2px var(--surface);
}
.cp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.cp-legend li { display: inline-flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--text-mute); }
.cp-legend i { width: 15px; height: 15px; display: inline-block; border-radius: 4px; }
.cp-legend i.crate { background: var(--accent); }
.cp-legend i.set { background: var(--mint); }
.cp-legend i.mark { background: var(--brand); opacity: .6; border-radius: 50%; }
.cp-legend i.you { background: var(--brand-strong); border-radius: 50%; }

/* -------------------------------------------- jogos: tower of hanoi ---- */
/* Cada haste e um botao: recebe foco, clique e ponteiro. Os discos sao
   spans com largura em porcentagem, empilhados de baixo para cima com
   column-reverse. O fantasma do arraste vive no body, fora da grade. */

.hanoi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(560px, 100%);
  touch-action: none;
}
.hanoi-peg {
  position: relative;
  height: clamp(190px, 40vw, 250px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--board);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}
.hanoi-peg.sel { border-color: var(--brand); box-shadow: var(--ring); }
.hanoi-post {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 8px;
  height: calc(100% - 24px);
  margin-left: -4px;
  border-radius: 4px;
  background: var(--board-line);
}
.hanoi-base {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 6px;
  height: 8px;
  border-radius: 4px;
  background: var(--border-strong);
}
.hanoi-stack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 2px;
}
.hanoi-disk {
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(13px, 2.7vw, 20px);
  border-radius: 999px;
  color: var(--text);
  font-size: clamp(.6rem, 1.7vw, .78rem);
  font-weight: 800;
  line-height: 1;
}
.hanoi-disk.pale { color: #fff; }
.hanoi-disk.lifted { opacity: .3; }
.hanoi-disk.ghost {
  position: fixed;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 60;
  box-shadow: var(--shadow-lg);
}

/* ---------------------------------------------- jogos: word search ----- */

.ws-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  gap: 18px;
  align-items: start;
}
.ws-grid {
  display: grid;
  gap: 2px;
  width: min(470px, 100%);
  margin: 0 auto;
  touch-action: none;
}
.ws-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: clamp(.72rem, 2.9vw, 1.02rem);
  line-height: 1;
  padding: 0;
  cursor: pointer;
  user-select: none;
}
.ws-grid.tight .ws-cell { font-size: clamp(.56rem, 2.1vw, .82rem); border-radius: 4px; }
.ws-cell:focus-visible { outline: none; box-shadow: var(--ring); }
.ws-cell.sel { background: var(--brand); border-color: var(--brand); color: #fff; }
.ws-cell.found { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.ws-cell.found.sel { background: var(--brand); color: #fff; }

.ws-side {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.ws-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mute); margin: 0 0 8px; }
.ws-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ws-word { font-size: .9rem; font-weight: 600; color: var(--text-soft); letter-spacing: .02em; }
.ws-word.found { color: var(--text-mute); text-decoration: line-through; opacity: .7; }
.ws-theme { width: auto; min-width: 148px; padding: 7px 10px; }

@media (max-width: 640px) {
  .ws-layout { grid-template-columns: 1fr; }
  .ws-list { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------- jogos: lights out ------ */

.lo-board {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: var(--board);
  border-radius: var(--radius);
  width: min(420px, 100%);
}
.lo-board[data-size="3"] { grid-template-columns: repeat(3, 1fr); }
.lo-board[data-size="5"] { grid-template-columns: repeat(5, 1fr); }
.lo-board[data-size="7"] { grid-template-columns: repeat(7, 1fr); gap: 6px; }

.lo-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--board-line);
  border-radius: var(--radius-sm);
  background: var(--tile-1);
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  user-select: none;
  touch-action: manipulation;
  transition: background-color .12s ease, transform .08s ease;
}
.lo-cell:hover { transform: scale(1.04); }
.lo-cell[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 253, 248, .4);
}
/* ponto de dica: celulas que ainda precisam ser pressionadas */
.lo-cell.hint::after {
  content: "";
  width: 32%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--brand);
}
.lo-cell[aria-pressed="true"].hint::after { background: var(--text); }

/* --------------------------------------------- jogos: pixel logic ------ */

.pl-board {
  display: grid;
  gap: 2px;
  padding: 8px;
  background: var(--board);
  border-radius: var(--radius);
  width: min(470px, 100%);
}
.pl-board[data-size="5"] { grid-template-columns: max-content repeat(5, minmax(0, 1fr)); }
.pl-board[data-size="10"] { grid-template-columns: max-content repeat(10, minmax(0, 1fr)); }

.pl-corner { background: transparent; }

.pl-clue {
  display: flex;
  gap: 4px;
  font-size: clamp(.6rem, 2.2vw, .8rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  line-height: 1.15;
}
.pl-clue.row { align-items: center; justify-content: flex-end; padding: 0 7px 0 3px; min-width: 44px; }
.pl-clue.col { flex-direction: column; align-items: center; justify-content: flex-end; padding: 3px 0 4px; }

.pl-cell {
  aspect-ratio: 1 / 1;
  position: relative;
  border: 1px solid var(--board-line);
  border-radius: 3px;
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.pl-cell:hover { background: var(--brand-soft); }
.pl-cell.fill,
.pl-cell.fill:hover { background: var(--brand); border-color: var(--brand-strong); }
/* o X e desenhado com as duas pseudo-elementos, sem fonte envolvida */
.pl-cell.mark::before,
.pl-cell.mark::after {
  content: "";
  position: absolute;
  left: 22%;
  top: 50%;
  width: 56%;
  height: 2px;
  border-radius: 2px;
  background: var(--text-mute);
}
.pl-cell.mark::before { transform: rotate(45deg); }
.pl-cell.mark::after { transform: rotate(-45deg); }
/* linhas de apoio a cada cinco casas, como no papel quadriculado */
.pl-cell.edge-col { border-right-width: 3px; border-right-color: var(--border-strong); }
.pl-cell.edge-row { border-bottom-width: 3px; border-bottom-color: var(--border-strong); }

.pl-board.solved .pl-cell { cursor: default; }
.pl-board.solved .pl-cell.mark::before,
.pl-board.solved .pl-cell.mark::after { opacity: 0; }
.pl-board.solved .pl-cell.fill { background: var(--mint); border-color: var(--mint); }
