/* Swaadle: daily food word game (DOM tiles + on-screen keyboard) */

body.sw {
  --bg-top: #fff6e6; --bg-bottom: #f6e5c8; --hud-ink: var(--ink); --hud-chip: rgba(43, 29, 20, .08);
  --sw-g: #3f9b4f; --sw-y: #e2a923; --sw-b: #8f8478;
  --sw-empty: #fffdf8; --sw-edge: #e6d4b6; --sw-edge-on: #8b735c;
  --tile: 56px;
  user-select: none; -webkit-user-select: none;
}

/* Status chips */
.sw .sw-chip-n { font-weight: 800; }
.sw .sw-chip-prac { background: var(--turmeric); color: var(--ink); }
.sw .sw-chip-streak { color: var(--chili-2); font-weight: 800; }

.sw .stage { display: flex; flex-direction: column; align-items: center; padding: 4px 16px 8px; gap: 10px; overflow: hidden; }

/* Category clue */
.sw-clue {
  flex: none; max-width: 100%; padding: 6px 16px 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15.5px; line-height: 1.25;
  background: #fff; border: 1.5px solid var(--line); box-shadow: 0 3px 0 var(--line); text-align: center;
  display: flex; align-items: center; gap: 8px;
}
.sw-clue::before { content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--cat, var(--chili)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat, var(--chili)) 25%, transparent); }
.sw-clue.practice { background: #fff3d1; border-color: var(--turmeric); box-shadow: 0 3px 0 #e8c468; }
.sw-tut .sw-clue { opacity: .75; font-size: 13.5px; }
.sw-tut .sw-clue::before { display: none; }

/* Board */
.sw-board { flex: 1; min-height: 0; display: grid; place-items: center; width: 100%; }
.sw-grid { display: grid; gap: 6px; perspective: 900px; }
.sw-row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 6px; }
.sw-tile {
  width: var(--tile); height: var(--tile); display: grid; place-items: center; border-radius: 10px;
  background: var(--sw-empty); border: 2px solid var(--sw-edge); color: var(--ink);
  font: 800 calc(var(--tile) * .52)/1 var(--font); text-transform: uppercase;
  transform-style: preserve-3d; backface-visibility: hidden;
}
.sw-tile.filled { border-color: var(--sw-edge-on); }
.sw-tile.s-g, .sw-tile.s-y, .sw-tile.s-b { color: #fff; border-color: transparent; text-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.sw-tile.s-g { background: var(--sw-g); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .14); }
.sw-tile.s-y { background: var(--sw-y); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12); }
.sw-tile.s-b { background: var(--sw-b); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12); }

.sw-tile.pop { animation: sw-pop .11s ease-out; }
@keyframes sw-pop { 0% { transform: scale(.86); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.sw-tile.flip { animation: sw-flip .52s ease-in-out both; }
@keyframes sw-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); } }
.sw-tile.bounce { animation: sw-bounce .7s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes sw-bounce { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-34%) scale(1.06); } 55% { transform: translateY(4%) scaleY(.94); } 75% { transform: translateY(-6%); } }
.sw-row.shake { animation: sw-shake .42s; }
@keyframes sw-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(5px); } 30%, 50%, 70% { transform: translateX(-9px); } 40%, 60% { transform: translateX(9px); } }
.sw-tile.ready { animation: sw-ready .8s ease-in-out 2; }
@keyframes sw-ready { 50% { border-color: var(--chili); box-shadow: 0 0 0 4px rgba(217, 72, 28, .2); } }
.sw-tut .sw-row:not(:first-child) { opacity: .35; }
.sw-tile.hl { animation: sw-hl 1s ease-in-out infinite; z-index: 1; }
@keyframes sw-hl { 50% { transform: translateY(-5px) scale(1.08); } }

/* Under-board actions once a game is over */
.sw-after { flex: none; display: flex; gap: 10px; justify-content: center; }
.sw-after .btn { min-height: 44px; padding: 8px 18px; font-size: 15px; }

/* Coach line sits below the clue during the tutorial */
.sw .coach-line { top: 48px; background: rgba(43, 29, 20, .82); font-size: 15.5px; line-height: 1.3; width: max-content; max-width: min(92%, 420px); white-space: normal; }

/* Keyboard (lives in the shell's bottom bar, which already pads for the safe area) */
.sw .sw-kb { flex-direction: column; gap: 7px; padding-top: 6px; padding-left: max(6px, env(safe-area-inset-left, 0px)); padding-right: max(6px, env(safe-area-inset-right, 0px)); touch-action: manipulation; }
.sw-kbrow { display: flex; gap: 5px; justify-content: center; width: 100%; max-width: 500px; margin: 0 auto; }
.sw-kbrow:nth-child(2) { padding: 0 4.5%; }
.sw-key {
  flex: 1 1 0; min-width: 0; height: 54px; border: 0; border-radius: 9px; padding: 0;
  background: #fff; color: var(--ink); font: 800 18px/1 var(--font);
  box-shadow: 0 3px 0 var(--line), 0 0 0 1px var(--line) inset; display: grid; place-items: center;
  transition: background .25s, color .25s, transform .06s;
  touch-action: manipulation;
}
.sw-key.wide { flex: 1.55 1 0; font-size: 13.5px; text-transform: uppercase; letter-spacing: .02em; }
.sw-key svg { width: 26px; height: 26px; }
.sw-key.down { transform: translateY(2px); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line) inset; }
.sw-key.ghost { background: var(--ink); color: #fff; }
.sw-key.s-g { background: var(--sw-g); color: #fff; box-shadow: 0 3px 0 #2c7339; }
.sw-key.s-y { background: var(--sw-y); color: #fff; box-shadow: 0 3px 0 #b5861a; }
.sw-key.s-b { background: var(--sw-b); color: #fff; box-shadow: 0 3px 0 #6f655a; }
@media (max-height: 640px) { .sw-key { height: 48px; } .sw .sw-kb { gap: 6px; } }
@media (max-height: 560px) { .sw-key { height: 44px; } }

/* Result modal: the dish card */
.sw-result { gap: 12px; padding-top: 20px; }
.sw-card {
  position: relative; border-radius: 22px; padding: 18px 14px 14px; display: grid; gap: 6px; justify-items: center;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--cat) 26%, #fff) 0%, #fff 70%);
  border: 2px solid color-mix(in srgb, var(--cat) 45%, #fff);
}
.sw-plate {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 4px;
  background: radial-gradient(circle at 50% 45%, #fff 0 52%, color-mix(in srgb, var(--cat) 30%, #fff) 53% 60%, var(--cat) 61% 100%);
  box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--cat) 80%, #000), inset 0 -4px 0 rgba(0, 0, 0, .12);
  animation: sw-plate .6s cubic-bezier(.2, 1.5, .4, 1) both;
}
.sw-plate span { font-size: 42px; line-height: 1; }
@keyframes sw-plate { from { transform: scale(.3) rotate(-30deg); opacity: 0; } }
.sw-card-word { display: flex; gap: 4px; }
.sw-card-word span {
  width: 34px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--sw-g);
  font: 800 21px/1 var(--font); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); animation: sw-pop .35s ease-out both;
}
.sw-hindi { font: 700 26px/1.2 var(--font); color: var(--ink) !important; }
.sw-cat { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--cat) !important; filter: brightness(.8); }
.sw-fact { font-size: 15px; line-height: 1.4; color: var(--ink-soft); max-width: 30ch; }
.sw-fact b { color: var(--ink); }

.sw-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sw-stats div { display: grid; justify-items: center; }
.sw-stats b { font: 700 26px/1.1 var(--display); color: var(--ink); }
.sw-stats span { font-size: 11.5px; line-height: 1.2; color: var(--ink-soft); font-weight: 600; }
.sw-next { display: flex; justify-content: center; align-items: baseline; gap: 8px; font-weight: 700; color: var(--ink-soft); }
.sw-count { font: 700 22px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: .02em; }

.sw-statsm { gap: 12px; }
.sw-dist-h { font-weight: 800; color: var(--ink) !important; text-align: left; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; }
.sw-dist { display: grid; gap: 5px; }
.sw-bar-row { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: center; font-weight: 800; }
.sw-bar { background: var(--sw-b); color: #fff; border-radius: 6px; padding: 2px 8px; text-align: right; min-width: 26px; transition: width .6s cubic-bezier(.2, 1, .3, 1); }
.sw-bar.hi { background: var(--sw-g); }
.sw-bar b { font-size: 14px; }

@media (min-width: 700px) {
  .sw .sw-kb { max-width: 560px; }
}

/* Toasts ("Not in our menu") show near the board, not over the keyboard */
body.sw .toast { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 62px); transform: translate(-50%, -12px); }
body.sw .toast.show { transform: translate(-50%, 0); }

/* Letter-spacing splits Devanagari conjuncts ("ना श्ता"): none in Hindi */
html[lang="hi"] .sw-cat, html[lang="hi"] .sw-dist-h, html[lang="hi"] body.sw .end-kicker { letter-spacing: 0; font-size: 13px; }
