/* ==========================================================================
   Secret Word — styles. Theme tokens and shared components come from
   shared/style.css.

   The board is a grid of squares as wide as the word (3 to 8), six rows high,
   with an on-screen keyboard under it. A marked row turns over square by square.
   ========================================================================== */

.sw {
  --hit: #3f9d4b;
  --near: #d9a521;
  --miss: #7b7468;
  display: grid;
  gap: .6rem;
  max-width: 30rem;
  margin-inline: auto;
  padding-block: .5rem 2rem;
}
@media (prefers-color-scheme: dark) {
  .sw { --miss: #4a4d55; }
}
.sw-title { font-size: clamp(1.4rem, 6.5vw, 2rem); text-align: center; }
.sw-subtitle { font-size: 1.1rem; }
.sw-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.sw-top > :last-child:not(:first-child) { margin-inline-start: auto; }
.sw-top .clock { font-size: 1.6rem; }
.sw-center { text-align: center; }
.sw-center-btn { justify-self: center; }
.sw-note-big { font-size: 1.05rem; font-weight: 700; text-align: center; }
.sw-info { font-weight: 800; text-align: center; }
.sw-left { font-weight: 700; text-align: center; color: var(--muted); }

/* ---------- Menu ---------- */

.sw-menu { display: grid; gap: .7rem; }
.howto { max-width: 30rem; margin: 1.5rem auto 0; padding: .25rem 1rem; }
.howto summary { min-height: var(--tap); display: flex; align-items: center; font-weight: 800; cursor: pointer; }
.howto ol { display: grid; gap: .5rem; padding: 0 0 1rem; padding-inline-start: 1.4rem; list-style: decimal; }
.sw-tagline { font-size: 1.1rem; font-weight: 700; text-align: center; }
.sw-best { font-weight: 900; text-align: center; }

/* ---------- Picking a word ---------- */

.sw-pick, .sw-pass { display: grid; gap: .55rem; padding: 1rem; }
.sw-pass { justify-items: center; text-align: center; padding-block: 2rem; }
.sw-pass__icon { font-size: 3rem; }
.sw-secret { font-size: 1.4rem; font-weight: 900; letter-spacing: .08em; }
/* Hidden while typing on a passed-around phone, unless the eye is pressed. */
.sw-secret:not(.is-shown) { -webkit-text-security: disc; }

/* ---------- The board ---------- */

.sw-pad { display: grid; gap: .5rem; }
.sw-grid {
  --size: min(3.4rem, calc((100vw - 2rem - (var(--len) - 1) * .35rem) / var(--len)));
  display: grid;
  gap: .35rem;
  justify-content: center;
}
.sw-row { display: grid; grid-template-columns: repeat(var(--len), var(--size)); gap: .35rem; }
.sw-tile {
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  font-size: calc(var(--size) * .5);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  background: var(--surface);
  border: 3px solid color-mix(in srgb, var(--line) 25%, transparent);
  border-radius: 10px;
}
.sw-row.is-current .sw-tile { border-color: color-mix(in srgb, var(--line) 45%, transparent); }
.sw-tile.is-typed { border-color: var(--line); animation: sw-pop .1s ease-out; }
.sw-tile--hit, .sw-tile--near, .sw-tile--miss { color: #fff; border-color: transparent; }
.sw-tile--hit { background: var(--hit); }
.sw-tile--near { background: var(--near); }
.sw-tile--miss { background: var(--miss); }
.sw-tile.is-flip { animation: sw-flip .45s ease-in-out both; }
@keyframes sw-pop { from { transform: scale(.88); } to { transform: scale(1); } }
@keyframes sw-flip {
  0% { transform: rotateX(0); background: var(--surface); color: var(--text); border-color: var(--line); }
  49% { transform: rotateX(90deg); background: var(--surface); color: var(--text); border-color: var(--line); }
  51% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .sw-tile.is-flip, .sw-tile.is-typed { animation: none; }
}
.sw-note { min-height: 1.4em; font-weight: 800; text-align: center; color: var(--tomato); }

/* The keyboard. */
.sw-keys { display: grid; gap: .35rem; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.sw-keys__row { display: flex; justify-content: center; gap: .25rem; }
.sw-key {
  flex: 1 1 0;
  max-width: 2.7rem;
  min-width: 0;
  min-height: 3.1rem;
  padding: 0;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.sw-key:active { transform: translateY(2px); }
.sw-key--wide { flex: 1.6 1 0; max-width: 4.4rem; font-size: .8rem; }
.sw-key--hit, .sw-key--near, .sw-key--miss { color: #fff; }
.sw-key--hit { background: var(--hit); }
.sw-key--near { background: var(--near); }
.sw-key--miss { background: var(--miss); opacity: .75; }

/* ---------- Everyone else ---------- */

.sw-players { display: grid; gap: .4rem; }
.sw-player { display: flex; align-items: center; gap: .55rem; padding: .4rem .7rem; background: var(--surface); border: 3px solid var(--line); border-radius: 14px 16px 13px 17px; }
.sw-player.is-you { border-color: var(--tomato); }
.sw-player.is-solved { background: color-mix(in srgb, var(--hit) 18%, var(--surface)); }
.sw-player__face { font-size: 1.5rem; line-height: 1; }
.sw-player__who { flex: 1; min-width: 0; display: grid; font-weight: 800; line-height: 1.25; }
.sw-player__who bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-player__who small { font-weight: 700; color: var(--muted); }
.sw-player__pts { font-size: 1.15rem; font-weight: 900; color: var(--olive); }
.sw-mini, .sw-peek { display: grid; grid-template-columns: repeat(var(--len), auto); gap: 2px; }
.sw-mini i { width: 8px; height: 8px; border-radius: 2px; background: color-mix(in srgb, var(--line) 15%, transparent); }
.sw-peek i { display: grid; place-items: center; width: 1.15rem; height: 1.15rem; font-size: .7rem; font-style: normal; font-weight: 900; text-transform: uppercase; color: #fff; border-radius: 3px; background: color-mix(in srgb, var(--line) 15%, transparent); }
.sw-dot--hit { background: var(--hit) !important; }
.sw-dot--near { background: var(--near) !important; }
.sw-dot--miss { background: var(--miss) !important; }

/* ---------- The word, at the end ---------- */

.sw-result { display: grid; gap: .55rem; padding: 1rem; }
.sw-result__label { font-weight: 800; text-align: center; color: var(--muted); }
.sw-result__word { font-size: clamp(2rem, 11vw, 3rem); font-weight: 900; line-height: 1.1; letter-spacing: .05em; text-align: center; text-transform: uppercase; color: var(--hit); }
.sw-result__line { font-weight: 800; text-align: center; }
.sw-streak { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; text-align: center; }
.sw-streak span { display: grid; padding: .35rem .2rem; background: var(--surface-2); border: 2px solid var(--line); border-radius: 12px; }
.sw-streak b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.sw-streak small { font-weight: 700; color: var(--muted); }
.sw-result__next { font-weight: 800; text-align: center; color: var(--muted); }
.sw-picker { font-weight: 800; text-align: center; }

.sw-board { display: grid; gap: .4rem; }
.sw-board__row { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); padding: .5rem .8rem; background: var(--surface); border: 3px solid var(--line); border-radius: 14px 16px 13px 17px; }
.sw-board__row:first-child { color: var(--ink); background: var(--sun); }
.sw-board__row.is-you { border-width: 4px; }
.sw-board__place { min-width: 1.4rem; font-size: 1.4rem; font-weight: 900; text-align: center; }
.sw-board__face { font-size: 1.6rem; line-height: 1; }
.sw-board__who { flex: 1; min-width: 0; font-weight: 800; }
.sw-board__pts { font-size: 1.3rem; font-weight: 900; font-variant-numeric: tabular-nums; }
