/* Treasure hunt, games, chest and present page. Kept separate from the site styles. */
/* Treasure hunt: log button, panel, hidden marks */
.log-btn {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--bg); border: 0; border-radius: 999px; padding: 10px 14px; cursor: pointer;
  font: inherit; font-size: .8rem; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.log-btn svg { width: 20px; height: 20px; }
.log {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 41; width: min(360px, calc(100% - 32px));
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.3); font-size: .92rem;
}
.log[hidden] { display: none; }
.log h2 { font-family: var(--serif); font-weight: 400; font-size: 1.3rem; margin-bottom: 10px; }
.log p { margin-bottom: 10px; }
.log-new { background: var(--soft); border-radius: 6px; padding: 8px 10px; }
.log-x { position: absolute; top: 8px; right: 12px; background: none; border: 0; font-size: 1.4rem; color: var(--muted); cursor: pointer; }
.slots { display: flex; gap: 8px; margin: 12px 0; }
.slot { width: 36px; height: 40px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); font-family: var(--serif); font-size: 1.3rem; }
.slot.on { border: 1px solid var(--accent); color: var(--accent); background: var(--soft); }
.log-go { display: inline-block; margin-top: 4px; color: var(--bg); background: var(--accent); padding: 8px 16px; border-radius: 999px; text-decoration: none; }

/* Hidden doors: ordinary words, letters and pictures that open a game when tapped.
   They must look exactly like normal content, before and after a game is solved:
   no focus ring, no tap flash, no underline. */
.hunt-hit { pointer-events: auto; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hunt-hit, .hunt-hit:focus, .hunt-hit:focus-visible { outline: none; }
/* words get an invisible, finger-sized tap area (padding grows the target, the negative margin keeps the text where it was) */
.hunt-word { padding: 14px 10px; margin: -14px -10px; }

/* The locked portfolio page */
.treasure-wrap { max-width: 560px; text-align: center; padding: 72px 0 96px; }
.treasure-wrap h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 6vw, 3rem); }
.chest { width: 200px; margin: 28px auto; color: var(--accent); }
.chest .lid { transform-origin: 20px 60px; transition: transform .8s ease; }
.chest.open .lid { transform: rotate(-35deg) translateY(-6px); }
.lock label { display: block; color: var(--muted); margin-bottom: 12px; }
.lock-row { display: flex; gap: 10px; justify-content: center; }
.lock input {
  width: 11.5ch; text-align: center; text-transform: uppercase; letter-spacing: .18em; font: inherit; font-size: 1.3rem;
  background: none; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.lock input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.err { color: #c46b5a; min-height: 1.5em; margin-top: 10px; font-size: .9rem; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.secret { margin-top: 24px; text-align: left; }
.secret h2 { font-family: var(--serif); font-weight: 400; font-size: 2rem; margin-bottom: 14px; text-align: center; }
.secret p { margin-bottom: 1em; }
.secret .sign { font-family: var(--serif); font-style: italic; }
.secret .btn { display: table; margin: 24px auto 0; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* Games (modal) */
.gm { position: fixed; inset: 0; z-index: 70; background: rgba(8,12,18,.78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.gm[hidden] { display: none; }
.gm-box { position: relative; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; width: min(520px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 24px 22px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.gm-title { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; margin-bottom: 12px; padding-right: 30px; }
.gm-x { position: absolute; top: 10px; right: 14px; background: none; border: 0; font-size: 1.6rem; color: var(--muted); cursor: pointer; }
.g-hint { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.g-msg { min-height: 1.6em; text-align: center; font-size: .9rem; margin: 10px 0; color: var(--accent); }
.g-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.g-actions .btn { padding: 8px 18px; }
.g-win { text-align: center; padding: 10px 0; }
.g-digit { font-family: var(--serif); font-size: 5rem; line-height: 1.1; color: var(--accent); margin: 8px 0; }
.g-win .btn { margin-top: 14px; }

/* Wordle */
.wd-grid { display: grid; gap: 6px; justify-content: center; margin-bottom: 6px; }
.wd-row { display: flex; gap: 6px; }
.wd-tile { width: 52px; height: 52px; display: grid; place-items: center; border: 2px solid var(--line); font-weight: 600; font-size: 1.5rem; text-transform: uppercase; border-radius: 4px; }
.wd-tile.filled { border-color: var(--muted); }
.wd-tile.correct { background: #5a9a6a; border-color: #5a9a6a; color: #fff; }
.wd-tile.present { background: #c9a24a; border-color: #c9a24a; color: #fff; }
.wd-tile.absent { background: #5b636b; border-color: #5b636b; color: #fff; }
.wd-kb { display: grid; gap: 6px; margin-top: 8px; }
.wd-kb > div { display: flex; gap: 5px; justify-content: center; }
.wd-kb button { flex: 1; max-width: 40px; height: 46px; border: 0; border-radius: 5px; background: var(--soft); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.wd-kb button.wide { max-width: 58px; }
.wd-kb button.correct { background: #5a9a6a; color: #fff; }
.wd-kb button.present { background: #c9a24a; color: #fff; }
.wd-kb button.absent { background: #5b636b; color: #fff; opacity: .6; }

/* Connections */
.cn-solved { display: grid; gap: 6px; margin-bottom: 6px; }
.cn-group { border-radius: 6px; padding: 10px; text-align: center; color: #1d2733; display: grid; font-size: .9rem; }
.cn-group span { font-size: .8rem; }
.g1 { background: #f1d675; } .g2 { background: #a8d08d; } .g3 { background: #9cc1e8; } .g4 { background: #c9a3d9; }
.cn-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cn-word { min-height: 58px; border: 0; border-radius: 6px; background: var(--soft); color: var(--ink); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; padding: 4px; }
.cn-word.sel { background: var(--ink); color: var(--bg); }
.cn-mistakes { text-align: center; font-size: .8rem; color: var(--muted); }

/* Binairo+ */
.gm-box.wide { width: min(640px, 100%); }
.bn-rules { font-size: .82rem; color: var(--muted); margin: 0 0 14px 18px; }
.bn-grid { --gap: 4px; display: grid; grid-template-columns: repeat(10, 1fr); gap: var(--gap); width: min(540px, 100%); margin: 0 auto; }
.bn-cell { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); display: grid; place-items: center; cursor: pointer; padding: 0; }
.bn-cell.fixed { background: var(--line); cursor: default; }
.bn-cell.bad { outline: 2px solid #c46b5a; z-index: 1; }
.bn-cell .dot { width: 70%; height: 70%; border-radius: 50%; }
.bn-cell .dot.b { background: #1d2733; }
.bn-cell .dot.w { background: #fff; border: 2px solid #1d2733; }
.bn-sym { position: absolute; z-index: 2; width: 17px; height: 17px; border-radius: 50%; background: var(--bg); border: 1px solid var(--muted); color: var(--ink); font-size: 12px; line-height: 15px; font-weight: 700; text-align: center; pointer-events: none; }
.bn-sym.h { right: calc(var(--gap) / -2 - 8.5px); top: calc(50% - 8.5px); }
.bn-sym.v { bottom: calc(var(--gap) / -2 - 8.5px); left: calc(50% - 8.5px); }
.bn-sym.bad { border-color: #c46b5a; color: #c46b5a; }
@media (max-width: 420px) { .bn-sym { width: 14px; height: 14px; font-size: 10px; line-height: 12px; } .bn-sym.h { right: calc(var(--gap) / -2 - 7px); top: calc(50% - 7px); } .bn-sym.v { bottom: calc(var(--gap) / -2 - 7px); left: calc(50% - 7px); } }
@media (prefers-color-scheme: dark) { .bn-cell .dot.b { background: #05080b; border: 2px solid #8fbad6; } }

/* Braille */
.br-chart { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; justify-content: center; }
.br-chart[hidden] { display: none; }
.br-key { display: grid; justify-items: center; gap: 2px; font-size: .75rem; }
.br-msg { display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; margin-top: 16px; }
.br-word { display: flex; gap: 6px; }
.br-col { display: grid; justify-items: center; gap: 4px; }
.br-cell { display: grid; grid-template-columns: repeat(2, 8px); grid-auto-rows: 8px; gap: 3px; padding: 5px 6px; background: var(--soft); border-radius: 6px; }
.br-cell i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line); }
.br-cell i.on { background: var(--accent); border-color: var(--accent); }
.br-col input { width: 26px; height: 28px; text-align: center; font: inherit; font-weight: 600; text-transform: uppercase; background: none; color: var(--ink); border: 0; border-bottom: 2px solid var(--line); padding: 0; }
.br-col input:focus { outline: none; border-color: var(--accent); }
.br-col input.ok { color: #5a9a6a; border-color: #5a9a6a; }
.br-col input.no { color: #c46b5a; border-color: #c46b5a; }
.g-hint + .btn { margin-bottom: 4px; }

/* Present page */
.present-hero { text-align: center; padding: 64px 0 28px; }
.present-hero h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 8vw, 5rem); line-height: 1.05; }
.show { position: relative; aspect-ratio: 1 / 1; max-height: 78vh; max-height: 78dvh; margin-inline: auto; overflow: hidden; background: var(--soft); max-width: 760px; box-shadow: 0 18px 50px rgba(0,0,0,.2); }
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1s ease; }
.slide.on { opacity: 1; }
.slide .bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(26px) brightness(.8); }
.slide img { position: relative; width: 100%; height: 100%; object-fit: contain; }
.show-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(0,0,0,.4); color: #fff; font-size: 1.4rem; cursor: pointer; }
.show-prev { left: 12px; } .show-next { right: 12px; }
.slide-cap { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 10px; min-height: 1.6em; }
.dots { display: flex; justify-content: center; margin-top: 2px; font-size: .8rem; letter-spacing: .1em; color: var(--muted); }
.dots button { width: 8px; height: 8px; border-radius: 50%; border: 0; background: var(--line); cursor: pointer; padding: 0; }
.dots button.on { background: var(--accent); }
.message { max-width: 62ch; padding: 56px 0 24px; font-size: 1.1rem; }
.message p { margin-bottom: 1.1em; }
.message .sign { font-family: var(--serif); font-style: italic; font-size: 1.3rem; }
.collage { columns: 4 130px; column-gap: 12px; padding: 24px 0 40px; }
.collage figure { break-inside: avoid; margin: 0 0 22px; background: #fff; padding: 10px 10px 8px; border-radius: 3px; box-shadow: 0 6px 18px rgba(0,0,0,.18); transform: rotate(var(--rot)); animation: pop .8s ease var(--delay) both; transition: transform .3s ease; }
@keyframes pop { from { opacity: 0; transform: rotate(var(--rot)) translateY(26px); } }
@media (hover: hover) { .collage figure:hover { transform: rotate(0) scale(1.03); } }
.collage img { width: 100%; height: auto; }
.collage figure.nocap { padding-bottom: 30px; cursor: pointer; }
.collage figure { cursor: pointer; }
.collage figcaption { color: #4a5360; font-family: var(--serif); font-style: italic; font-size: .85rem; padding-top: 8px; text-align: center; }
.present-end { text-align: center; padding-bottom: 96px; }

@media (max-width: 480px) { .wd-tile { width: 46px; height: 46px; } }

/* Extra marks */
.portrait { position: relative; }

/* Portfolio: numbers tray and rearrange animation */
.tray { display: flex; gap: 8px; justify-content: center; margin: 4px 0 22px; }
.tile { width: 40px; height: 52px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); font-family: var(--serif); font-size: 1.4rem; }
.tile.on { border: 1px solid var(--accent); background: var(--soft); color: var(--accent); }
.reveal { position: fixed; inset: 0; z-index: 55; background: color-mix(in srgb, var(--bg) 92%, transparent); }
.reveal[hidden] { display: none; }
.tile.big { position: fixed; border: 1px solid var(--accent); background: var(--soft); color: var(--accent); transition: left .9s cubic-bezier(.5,0,.2,1), top .9s cubic-bezier(.5,0,.2,1), width .9s ease, height .9s ease, font-size .9s ease, box-shadow .6s; }
.reveal.done .tile.big { box-shadow: 0 0 22px var(--accent); }
.treasure-wrap { transition: opacity .6s; }

/* Sliding puzzle */
.sl-board { --img: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; aspect-ratio: 16 / 9; width: 100%; background: var(--line); border-radius: 6px; overflow: hidden; }
.sl-tile { border: 0; padding: 0; background-image: var(--img); background-size: 300% 300%; cursor: pointer; }
.sl-tile.gap { background: var(--bg); cursor: default; }
.sl-board.peek { background-image: var(--img); background-size: 100% 100%; }
.sl-board.peek .sl-tile { visibility: hidden; }

.g-note { font-style: italic; color: var(--muted); font-size: .9rem; }




/* ---------- Phones and tablets ---------- */
/* no text selection, magnifier or callout while tapping and holding game pieces */
.cn-word, .bn-cell, .sl-tile, .wd-kb button, .wd-tile, .br-key, .tile, .br-cell, .g-digit {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
@media (pointer: coarse) {
  .br-col input { width: 32px; height: 38px; font-size: 1.05rem; }
  .wd-kb button { height: 52px; }
  .gm-x, .log-x { width: 44px; height: 44px; top: 4px; right: 6px; }
}
@media (max-width: 480px) {
  .gm { padding: 8px; }
  .gm-box { padding: 20px 14px 22px; }       /* more room for the Binairo+ board */
  .br-msg { gap: 8px 14px; }
}

.log { max-height: 70vh; max-height: 70dvh; overflow-y: auto; overscroll-behavior: contain; }

/* LITS */
.lt-grid { display: grid; grid-template-columns: repeat(6, 1fr); width: min(360px, 100%); margin: 0 auto; }
.lt-cell {
  aspect-ratio: 1; padding: 0; position: relative; cursor: pointer; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
}
.lt-cell.t { border-top: 3px solid var(--ink); }
.lt-cell.b { border-bottom: 3px solid var(--ink); }
.lt-cell.l { border-left: 3px solid var(--ink); }
.lt-cell.r { border-right: 3px solid var(--ink); }
/* shaded squares: the fill sits inside the cell, so the region outline stays visible around it */
.lt-cell.on::before {
  content: ""; position: absolute; background: var(--fill, var(--muted));
  top: var(--t, 5px); right: var(--r, 5px); bottom: var(--b, 5px); left: var(--l, 5px);
}
.lt-cell.s-I, .lt-legend .s-I { --fill: #3fb8d6; }
.lt-cell.s-L, .lt-legend .s-L { --fill: #e0b030; }
.lt-cell.s-T, .lt-legend .s-T { --fill: #a066d3; }
.lt-cell.s-S, .lt-legend .s-S { --fill: #5bb56a; }
.lt-legend { display: flex; gap: 18px; justify-content: center; margin-top: 12px; font-size: .8rem; color: var(--muted); }
.lt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lt-legend i { width: 14px; height: 14px; background: var(--fill); display: inline-block; }
.lt-cell.dot::after { content: ""; width: 28%; height: 28%; border-radius: 50%; background: var(--muted); }
.lt-cell.bad { box-shadow: inset 0 0 0 3px var(--accent); z-index: 1; }
.lt-cell { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sl-note { text-align: center; margin-top: 4px; }

/* long words (WHITE HAIR, UNIVERSITY) must fit on small phones */
.cn-word { overflow-wrap: anywhere; hyphens: auto; }
@media (max-width: 420px) { .cn-word { font-size: .66rem; } }
@media (max-width: 340px) { .cn-word { font-size: .58rem; } }

/* secret page: the line under the headline */
.treasure-wrap .lead { color: var(--muted); font-size: 1.05rem; font-weight: 300; max-width: 46ch; margin: 12px auto 0; }


/* ---------- The birthday letter ---------- */
.letter-wrap { padding: 56px 0 56px; }
.letter {
  max-width: 700px; margin-inline: auto; position: relative;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0,0,0,.10);
  padding: clamp(30px, 6vw, 68px) clamp(24px, 6.5vw, 76px) clamp(30px, 5vw, 56px);
  font-size: clamp(1.03rem, .96rem + .45vw, 1.2rem); font-weight: 300; line-height: 1.85;
  animation: letter-in 1s ease both;
}
.letter::before { content: ""; position: absolute; left: clamp(24px, 6.5vw, 76px); top: 0; width: 56px; height: 3px; background: var(--accent); }
.letter p { margin: 0 0 1.55em; text-wrap: pretty; }
.letter .salutation { font-family: var(--serif); font-weight: 500; font-size: 1.45em; line-height: 1.3; margin-bottom: 1.3em; }
.letter .closing { margin-top: 2.1em; margin-bottom: .9em; }
.letter .love { font-size: 1.3em; letter-spacing: .18em; margin-bottom: 1.1em; font-weight: 400; }
.letter .signature { text-align: right; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.5em; margin-bottom: 0; }
.letter .ps {
  margin: 2.6em 0 0; padding-top: 1.3em; border-top: 1px dashed var(--line);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-weight: 400;
  font-size: .8em; line-height: 1.75; color: var(--muted);
}
@keyframes letter-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .letter { animation: none; } }
