/* SlideWords: the RINgames house look (ink on paper, one green accent, Instrument Serif and Sans), with letter tiles that
   have a little thickness, so turning one over reads as a card turning over. */
@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(/fonts/instrument-serif-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: light dark;
  --paper: #f6f6f3; --card: #ffffff; --ink: #16161a; --muted: #5f6068; --line: #e3e2dc; --line-strong: #cfcec7;
  --hover: #efeee9; --accent: #2e6b57; --accent-soft: #e3efe9; --on-accent: #ffffff; --accent-edge: #1f4c3d;
  --tile-edge: #d9d8d0; --shadow: rgba(22, 22, 26, .10); --slot: #ebeae4; --slot-shade: rgba(22, 22, 26, .10);
  --sans: "Instrument Sans", "Segoe UI", Roboto, system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --rin-nav-font: var(--sans);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131316; --card: #1c1c21; --ink: #ecebe6; --muted: #a6a6ae; --line: #2e2e35; --line-strong: #3d3d45;
    --hover: #26262c; --accent: #8fd3b8; --accent-soft: #1e3029; --on-accent: #0f241c; --accent-edge: #5fa58a;
    --tile-edge: #0c0c0f; --shadow: rgba(0, 0, 0, .35); --slot: #0e0e11; --slot-shade: rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --paper: #131316; --card: #1c1c21; --ink: #ecebe6; --muted: #a6a6ae; --line: #2e2e35; --line-strong: #3d3d45;
  --hover: #26262c; --accent: #8fd3b8; --accent-soft: #1e3029; --on-accent: #0f241c; --accent-edge: #5fa58a;
  --tile-edge: #0c0c0f; --shadow: rgba(0, 0, 0, .35); --slot: #0e0e11; --slot-shade: rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--sans);
  display: flex; flex-direction: column; align-items: center; min-height: 100svh;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- the top bar ---- */
.top { width: 100%; max-width: 640px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 6px 12px 0; }
.nav-slot { display: flex; align-items: center; min-height: 44px; }
.nav-slot .rin-nav-button { color: var(--ink); }
.title { margin: 0; text-align: center; font: 400 30px/1.1 var(--serif); letter-spacing: .01em; }
.streak { justify-self: end; display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 4px; color: var(--accent); font: 600 15px/1 var(--sans); }
.streak svg { width: 22px; height: 22px; }
.streak .flame { fill: currentColor; }
.streak .flame-core { fill: var(--paper); }
.streak.zero { color: var(--muted); }
.streak.zero .flame { fill: none; stroke: currentColor; stroke-width: 1.5; }
.streak.zero .flame-core { display: none; }

/* ---- the date bar ---- */
.datebar { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 12px 4px; width: 100%; max-width: 640px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:disabled { color: var(--line-strong); cursor: default; }
.date-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); cursor: pointer; font: 500 15px/1 var(--sans); box-shadow: 0 1px 0 var(--line);
}
.date-btn:disabled { cursor: default; }
.date-num { color: var(--muted); font-weight: 400; }
.cal-icon { width: 20px; height: 20px; color: var(--ink); }
.cal-icon-today { fill: var(--accent); }

/* ---- the calendar panel: a desk calendar's page, its days drawn as tiles ---- */
.cal-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 50%; width: min(340px, calc(100vw - 24px));
  transform: translateX(-50%); transform-origin: 50% 0;
  padding: 18px 14px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--card);
  box-shadow: 0 1px 0 var(--line-strong), 0 14px 34px var(--shadow);
}
.cal-panel.open { animation: cal-in .2s cubic-bezier(.2,.8,.3,1) both; }
.cal-panel.closing { animation: cal-out .16s ease-in both; }
@keyframes cal-in { from { opacity: 0; transform: translateX(-50%) perspective(700px) rotateX(-14deg) translateY(-8px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes cal-out { from { opacity: 1; transform: translateX(-50%); } to { opacity: 0; transform: translateX(-50%) perspective(700px) rotateX(-14deg) translateY(-8px); } }
.cal-rings { position: absolute; top: -9px; left: 0; right: 0; display: flex; justify-content: center; gap: 120px; pointer-events: none; }
.cal-rings i { width: 9px; height: 20px; border-radius: 5px; background: var(--ink); box-shadow: 0 0 0 3px var(--card); }
.cal-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; margin-bottom: 6px; }
.cal-title { margin: 0; text-align: center; font: 400 24px/1.2 var(--serif); }
.cal-week, .cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-week span { text-align: center; font: 600 11px/1.6 var(--sans); letter-spacing: .04em; color: var(--muted); }
.cal-day { aspect-ratio: 1; padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
.cal-day.gone { display: none; }
.cal-day.blank { visibility: hidden; }
.cal-face {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 7px; font: 400 18px/1 var(--serif); color: var(--muted);

}
.cal-day.play .cal-face { color: var(--ink); background: var(--card); border: 1px solid var(--line-strong); box-shadow: 0 2px 0 var(--tile-edge); }
.cal-day.won .cal-face { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: 0 2px 0 var(--accent-edge); }
.cal-day.late .cal-face { border: 2px solid var(--accent); color: var(--accent); }
.cal-day.upcoming .cal-face { border-style: dashed; box-shadow: none; background: transparent; }
.cal-day.today .cal-face { outline: 2px solid var(--ink); outline-offset: 2px; }
.cal-day.current .cal-face { transform: translateY(-2px); box-shadow: 0 4px 0 var(--tile-edge), 0 6px 12px var(--shadow); }
.cal-day.won.current .cal-face { box-shadow: 0 4px 0 var(--accent-edge), 0 6px 12px var(--shadow); }
.cal-day:disabled { cursor: default; }
.cal-day.off .cal-face { opacity: .55; }

/* ---- the stage ---- */
.stage { width: 100%; max-width: 640px; flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.admin-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.preview-chip { font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); border: 1px dashed var(--accent); border-radius: 999px; padding: 5px 9px; }
.text-btn { border: 0; background: none; padding: 6px 4px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }

.board-wrap { flex: 1; display: grid; place-items: center; width: 100%; padding: 14px 0 6px; min-height: 120px; }
/* each place on the board is a slot sunk into the paper; the letter tiles sit in the slots and slide between them (every
   slot under every tile, every tile over every slot, so a tile sliding into the next place passes over its slot) */
.board {
  --t: 52px; position: relative; display: grid; grid-template-columns: repeat(var(--cols), var(--t)); grid-template-rows: repeat(var(--rows), var(--t));
  gap: 6px; transition: opacity .12s ease;
}
.board.leaving { opacity: .35; }
.tile { position: relative; width: var(--t); height: var(--t); }
.tile::before {
  content: ""; position: absolute; inset: 0; z-index: 0; border-radius: calc(var(--t) * .16);
  background: var(--slot); box-shadow: inset 0 2px 3px var(--slot-shade);
}
.face {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; border-radius: calc(var(--t) * .16);
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 3px 0 var(--tile-edge), 0 4px 10px var(--shadow);
  font: 400 calc(var(--t) * .62)/1 var(--serif); text-transform: uppercase; user-select: none;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.tile.ghost { position: absolute; z-index: 1; pointer-events: none; }
.tile.ghost::before { display: none; }
.tile.won .face {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: 0 3px 0 var(--accent-edge), 0 4px 10px var(--shadow);
}
.tile.answer .face { background: var(--card); border: 2px dashed var(--accent); color: var(--accent); box-shadow: none; }

.message { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; color: var(--muted); }
.message-text { margin: 0; font: 400 22px/1.3 var(--serif); color: var(--ink); }

.tools { position: relative; display: flex; align-items: center; justify-content: space-between; width: min(100%, 340px); padding: 2px 0; }
.moves { font: 500 14px/1 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.tools-right { display: inline-flex; gap: 2px; }
.cloud-btn { color: var(--muted); }
.cloud-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; width: min(300px, calc(100vw - 24px)); display: grid; gap: 8px; justify-items: center;
  padding: 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card); text-align: center;
  box-shadow: 0 1px 0 var(--line-strong), 0 12px 28px var(--shadow); animation: pop-in .16s cubic-bezier(.2,.8,.3,1) both;
}
.cloud-pop p { margin: 0; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.sound .mute { display: none; }
.sound.off .waves { display: none; }
.sound.off .mute { display: inline; }
.sound.off { color: var(--muted); }

/* the arrows and, once solved, the solved card take the same place (the card slides up as the arrows go down) */
.dock { display: grid; justify-items: center; align-items: start; width: 100%; }
.dock > .pad, .dock > .result { grid-area: 1 / 1; }

/* ---- the arrows: a cross, like a game pad ---- */
.pad {
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px); gap: 6px; margin-top: 6px;
  grid-template-areas: ". u ." "l . r" ". d ."; transition: transform .24s cubic-bezier(.4,0,.6,1), opacity .2s ease;
}
.pad.away { transform: translateY(40px); opacity: 0; pointer-events: none; }
.pad-btn {
  display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--card); color: var(--ink);
  box-shadow: 0 3px 0 var(--tile-edge); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; padding: 0;
  transition: transform .06s ease, box-shadow .06s ease, background .1s ease;
}
.pad-btn svg { width: 28px; height: 28px; }
.pad-btn[data-dir="U"] { grid-area: u; } .pad-btn[data-dir="L"] { grid-area: l; } .pad-btn[data-dir="R"] { grid-area: r; } .pad-btn[data-dir="D"] { grid-area: d; }
.pad-btn.pressed, .pad-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-edge); background: var(--hover); }

/* short screens: the arrows in one row, so the board keeps its size */
@media (max-height: 700px) {
  .pad { grid-template-columns: repeat(4, 60px); grid-template-rows: 52px; grid-template-areas: "l u d r"; }
}

/* ---- solved ---- */
.result {
  display: grid; justify-items: center; gap: 4px; margin-top: 6px; padding: 14px 18px 12px; width: min(100%, 360px); text-align: center;
  transform: translateY(40px); opacity: 0; transition: transform .26s cubic-bezier(.2,.8,.3,1), opacity .2s ease;
}
.result.shown { transform: none; opacity: 1; }
.result.instant { transition: none; }
.result-title { margin: 0; font: 400 34px/1.1 var(--serif); color: var(--accent); }
.result-moves, .result-streak, .next-in { margin: 0; color: var(--muted); }
.result-streak { color: var(--ink); font-weight: 500; }
.next-in { font-variant-numeric: tabular-nums; font-size: 14px; }
.cloud { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; justify-items: center; width: 100%; }
.cloud-text { margin: 0; }
.cloud-actions { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font: 500 15px/1.2 var(--sans); cursor: pointer; margin-top: 6px;
}
.btn-go { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }

/* hover shades only for a real pointer: on a touch screen a tapped button would keep its shade */
@media (hover: hover) {
  .icon-btn:hover:not(:disabled) { background: var(--hover); }
  .date-btn:hover { border-color: var(--line-strong); }
  .cal-day.play:hover .cal-face { background: var(--hover); }
  .cal-day.won:hover .cal-face { background: var(--accent); filter: brightness(1.06); }
  .pad-btn:hover { background: var(--hover); }
  .btn:hover { background: var(--hover); }
  .btn-go:hover { background: var(--accent); filter: brightness(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .pad, .result, .board { transition: none; }
  .cal-panel.open, .cal-panel.closing { animation: none; }
}
