/* Sylamix: Beach tile scheme from the Reveel tile key */
:root {
  --keep: #17a9a0; --move: #e2c799; --drop: #9a948a;
  --ink: #1b2130; --ink-soft: #5b6170; --line: #d8d4cc;
  --bg: #fbfaf7; --card: #ffffff; --key: #e9e6df; --key-ink: #1b2130;
  --cur-bg: #ffffff; --cur-line: #9a948a;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink: #eef0f4; --ink-soft: #a5aab5; --line: #3a3f4b; --bg: #14171f; --card: #1d212b;
          --key: #343946; --key-ink: #eef0f4; --cur-bg: #1d212b; --cur-line: #8b867d; }
}
:root[data-theme="dark"] { --ink: #eef0f4; --ink-soft: #a5aab5; --line: #3a3f4b; --bg: #14171f; --card: #1d212b;
        --key: #343946; --key-ink: #eef0f4; --cur-bg: #1d212b; --cur-line: #8b867d; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 520px; margin: 0 auto;
       padding: env(safe-area-inset-top) 8px calc(8px + env(safe-area-inset-bottom)); }

.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.title { text-align: center; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: .04em; }
h1::first-letter { color: var(--keep); }
.sub { font-size: 13px; color: var(--ink-soft); }
.icon { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card);
        font-weight: 700; font-size: 18px; display: grid; place-items: center; }

.banner { margin: 8px 4px 0; padding: 6px 10px; border-radius: 8px; background: var(--move); color: #1b2130;
          font-size: 13px; text-align: center; }

.board-wrap { flex: 1; display: grid; place-items: center; min-height: 0; padding: 10px 0; }
.board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px;
         height: min(100%, 420px); aspect-ratio: 5 / 6; }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.row.shake { animation: shake .4s; }
.board .tile { aspect-ratio: auto; }

.tile { display: grid; place-items: center; border-radius: 8px; font-weight: 700; font-size: clamp(22px, 7vw, 34px);
        border: 2px solid var(--line); background: var(--cur-bg); color: var(--ink); user-select: none; aspect-ratio: 1; }
.tile.filled { border-color: var(--cur-line); animation: pop .1s; }           /* a "cur": typed, not entered */
.tile.keep { background: var(--keep); border-color: var(--keep); color: #fff; }
.tile.move { background: var(--move); border-color: var(--move); color: #1b2130; }
.tile.drop { background: var(--drop); border-color: var(--drop); color: #fff; }
.tile.flip { animation: flip .5s ease both; }

.keyboard { display: flex; flex-direction: column; gap: 7px; padding: 4px 0 6px; user-select: none; }
.krow { display: flex; gap: 5px; justify-content: center; }
.k { flex: 1; max-width: 46px; height: 56px; border: none; border-radius: 6px; background: var(--key); color: var(--key-ink);
     font-weight: 700; font-size: 17px; padding: 0; }
.k.wide { max-width: 72px; flex: 1.5; font-size: 13px; }
.k.keep { background: var(--keep); color: #fff; }
.k.move { background: var(--move); color: #1b2130; }
.k.drop { background: var(--drop); color: #fff; text-transform: lowercase; }
/* lowercase l with a tail, so it can't be read as a capital I */
.tile.ll, .k.drop[data-key="L"] { font-family: "IBM Plex Mono", "IBM Plex Sans", monospace; }
.k:active { filter: brightness(.9); }

.toast { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none;
         transition: opacity .6s; z-index: 10; text-align: center; max-width: 90vw; }
.toast.show { opacity: 1; }

dialog.sheet { border: none; border-radius: 14px; padding: 22px 20px 20px; width: min(440px, calc(100vw - 32px));
               background: var(--card); color: var(--ink); max-height: 90dvh; overflow: auto; }
dialog::backdrop { background: rgba(10, 12, 18, .55); }
dialog h2 { margin: 0 0 10px; font-size: 22px; }
dialog h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
dialog p { line-height: 1.45; margin: 8px 0; }
.lead { white-space: nowrap; font-weight: 600; font-size: min(17px, calc((100vw - 72px) / 23)); }
.close { position: absolute; right: 10px; top: 8px; border: none; background: none; font-size: 28px; color: var(--ink-soft); }
.key { display: grid; gap: 8px; margin: 12px 0; }
.key > div { display: flex; align-items: center; gap: 10px; }
.key .tile { width: 40px; font-size: 22px; flex: none; }
.key b { width: 44px; }
.rule { background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.small { font-size: 13px; color: var(--ink-soft); }
.primary { display: block; width: 100%; margin-top: 14px; padding: 12px; border: none; border-radius: 10px;
           background: var(--keep); color: #fff; font-weight: 700; font-size: 16px; }
.secondary { display: block; width: 100%; margin-top: 8px; padding: 11px; border-radius: 10px;
             border: 1.5px solid var(--line); background: none; font-weight: 600; }

.result-head { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.result-head.success { color: var(--keep); }
.answer-reveal { display: flex; gap: 5px; margin: 10px 0; }
.answer-reveal .tile { width: 38px; font-size: 20px; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.nums b { display: block; font-size: 26px; }
.nums span { font-size: 12px; color: var(--ink-soft); }
.dist { display: grid; gap: 4px; }
.bar { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bar > span:first-child { width: 34px; text-align: right; }
.bar > span:last-child { background: var(--drop); color: #fff; padding: 2px 8px; border-radius: 4px; min-width: 24px;
                         text-align: right; font-weight: 600; }
.bar.today > span:last-child { background: var(--keep); }
.countdown { text-align: center; margin-top: 14px; font-size: 14px; color: var(--ink-soft); }
.countdown b { display: block; font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }

@keyframes pop { from { transform: scale(.9); } to { transform: scale(1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .tile.flip, .row.shake, .tile.filled { animation: none; } }
@media (max-height: 640px) { .k { height: 48px; } }
