/* WC-PRACTICE-01: local Word Connect practice demo styles. Same light Pearl/Pink/Gold surface
   and raised-tile language as the Word Predictor demo (own copy; no shared CSS between games).
   Base colours are approved tokens from docs/DESIGN-SYSTEM.md; --wc-* values are demo-local.
   No external fonts or images; motion is cosmetic and off under prefers-reduced-motion. */
:root {
  --ac-primary: #6C3BFF;
  --ac-success: #14B8A6;
  --ac-premium: #D4AF37;
  --ac-bg-dark: #0B1220;
  --wc-ink: #2A1B3D;
  --wc-ink-muted: #5B4B6B;
  --wc-pink-deep: #DB2777;
  --wc-pink-ink: #BE185D;
  --wc-blush: #FDF2F8;
  --wc-blush-200: #FBCFE8;
  --wc-line: #E7D8EC;
  --wc-edge: #9C86AE;
  --wc-lip: #E3D0EA;
  --wc-primary-gradient: linear-gradient(135deg, #6C3BFF 0%, #A133E8 48%, #DB2777 100%);
  --wc-ring: 0 0 0 2px #FFFFFF, 0 0 0 5px var(--wc-pink-deep), 0 0 0 10px rgba(236, 72, 153, 0.16);
  --wc-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --wc-font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  display: flow-root;
  margin: 0;
  min-height: 100dvh;
  color: var(--wc-ink);
  font-family: var(--wc-font);
  line-height: 1.4;
  background:
    radial-gradient(1000px 600px at 0% 0%, #FFE6F1 0%, rgba(255, 230, 241, 0) 60%),
    radial-gradient(900px 600px at 100% 0%, #F1EBFF 0%, rgba(241, 235, 255, 0) 58%),
    radial-gradient(1000px 640px at 100% 100%, #FFF0CC 0%, rgba(255, 240, 204, 0) 60%),
    linear-gradient(160deg, #FFF9F6 0%, #FDF4F9 45%, #FBF6FF 70%, #FFFAF0 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
}

.orb-peach { top: -120px; left: -100px; width: 400px; height: 400px; background: radial-gradient(circle, rgba(255, 190, 160, 0.5), rgba(255, 190, 160, 0) 70%); }
.orb-lavender { top: -80px; right: -120px; width: 440px; height: 440px; background: radial-gradient(circle, rgba(196, 181, 253, 0.45), rgba(196, 181, 253, 0) 70%); }
.orb-gold { right: -140px; bottom: -140px; width: 500px; height: 500px; background: radial-gradient(circle, rgba(250, 204, 21, 0.3), rgba(250, 204, 21, 0) 70%); }

.game {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

@media (min-width: 560px) {
  .game {
    min-height: auto;
    margin: 14px auto;
    padding: 20px 24px;
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    border-radius: 32px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 251, 253, 0.88));
    box-shadow: 0 0 0 1px rgba(219, 39, 119, 0.1), 0 50px 90px -46px rgba(190, 24, 93, 0.45), 0 22px 44px -28px rgba(42, 27, 61, 0.3);
  }
}

.game-header {
  text-align: center;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--wc-pink-ink);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 10px;
  margin: 6px 0 0;
}

.mode-badge {
  padding: 3px 11px;
  border: 1.5px solid var(--wc-blush-200);
  border-radius: 999px;
  background: var(--wc-blush);
  color: var(--wc-pink-ink);
  font-size: 0.75rem;
  font-weight: 800;
}

.demo-note,
.no-points {
  color: var(--wc-ink-muted);
  font-size: 0.8125rem;
}

/* ---------- Controls ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.round-picker {
  display: inline-flex;
  align-items: center;
  gap: 0; /* 44px segments: keeps the picker and New board on one row on desktop */
  margin: 0;
  padding: 3px;
  border: 1.5px solid var(--wc-line);
  border-radius: 16px;
  background: #FFFFFF;
  box-shadow: 0 3px 0 var(--wc-lip);
}

.round-legend {
  float: left;
  padding: 0 6px 0 8px;
  color: var(--wc-ink-muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.segment {
  position: relative;
  display: inline-flex;
}

.segment input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.segment span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
}

.segment input:checked + span {
  background: var(--wc-primary-gradient);
  color: #FFFFFF;
}

.segment input:focus-visible + span {
  box-shadow: var(--wc-ring);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 220ms var(--wc-spring);
}

.btn:active:not(:disabled) {
  transform: translateY(2px) scale(0.96);
  transition-duration: 60ms;
}

.btn-secondary {
  border: 1.5px solid var(--wc-line);
  background: linear-gradient(180deg, #FFFFFF, #FBF7FC);
  color: var(--wc-ink);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 3px 0 var(--wc-lip);
}

.btn-primary {
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: var(--wc-primary-gradient);
  color: #FFFFFF;
  text-shadow: 0 1px 1px rgba(42, 27, 61, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 0 #5A22C9;
}

.btn-ghost {
  min-height: 44px;
  border: 1.5px dashed var(--wc-edge);
  background: transparent;
  color: var(--wc-ink-muted);
}

.btn:disabled {
  border-color: #E5E7EB;
  background: #F1F1F4;
  color: #8A8F98;
  text-shadow: none;
  box-shadow: none;
  cursor: not-allowed;
}

:focus-visible {
  outline: none;
  box-shadow: var(--wc-ring);
}

/* ---------- Progress ---------- */
.progress {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
}

.progress p {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
}

.found {
  color: var(--wc-pink-ink);
}

/* ---------- Crossword-style slots ---------- */
.slots {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(251, 244, 251, 0.95), rgba(253, 246, 240, 0.95));
  box-shadow: inset 0 2px 6px rgba(190, 24, 93, 0.08);
}

.slot-row {
  display: flex;
  gap: 4px;
}

.cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(26px, 8vw, 34px);
  height: clamp(26px, 8vw, 34px);
  border: 2px solid var(--wc-edge);
  border-radius: 9px;
  background: #FFFFFF;
  font-weight: 900;
  font-size: clamp(0.85rem, 3.6vw, 1.05rem);
}

.slot-row.found .cell {
  border-color: transparent;
  background: linear-gradient(180deg, #6EF0DC, #14B8A6);
  color: var(--wc-ink);
  box-shadow: 0 3px 0 #0B8C80;
}

.slot-row.revealed .cell {
  border-color: transparent;
  background: linear-gradient(180deg, #8A9BB6, #5E6E89);
  color: #FFFFFF;
  box-shadow: 0 3px 0 #435069;
}

/* Success language: springy pop, cascading across the word. */
.slot-row.found-now .cell {
  animation: cell-pop 520ms var(--wc-spring) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes cell-pop {
  0% { scale: 0.5; translate: 0 6px; }
  60% { scale: 1.15; translate: 0 -6px; }
  100% { scale: 1; translate: 0 0; }
}

.slots.celebrate .slot-row {
  animation: row-cheer 700ms var(--wc-spring);
}

@keyframes row-cheer {
  0%, 100% { translate: 0 0; }
  40% { translate: 0 -6px; }
}

/* ---------- Word display and wheel ---------- */
/* The top of .play-area is a reserved toast lane (--wc-toast-lane = one toast line: 8px + 1.4 * 1rem
   + 8px). The toast lives only in that lane, so it never covers the word display, the wheel or the
   action controls; multi-line toasts (narrow screens) grow upward, away from them. */
.play-area {
  --wc-toast-lane: 2.4rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-top: calc(var(--wc-toast-lane) + 8px);
}

.word-display {
  min-width: 140px;
  min-height: 44px;
  margin: 0;
  padding: 6px 18px;
  border: 2px solid var(--wc-line);
  border-radius: 14px;
  background: #FFFFFF;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-align: center;
}

.word-display.empty::before {
  content: "Tap letters";
  color: var(--wc-ink-muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0;
}

.word-display.pulse {
  animation: word-pulse 200ms ease-out;
}

/* Failure language: horizontal shake with a red edge flash, never a bounce. */
.word-display.shake,
.word-display.nudge {
  animation: word-deny 440ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes word-pulse {
  50% { scale: 1.05; }
}

@keyframes word-deny {
  0%, 100% { translate: 0 0; border-color: var(--wc-line); }
  15% { translate: -8px 2px; border-color: #E11D48; }
  35% { translate: 7px 2px; border-color: #E11D48; }
  55% { translate: -5px 1px; }
  75% { translate: 3px 0; }
}

.wheel {
  --size: min(250px, 66vw);
  --r: calc(var(--size) / 2 - 32px);
  position: relative;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle, #FFFFFF 0%, #FBF4FB 70%);
  box-shadow: inset 0 2px 8px rgba(190, 24, 93, 0.1), 0 0 0 1.5px var(--wc-line);
}

.wheel.spin {
  animation: wheel-spin 480ms var(--wc-spring);
}

@keyframes wheel-spin {
  from { rotate: -40deg; }
  to { rotate: 0deg; }
}

.wheel-tile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: 2px solid var(--wc-edge);
  border-radius: 14px;
  background: linear-gradient(180deg, #FFFFFF, #FBF6FC);
  color: var(--wc-ink);
  box-shadow: inset 0 2px 0 #FFFFFF, 0 4px 0 #CDB5DB, 0 10px 14px -8px rgba(42, 27, 61, 0.3);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  transform: rotate(var(--a)) translate(var(--r)) rotate(calc(-1 * var(--a)));
  transition: background-color 160ms ease, box-shadow 160ms ease;
  touch-action: manipulation;
}

.wheel-tile.used {
  border-color: transparent;
  background: linear-gradient(180deg, #F9A8D4, #EC4899);
  color: #FFFFFF;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 2px 0 #BE185D;
}

.wheel-tile:disabled {
  opacity: 0.6;
  cursor: default;
}

.wheel.entering .wheel-tile,
.slots.entering .slot-row {
  animation: enter-pop 460ms var(--wc-spring) both;
}

@keyframes enter-pop {
  from { opacity: 0; scale: 0.6; }
  to { opacity: 1; scale: 1; }
}

/* ---------- Actions / extras ---------- */
.actions,
.extras {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.bonus {
  margin: 0;
  max-width: 100%;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: center;
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  bottom: calc(100% - var(--wc-toast-lane));
  left: 50%;
  z-index: 3;
  width: max-content;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 14px;
  color: #FFFFFF;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-success { background: linear-gradient(180deg, #14B8A6, #0B8C80); }
.toast.is-info { background: linear-gradient(180deg, #3B2A4F, var(--wc-ink)); }
.toast.is-error { background: linear-gradient(180deg, #BE123C, #9F1239); }

.toast.is-success.visible {
  animation: toast-pop 420ms var(--wc-spring);
}

.toast.is-error.visible {
  animation: toast-wobble 420ms ease-in-out;
}

@keyframes toast-pop {
  0% { scale: 0.6; }
  60% { scale: 1.1; }
  100% { scale: 1; }
}

@keyframes toast-wobble {
  0%, 100% { translate: 0 0; }
  25% { translate: -6px 0; }
  50% { translate: 5px 0; }
  75% { translate: -3px 0; }
}

@media (max-width: 360px) {
  .round-legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .wheel-tile {
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
