/* No flex `gap` in this file: iOS 14.0 ignores it, so spacing is margins. */
.dw { position: relative; width: 100%; max-width: 360px; margin: 0 auto; }
.dw-board { display: flex; flex-direction: column; align-items: center; }
.dw-row { display: flex; justify-content: center; }
.dw-row + .dw-row { margin-top: 6px; }
.dw-tile {
  width: 56px; height: 56px; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 800; text-transform: uppercase;
  border: 2px solid var(--c-border); border-radius: 8px; background: var(--c-surface); color: var(--c-text);
}
.dw-tile + .dw-tile { margin-left: 6px; }
.dw-tile.dw-filled  { border-color: #b9b9c9; }
.dw-tile.dw-correct { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.dw-tile.dw-present { background: var(--c-accent);  border-color: var(--c-accent);  color: #5a4a00; }
.dw-tile.dw-absent  { background: #78848c; border-color: #78848c; color: #fff; }
.dw-msg { min-height: 20px; text-align: center; color: var(--c-text-soft); font-weight: 600; font-size: .9rem; margin: 8px 0; }
.dw-keyboard { display: flex; flex-direction: column; scroll-margin-bottom: 12px; }
/* The display above would otherwise beat the hidden attribute. */
.dw-keyboard[hidden] { display: none; }
.dw-kb-row { display: flex; justify-content: center; }
.dw-kb-row + .dw-kb-row { margin-top: 6px; }
.dw-key {
  min-width: 30px; height: 50px; padding: 0 6px; border: 0; border-radius: 6px;
  background: #e4e4ee; color: var(--c-text); font-weight: 700; font-size: .95rem;
  text-transform: uppercase; cursor: pointer; transition: filter .12s ease;
  touch-action: manipulation;
}
.dw-key + .dw-key { margin-left: 5px; }
@media (hover: hover) {
  .dw-key:hover { filter: brightness(.95); }
}
.dw-key-wide { min-width: 52px; font-size: .78rem; }
.dw-key.dw-correct { background: var(--c-success); color: #fff; }
.dw-key.dw-present { background: var(--c-accent);  color: #5a4a00; }
.dw-key.dw-absent  { background: #6f7b83; color: #fff; }
.dw-end:empty { display: none; }
.dw-reveal { text-align: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--c-border); }
.dw-word { font-size: 1.35rem; margin: 0 0 6px; }
.dw-pos { color: var(--c-text-soft); font-weight: 400; font-size: 1rem; }
.dw-reveal p { margin: 6px 0; color: var(--c-text); line-height: 1.5; }
.dw-label { font-weight: 700; color: var(--c-text-soft); }
.dw-lost { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.dw-answer { font-size: 1.6rem; font-weight: 800; letter-spacing: 2px; color: var(--c-primary); }
.dw-tomorrow { margin-top: 12px; color: var(--c-text-soft); font-size: .9rem; }
@media (max-width: 380px) {
  .dw-tile { width: 48px; height: 48px; font-size: 1.5rem; }
  .dw-key { height: 46px; min-width: 26px; }
  .dw-key-wide { min-width: 44px; }
}

/* The panel's theme, set on #game-root by daily-word.js. Wide screens only, and one file per
   rule, so a phone downloads none and a computer only its own. */
@media (min-width: 1000px) {
  .game-root[data-dw-theme] { background-position: center; background-size: cover; background-repeat: no-repeat; }
  .game-root[data-dw-theme="calendar"]    { background-image: url(/assets/img/daily-word/bg-calendar.jpg); }
  .game-root[data-dw-theme="dictionary"]  { background-image: url(/assets/img/daily-word/bg-dictionary.jpg); }
  .game-root[data-dw-theme="letterpress"] { background-image: url(/assets/img/daily-word/bg-letterpress.jpg); }
  .game-root[data-dw-theme="sky"]         { background-image: url(/assets/img/daily-word/bg-sky.jpg); }
  .game-root[data-dw-theme="paper"]       { background-image: url(/assets/img/daily-word/bg-paper.svg); }
  .game-root[data-dw-theme="planes"]      { background-image: url(/assets/img/daily-word/bg-planes.svg); }
  .game-root[data-dw-theme="washes"]      { background-image: url(/assets/img/daily-word/bg-washes.svg); }
  .game-root[data-dw-theme="bubbles"]     { background-image: url(/assets/img/daily-word/bg-bubbles.svg); }
  .game-root[data-dw-theme="shelf"]       { background-image: url(/assets/img/daily-word/bg-shelf.svg); }
  .game-root[data-dw-theme] { position: relative; }
  /* Sits straight on the picture, so each theme sets the colour of its bottom-left corner's
     ink (--dw-ink) and a halo of the opposite tone (--dw-halo) for the busy ones. */
  .game-root[data-dw-theme="calendar"]    { --dw-ink: #4a2f17; --dw-halo: rgba(255, 248, 236, .95); }
  .game-root[data-dw-theme="dictionary"]  { --dw-ink: #3d2a14; --dw-halo: rgba(255, 246, 228, .95); }
  .game-root[data-dw-theme="letterpress"] { --dw-ink: #fbf3e2; --dw-halo: rgba(30, 15, 5, .9); }
  .game-root[data-dw-theme="sky"]         { --dw-ink: #3b2f6b; --dw-halo: rgba(255, 255, 255, .95); }
  .game-root[data-dw-theme="paper"]       { --dw-ink: #6b7280; --dw-halo: transparent; }
  .game-root[data-dw-theme="planes"],
  .game-root[data-dw-theme="washes"],
  .game-root[data-dw-theme="bubbles"],
  .game-root[data-dw-theme="shelf"]       { --dw-ink: #6b6390; --dw-halo: transparent; }
  .dw-theme-btn {
    position: absolute; bottom: 12px; left: 12px; z-index: 2;
    display: inline-flex; align-items: center; height: 32px; padding: 0 6px;
    border: 0; background: none; color: var(--dw-ink, var(--c-text-soft));
    font-size: .8rem; font-weight: 700; cursor: pointer;
    text-shadow: 0 0 3px var(--dw-halo, transparent), 0 0 8px var(--dw-halo, transparent);
  }
  .dw-theme-btn svg {
    flex: 0 0 auto; width: 20px; height: 20px;
    fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round;
    filter: drop-shadow(0 0 2px var(--dw-halo, transparent));
  }
  /* The topic pages' How to play sits on the panel's top-right corner: its own ink per theme. */
  .game-root[data-dw-theme="calendar"] ~ .topic-howto    { --dw-ink: #fff8ec; --dw-halo: rgba(60, 30, 10, .85); }
  .game-root[data-dw-theme="dictionary"] ~ .topic-howto  { --dw-ink: #3d2a14; --dw-halo: rgba(255, 246, 228, .95); }
  .game-root[data-dw-theme="letterpress"] ~ .topic-howto { --dw-ink: #fbf3e2; --dw-halo: rgba(30, 15, 5, .9); }
  .game-root[data-dw-theme="sky"] ~ .topic-howto         { --dw-ink: #3b2f6b; --dw-halo: rgba(255, 255, 255, .95); }
  .game-root[data-dw-theme="paper"] ~ .topic-howto       { --dw-ink: #6b7280; --dw-halo: transparent; }
  .game-root[data-dw-theme="planes"] ~ .topic-howto,
  .game-root[data-dw-theme="washes"] ~ .topic-howto,
  .game-root[data-dw-theme="bubbles"] ~ .topic-howto,
  .game-root[data-dw-theme="shelf"] ~ .topic-howto       { --dw-ink: #6b6390; --dw-halo: transparent; }
  .game-root[data-dw-theme] ~ .topic-howto,
  .game-root[data-dw-theme] ~ .topic-howto:hover {
    color: var(--dw-ink);
    text-shadow: 0 0 3px var(--dw-halo), 0 0 8px var(--dw-halo);
  }
  /* The label only on hover (or keyboard focus). */
  .dw-theme-btn span {
    max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0;
    transition: max-width .2s ease, opacity .2s ease, margin .2s ease;
  }
  .dw-theme-btn:hover span, .dw-theme-btn:focus-visible span { max-width: 180px; opacity: 1; margin-left: 6px; }
}
/* The themes are wide-screen only, and so is the button that changes them. */
@media (max-width: 999px) {
  .dw-theme-btn { display: none; }
}

/* The demo's hand: daily-word.js puts its top-left corner in --x / --y. */
.dw-hand {
  position: absolute; left: 0; top: 0; z-index: 2; width: 44px; height: 46.75px;
  pointer-events: none; opacity: 0;
  transform: translate(var(--x, 0), var(--y, 0));
  transition: transform .3s cubic-bezier(.2, .7, .3, 1), opacity .25s ease;
}
.dw-hand.is-on { opacity: 1; }
.dw-hand svg {
  display: block; width: 100%; height: 100%; transform-origin: 34.4% 5.9%;
  transition: transform .1s ease; filter: drop-shadow(0 2px 2px rgba(40, 30, 80, .3));
}
.dw-hand.is-press svg { transform: scale(.86); }
.dw-key.dw-key-demo { filter: brightness(.85); }
/* One line down to a 320px screen: a second line would push the keyboard down. */
.dw-legend { font-size: .78rem; white-space: nowrap; }
.dw-sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin: 0 4px 0 12px; vertical-align: -1px; }
.dw-sw:first-child { margin-left: 0; }
@media (max-width: 380px) {
  .dw-legend { font-size: .68rem; }
  .dw-sw { margin: 0 3px 0 7px; }
}
.dw-sw.dw-correct { background: var(--c-success); }
.dw-sw.dw-present { background: var(--c-accent); }
.dw-sw.dw-absent  { background: #78848c; }

/* Durations are mirrored by FLIP_HALF and JUMP_MS in games/daily-word.js. */
.dw-tile.dw-pop { animation: dw-pop .1s ease-out; }
.dw-tile.dw-flip-out { animation: dw-flip-out .25s ease-in forwards; }
.dw-tile.dw-flip-in { animation: dw-flip-in .25s ease-out; }
.dw-tile.dw-jump { animation: dw-jump .5s ease; }
.dw-row.dw-shake { animation: dw-shake .4s ease; }
@keyframes dw-pop { 50% { transform: scale(1.12); } }
@keyframes dw-flip-out { from { transform: rotateX(0); } to { transform: rotateX(90deg); } }
@keyframes dw-flip-in { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
@keyframes dw-jump {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-28%); }
  70% { transform: translateY(4%); }
}
@keyframes dw-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
