/* The games page (ticket 12): the pill bar, the shared panel, then one block per game.
   Every game fits one phone screen (375 x 812) under the header, without scrolling.
   Ticket 13: add a block per new game at the end; the pill bar and the panel are shared. */

.games {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 1rem 0.25rem;
}

.games h1 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  text-align: center;
}

.games-page .site-footer {
  padding: 0.5rem 1.25rem 0.75rem;
}

/* The pill bar: one row; with many games it scrolls sideways rather than pushing the game down. */
.game-pills {
  display: flex;
  gap: 0.4rem;
  margin: 0 -1rem 0.6rem;
  padding: 0.2rem 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.game-pills::-webkit-scrollbar {
  display: none;
}

.game-pill {
  flex: 1 0 auto;
  width: auto;
  min-width: 3.6rem;
  min-height: 2.75rem; /* 44px */
  margin: 0;
  padding: 0.25rem 0.8rem;
  border: 1.5px solid var(--cocoa);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--cocoa);
  font-size: 0.95rem;
  white-space: nowrap;
  touch-action: manipulation;
}

.game-pill[aria-selected="true"] {
  background: var(--cocoa);
  color: #fffdf9;
}

.game-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.85rem 0.9rem;
  background: #fffdf9;
  border: 1px solid var(--stone);
  border-radius: 1.25rem;
}

.game-panel[hidden] {
  display: none;
}

.game-panel h2 {
  margin: 0;
  font-size: 1.1rem;
  text-align: center;
}

.game-lead {
  margin: 0.1rem 0 0.5rem;
  font-size: 0.92rem;
  line-height: 1.65;
  text-align: center;
}

.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.game-stage button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* site.css gives every button a display, which would show a hidden one. */
.game-stage [hidden] {
  display: none !important;
}

/* ---- The wheel ---- */
.wheel {
  width: min(19rem, 44vh, 100%);
  margin: 0.25rem auto 0;
  transition: width 0.35s ease-out;
}

/* With the card under it, the disc steps back so that both fit one screen. */
.wheel.is-small {
  width: min(13.5rem, 30vh, 100%);
}

.wheel-svg {
  display: block;
  width: 100%;
  height: auto;
}

.wheel-disc {
  transform-origin: 0 0;
  transform-box: view-box;
  will-change: transform;
}

.wheel-label {
  fill: var(--espresso);
  font-family: var(--font);
  font-weight: 700;
}

.wheel-spin {
  margin-top: 1rem;
  min-height: 3.25rem;
  font-size: 1.1rem;
}

.wheel-card {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem 0.75rem;
  background: var(--ivory);
  border: 1px solid var(--stone);
  border-radius: 1rem;
  text-align: center;
  animation: game-rise 0.35s ease-out;
}

.wheel-kicker {
  margin: 0;
  font-size: 0.85rem;
  color: var(--cocoa);
}

.wheel-value {
  margin: 0;
  color: var(--cocoa);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.5;
}

.wheel-challenge {
  margin: 0.15rem 0 0;
  font-size: 1rem;
  line-height: 1.7;
}

.wheel-pledge {
  margin-top: 0.65rem;
}

.wheel-pledge.is-done {
  opacity: 1;
  background: #dcebdd;
  color: #2f5a3a;
  border: 1.5px solid #b5d6bc;
}

.wheel-note {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--cocoa);
}

.wheel-again {
  min-height: 2.75rem;
  margin-top: 0.4rem;
  padding: 0.3rem 1rem;
  background: transparent;
  color: var(--cocoa);
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

/* ---- Memory match ---- */
.memory-counters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.memory-counter {
  flex: 1;
  margin: 0;
  padding: 0.2rem 0.5rem;
  background: var(--ivory);
  border: 1px solid var(--stone);
  border-radius: 999px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--cocoa);
}

.memory-number {
  display: inline-block;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--espresso);
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.memory-card {
  position: relative;
  display: block;
  width: 100%;
  min-height: 4.6rem;
  height: min(4.9rem, 10.5vh);
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--cocoa);
  border-radius: 0.8rem;
  background: var(--cocoa);
  color: var(--espresso);
  font-weight: 700;
  transition: transform 0.18s ease-out;
}

.memory-card:active {
  transform: scale(0.96);
}

.memory-back,
.memory-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.memory-back svg {
  width: 1.9rem;
  height: 1.9rem;
}

.memory-face {
  display: none;
  gap: 0.05rem;
  padding: 0.15rem;
  background: #fffdf9;
}

.memory-face svg {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
}

.memory-word {
  max-width: 100%;
  font-size: 0.86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.memory-card.is-up {
  background: #fffdf9;
  border-color: var(--stone);
  animation: memory-turn 0.22s ease-out;
}

.memory-card.is-up .memory-back {
  display: none;
}

.memory-card.is-up .memory-face {
  display: flex;
}

.memory-card.is-found {
  opacity: 1;
  border-color: #8fbf9b;
}

.memory-card.is-found .memory-face {
  background: #eaf4ea;
}

.memory-card.is-miss {
  border-color: #d9a59c;
}

.memory-card.is-miss .memory-face {
  background: #fbefec;
}

.memory-status {
  min-height: 2.9rem;
  margin: 0.45rem 0 0;
  white-space: pre-line;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.5;
  font-weight: 600;
  color: var(--cocoa);
}

.memory-status.is-good,
.memory-status.is-done {
  color: #2f5a3a;
}

.memory-status.is-miss {
  color: #7a2e22;
}

.memory-again {
  min-height: 2.75rem;
  margin-top: 0.25rem;
  padding: 0.3rem 1rem;
  border: 1.5px solid var(--cocoa);
  background: #fffdf9;
  color: var(--cocoa);
}

.memory-again.is-ready {
  background: var(--cocoa);
  color: #fffdf9;
}

@keyframes game-rise {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@keyframes memory-turn {
  from {
    transform: rotateY(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-card,
  .memory-card.is-up {
    animation: none;
  }
  .memory-card,
  .wheel {
    transition: none;
  }
  .wheel-disc {
    transition: none !important;
  }
}

/* ==== Ticket 13: the plant, word order and key-catching ==== */

/* Shared by the three: a small counter pill, a status line, a play-again button. */
.plant-meter,
.phrases-counter,
.keys-counter {
  margin: 0;
  padding: 0.2rem 0.5rem;
  background: var(--ivory);
  border: 1px solid var(--stone);
  border-radius: 999px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--cocoa);
}

.plant-number,
.phrases-number,
.keys-number {
  display: inline-block;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  color: var(--espresso);
}

.plant-status,
.phrases-status {
  min-height: 2.9rem;
  margin: 0.4rem 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.5;
  font-weight: 600;
  color: var(--cocoa);
}

.plant-status.is-good,
.plant-status.is-done,
.phrases-status.is-good,
.phrases-status.is-done {
  color: #2f5a3a;
}

.plant-status.is-miss,
.phrases-status.is-miss {
  color: #7a2e22;
}

.plant-again {
  min-height: 2.75rem;
  margin-top: 0.25rem;
  padding: 0.3rem 1rem;
  border: 1.5px solid var(--cocoa);
  background: #fffdf9;
  color: var(--cocoa);
}

.plant-again.is-ready {
  background: var(--cocoa);
  color: #fffdf9;
}

/* ---- The plant ---- */
.plant-scene {
  display: flex;
  justify-content: center;
}

.plant-svg {
  display: block;
  width: auto;
  height: min(8.4rem, 17vh);
}

.plant-svg [data-step] {
  opacity: 0;
  transform: translateY(10px) scale(0.7);
  transform-origin: 80px 112px;
  transform-box: view-box;
  transition:
    opacity 0.35s ease-out,
    transform 0.45s ease-out;
}

.plant-svg [data-step].is-grown {
  opacity: 1;
  transform: none;
}

.plant-meter {
  align-self: center;
  margin: 0.1rem 0 0.5rem;
  padding-inline: 1rem;
}

.plant-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.plant-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  min-height: 3.2rem;
  margin: 0;
  padding: 0.2rem 0.4rem;
  border: 1.5px solid var(--stone);
  border-radius: 0.8rem;
  background: var(--ivory);
  color: var(--espresso);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  transition: transform 0.15s ease-out;
}

.plant-choice:active {
  transform: scale(0.97);
}

.plant-choice:disabled {
  opacity: 1;
}

.plant-text {
  overflow-wrap: anywhere;
}

/* The mark says the result in a shape as well as a colour. */
.plant-mark {
  flex: none;
  font-weight: 700;
}

.plant-choice.is-good {
  background: #eaf4ea;
  border-color: #8fbf9b;
  color: #2f5a3a;
}

.plant-choice.is-good .plant-mark::before {
  content: "✓";
}

.plant-choice.is-miss {
  background: #fbefec;
  border-color: #d9a59c;
  color: #7a2e22;
  animation: game-nudge 0.3s ease-out;
}

.plant-choice.is-miss .plant-mark::before {
  content: "×";
}

.plant-choices.is-done .plant-choice:not(.is-good):not(.is-miss) {
  color: #6f625c;
}

/* ---- Word order ---- */
.phrases-counter {
  align-self: center;
  margin-bottom: 0.6rem;
  padding-inline: 1rem;
}

.phrases-line,
.phrases-pool {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 7.2rem;
  padding: 0.5rem;
  border-radius: 1rem;
}

/* The line is where the phrase is built: it fills from the right, as Arabic is read. */
.phrases-line {
  justify-content: flex-start;
  align-content: flex-start;
  background: var(--ivory);
  border: 1.5px dashed var(--cocoa);
}

.phrases-line.is-good {
  background: #eaf4ea;
  border: 1.5px solid #8fbf9b;
}

.phrases-pool {
  margin-top: 0.6rem;
}

.phrases-chip {
  width: auto;
  min-width: 3.25rem;
  min-height: 2.9rem;
  margin: 0;
  padding: 0.2rem 0.85rem;
  border: 1.5px solid var(--cocoa);
  border-radius: 0.8rem;
  background: #fffdf9;
  color: var(--espresso);
  font-size: 1.05rem;
  font-weight: 700;
  animation: game-rise 0.2s ease-out;
}

.phrases-chip:disabled {
  opacity: 1;
}

.phrases-line .phrases-chip {
  background: #f3e7d6;
}

.phrases-line.is-good .phrases-chip {
  background: #fffdf9;
  border-color: #8fbf9b;
  color: #2f5a3a;
}

.phrases-chip.is-miss {
  background: #fbefec;
  border-color: #d9a59c;
  color: #7a2e22;
  animation: game-nudge 0.3s ease-out;
}

.phrases-next,
.phrases-again {
  min-height: 3rem;
  margin-top: 0.4rem;
}

/* ---- Key-catching ---- */
.keys-hud {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.keys-counter {
  flex: 1;
}

.keys-number {
  min-width: 1.5em;
}

/* The finger moves the basket here, so the page must not scroll or zoom under it. */
.keys-area {
  position: relative;
  flex: 1;
  min-height: min(22rem, 46vh);
  overflow: hidden;
  background: linear-gradient(#f3f7fa, var(--ivory) 70%);
  border: 1px solid var(--stone);
  border-radius: 1rem;
  direction: ltr;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
}

.keys-area:focus-visible {
  outline: 2px solid var(--cocoa);
  outline-offset: 2px;
}

.keys-thing {
  position: absolute;
  top: 0;
  left: 0;
  width: 4.5rem;
  height: 3.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  visibility: hidden;
  pointer-events: none;
  will-change: transform;
}

.keys-thing.is-live {
  visibility: visible;
}

.keys-thing::before {
  content: "";
  flex: none;
  width: 2.9rem;
  height: 1.75rem;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 24'%3E%3Cg stroke='%236A4C46' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='12' r='7.5' fill='%23f3dc9a'/%3E%3Ccircle cx='10' cy='12' r='2.4' fill='%23fffdf9'/%3E%3Cpath d='M17.5 12H37M30 12v6M36 12v5' fill='none'/%3E%3C/g%3E%3C/svg%3E");
}

.keys-thing.is-cloud::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 24'%3E%3Cpath d='M11 21a6 6 0 0 1-.8-11.9A9 9 0 0 1 27.4 8 6.6 6.6 0 0 1 29 21z' fill='%23CEC3B7' stroke='%236A4C46' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.keys-word {
  direction: rtl;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: #fffdf9;
  border: 1px solid #e3c9a8;
  color: var(--espresso);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.55;
  white-space: nowrap;
}

.keys-thing.is-cloud .keys-word {
  background: #efeae4;
  border-color: var(--stone);
  color: #4e433f;
}

.keys-basket {
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 5.5rem;
  height: 2.75rem;
  pointer-events: none;
  will-change: transform;
}

.keys-basket-inner,
.keys-basket svg {
  display: block;
  width: 100%;
  height: 100%;
}

.keys-basket-inner.is-good {
  animation: keys-good 0.3s ease-out;
}

.keys-basket-inner.is-miss {
  animation: keys-miss 0.3s ease-out;
}

.keys-basket-inner.is-miss svg {
  opacity: 0.55;
}

.keys-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1rem 1rem 4rem;
  direction: rtl;
  text-align: center;
  background: rgba(247, 242, 234, 0.82);
}

.keys-closing {
  margin: 0;
  color: var(--cocoa);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.6;
}

.keys-result {
  margin: 0 0 0.4rem;
  white-space: pre-line;
  font-size: 0.95rem;
  line-height: 1.7;
  font-weight: 600;
  color: var(--espresso);
}

.keys-go {
  width: auto;
  min-width: 11rem;
  min-height: 3.25rem;
  margin: 0;
  font-size: 1.1rem;
}

.keys-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--cocoa);
}

@keyframes game-nudge {
  30% {
    transform: translateX(4px);
  }
  65% {
    transform: translateX(-3px);
  }
}

@keyframes keys-good {
  40% {
    transform: scale(1.12);
  }
}

@keyframes keys-miss {
  35% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .plant-svg [data-step],
  .plant-choice {
    transition: none;
  }
  .plant-choice.is-miss,
  .phrases-chip,
  .phrases-chip.is-miss,
  .keys-basket-inner.is-good,
  .keys-basket-inner.is-miss {
    animation: none;
  }
}
/* ==== end of ticket 13 ==== */
