/* Memory styles. The theme and the shared controls are in ../shared/base.css.
   Play: flat bold colours. The whole screen is the colour of the player whose turn it is. */

:root {
  --ink: #14162b; /* text and card backs on the coloured play screen */
  --flip-ms: 420ms;
}

.names { display: flex; flex-direction: column; gap: 8px; }
.names .row input { border-left: 6px solid var(--c, var(--line)); }
.chip .emo { font-size: 18px; margin-right: 4px; vertical-align: -2px; }

/* ---------- Play ---------- */
.play {
  --pc: var(--accent); /* the current player's colour */
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right))
    calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  background: var(--pc);
  color: var(--ink);
  transition: background-color 600ms ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}

.bar {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "turn menu" "scores scores";
  align-items: center;
  gap: 8px 10px;
}
.turn {
  grid-area: turn;
  margin: 0;
  font-weight: 900;
  font-size: clamp(24px, 7.5vw, 44px);
  letter-spacing: -1px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn.pop { animation: turn-in 420ms cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes turn-in {
  from { transform: translateY(10px) scale(0.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.menu-btn {
  grid-area: menu;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(20, 22, 43, 0.14);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.scores { grid-area: scores; display: flex; gap: 8px; flex-wrap: wrap; }
.score {
  --c: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--c);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-weight: 800;
  font-size: clamp(15px, 1.2vw + 8px, 19px);
  box-shadow: 0 0 0 2px rgba(20, 22, 43, 0.14);
  transition: transform 300ms ease, box-shadow 300ms ease;
  max-width: 100%;
}
.score .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9em; }
.score b {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0 6px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
/* The current player's chip has a white ring, so it shows on its own colour. */
.score.on { box-shadow: 0 0 0 3px #fff, 0 6px 16px rgba(20, 22, 43, 0.25); transform: scale(1.06); }
.score.bump b { animation: bump 450ms cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes bump { 40% { transform: scale(1.5); } }
.score.solo { padding: 6px 14px; box-shadow: none; background: rgba(255, 255, 255, 0.5); font-variant-numeric: tabular-nums; }

/* ---------- Board ---------- */
.board { flex: 1; min-height: 0; display: grid; place-items: center; }
.grid { display: grid; justify-content: center; align-content: center; }

.card {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
  cursor: pointer;
  border-radius: 14px;
  -webkit-tap-highlight-color: transparent;
}
.card:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.card .in {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform var(--flip-ms) cubic-bezier(0.3, 0.1, 0.25, 1.25);
}
.card.up .in { transform: rotateY(180deg); }
.card .back,
.card .face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid;
  place-items: center;
}
/* Neutral back: dark ink with a soft ring and dot. */
.card .back {
  background: var(--ink);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.07), 0 4px 0 rgba(20, 22, 43, 0.22);
  transition: background-color 200ms ease;
}
.card .back::after {
  content: "";
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.16);
}
@media (hover: hover) {
  .card:not(.up):hover .back { background: #262a50; }
}
.card .face {
  transform: rotateY(180deg);
  background: #fff;
  box-shadow: 0 4px 0 rgba(20, 22, 43, 0.18);
  font-size: var(--emo, 40px);
  line-height: 1;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
/* A found set takes the finder's colour, with a white ring so it shows on the same colour. */
.card.won .face {
  background: var(--oc);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.85);
  transition: background-color 300ms ease 150ms;
}
.card.won { cursor: default; }
.card.pop { animation: pop 520ms cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
.card.shake { animation: shake 420ms ease-in-out; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px) rotate(-2deg); }
  40%, 80% { transform: translateX(6px) rotate(2deg); }
}
/* No taps while a miss shows or a set pops. */
.grid.locked .card { pointer-events: none; cursor: default; }

/* The emoji that flies from a found set to the finder's score. */
.flyer {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  line-height: 1;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

/* "Ben's turn" / "Set! Go again" in the middle of the screen for a moment. */
.banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 15;
  margin: 0;
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  font-size: clamp(22px, 6vw, 34px);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}
.banner.show { animation: banner 1100ms ease forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  28%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* Sideways phone: one row on top, turn left, scores middle, ✕ right. */
@media (orientation: landscape) and (max-height: 560px) {
  .play { gap: 6px; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .bar { grid-template-columns: auto 1fr auto; grid-template-areas: "turn scores menu"; }
  .turn { font-size: 24px; max-width: 34vw; }
  .scores { flex-wrap: nowrap; justify-content: flex-end; padding: 4px; min-width: 0; }
  .score { min-width: 0; flex-shrink: 1; }
  .score { padding: 4px 6px 4px 12px; font-size: 14px; }
  .score .nm { max-width: 6em; }
  .score b { min-width: 24px; height: 24px; }
  .menu-btn { width: 38px; height: 38px; }
}

/* ---------- Results ---------- */
.results { justify-content: center; align-items: center; overflow-y: auto; touch-action: pan-y; }
.results-box {
  width: 100%;
  max-width: 440px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  text-align: center;
}
.res-icon { font-size: 76px; line-height: 1; animation: drop 700ms cubic-bezier(0.2, 1.5, 0.4, 1); }
.res-title { font-size: clamp(32px, 10vw, 48px); font-weight: 900; letter-spacing: -1.5px; line-height: 1.05; margin: 0; }
.res-sub { margin: -6px 0 0; font-weight: 700; opacity: 0.75; font-size: 17px; }
@keyframes drop {
  from { transform: translateY(-40px) scale(0.5) rotate(-15deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.res-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.res-list li {
  --c: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--c);
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8);
  animation: slide-in 450ms cubic-bezier(0.2, 1.2, 0.4, 1) both;
  animation-delay: calc(var(--i, 0) * 110ms + 250ms);
  text-align: left;
}
.res-list li .rk { width: 1.8em; opacity: 0.6; font-variant-numeric: tabular-nums; }
.res-list li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-list li .pts { font-variant-numeric: tabular-nums; }
.res-list li.stat { background: rgba(255, 255, 255, 0.55); box-shadow: none; }
.res-list li.new { box-shadow: 0 0 0 3px var(--ink); }
@keyframes slide-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.res-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.btn.ink { background: var(--ink); color: #fff; }
.btn.ink-ghost { color: var(--ink); border: 2px solid rgba(20, 22, 43, 0.35); }

.stop-sheet .stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.stop-sheet .btn { width: 100%; }

/* Less motion: no flips, shakes, pops or flights; cards change at once. */
@media (prefers-reduced-motion: reduce) {
  :root { --flip-ms: 0ms; }
  .card .in { transition: none; }
  .card.pop, .card.shake, .turn.pop, .res-icon, .res-list li, .score.bump b { animation: none; }
  .banner.show { animation: banner-fade 1100ms linear forwards; transform: translate(-50%, -50%); }
  .play { transition-duration: 200ms; }
}
@keyframes banner-fade {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}
