/*
  Word Scramble App Styles (Layer 3)
  Loaded after papupa.css — relies on --pa-* design tokens.
  All game-specific vars use --ws-* prefix.
*/

/* ── Leaderboard theme overrides ─────────────────────────────────── */
:root {
  --lb-primary:    #e67e22;
  --lb-secondary:  #3498db;
  --lb-bg:         #fffaf5;
  --lb-gold:       #FFD700;
  --lb-silver:     #C0C0C0;
  --lb-bronze:     #CD7F32;
  --lb-row-hover:  rgba(230, 126, 34, 0.08);
  --lb-row-me:     rgba(230, 126, 34, 0.15);

  /* Game-specific palette */
  --ws-primary:   #e67e22;
  --ws-secondary: #3498db;
  --ws-success:   #27ae60;
  --ws-error:     #e74c3c;
  --ws-accent:    #9b59b6;
}

body {
  background-color: #fffbf5;
  background-image:
    radial-gradient(at 0% 0%,   rgba(230, 126, 34, 0.04) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(52, 152, 219, 0.04) 0px, transparent 50%);
}

#ws-app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  font-family: var(--font-body);
  color: var(--pa-color-text);
  padding: var(--space-sm);
  box-sizing: border-box;
}

/* ── Game card ─────────────────────────────────────────────────────── */
.ws-card {
  background-color: #ffffff;
  border-radius: 22px;
  box-shadow: 0 7px 21px rgba(0, 0, 0, 0.1);
  padding: var(--space-lg) var(--space-sm);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  max-width: 420px;
  margin: 0 auto var(--space-xl);
}

.ws-card.ws-correct-flash {
  box-shadow: 0 0 0 4px var(--ws-success), 0 7px 21px rgba(0,0,0,0.1);
}

.ws-card.ws-wrong-flash {
  box-shadow: 0 0 0 4px var(--ws-error), 0 7px 21px rgba(0,0,0,0.1);
}

/* ── HUD ───────────────────────────────────────────────────────────── */
.ws-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  font-family: var(--font-heading);
}

.ws-progress-pill {
  background-color: var(--ws-primary);
  color: #fff;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-md);
  font-weight: bold;
}

.ws-score-pill {
  background-color: #ffc107;
  color: #333;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-md);
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Round progress bar ────────────────────────────────────────────── */
.ws-round-track {
  width: 100%;
  height: 6px;
  background-color: #fde8d4;
  border-radius: 3px;
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.ws-round-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ws-primary), #f39c12);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Clue area ─────────────────────────────────────────────────────── */
.ws-clue-area {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ws-primary), #f39c12);
  box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
  margin: 0 auto var(--space-md);
  cursor: default;
}

.ws-clue-image {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 50%;
}

.ws-clue-emoji {
  font-size: 3rem;
  line-height: 1;
}

/* ── Answer slots ──────────────────────────────────────────────────── */
.ws-slots-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
  min-height: 52px;
  cursor: default;
}

.ws-slot {
  width: 38px;
  height: 46px;
  border: 2px solid #ddd;
  border-bottom: 3px solid var(--ws-secondary);
  border-radius: 8px;
  background-color: #eaf4fb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--pa-color-text);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  text-transform: uppercase;
}

.ws-slot--filled {
  border-color: var(--ws-primary);
  border-bottom-color: var(--ws-primary);
  background-color: #fef3e8;
  color: var(--ws-primary);
  animation: ws-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ws-slot--reveal {
  border-color: var(--ws-success);
  border-bottom-color: var(--ws-success);
  background-color: #eafaf1;
  color: var(--ws-success);
  animation: ws-reveal 0.3s ease forwards;
  animation-fill-mode: both;
}

.ws-slot:disabled {
  cursor: default;
}

/* ── Scrambled letter tiles ────────────────────────────────────────── */
.ws-tiles-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-md);
}

.ws-tile {
  width: 44px;
  height: 50px;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
  text-transform: uppercase;
  padding: 0;
  user-select: none;
}

.ws-tile:hover:not(:disabled):not(.ws-tile--used) {
  transform: translateY(-3px);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.2);
}

.ws-tile:active:not(:disabled):not(.ws-tile--used) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.ws-tile--used {
  opacity: 0.2;
  cursor: default;
  box-shadow: none;
}

/* ── Hint panel ────────────────────────────────────────────────────── */
.ws-hint-panel {
  background: linear-gradient(135deg, #fff8f0, #fff3e0);
  border: 1.5px solid #ffd180;
  border-radius: 14px;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.ws-hint-emoji-badge {
  font-size: 2.2rem;
  line-height: 1;
}

.ws-hint-text {
  margin: 0;
  font-size: var(--font-size-md);
  color: var(--pa-color-text);
  font-weight: 600;
  text-align: center;
}

/* ── Hint button ───────────────────────────────────────────────────── */
.ws-hint-row {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-sm);
  min-height: 2.5rem;
}

.ws-hint-btn {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-heading);
  font-size: var(--font-size-md);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(230, 126, 34, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ws-hint-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(230, 126, 34, 0.4);
}

/* ── Timer bar ─────────────────────────────────────────────────────── */
.ws-timer-track {
  position: relative;
  width: 100%;
  height: 18px;
  background-color: #f0f0f0;
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.ws-timer-fill {
  height: 100%;
  border-radius: 9px;
}

.ws-timer-label {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  pointer-events: none;
}

/* ── Feedback banner ───────────────────────────────────────────────── */
.ws-feedback {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: var(--space-sm);
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: #fff;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-sizing: border-box;
  text-align: center;
}

.ws-feedback--show {
  transform: translateY(0);
}

.ws-feedback--correct {
  background-color: var(--ws-success);
}

.ws-feedback--wrong {
  background-color: var(--ws-error);
}

/* ── Streak popup ──────────────────────────────────────────────────── */
.ws-streak-popup {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background-color: #ffc107;
  color: #333;
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: 800;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 10;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
  pointer-events: none;
}

.ws-streak-popup--show {
  transform: translate(-50%, -50%) scale(1);
}

/* ── Hidden keyboard input ─────────────────────────────────────────── */
.ws-hidden-input {
  position: absolute;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes ws-pop {
  0%   { transform: scale(0.7); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes ws-bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40%                      { transform: translateY(-18px); }
  60%                      { transform: translateY(-9px); }
}

@keyframes ws-shake {
  0%, 100%                { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80%      { transform: translateX(10px); }
}

@keyframes ws-reveal {
  0%   { opacity: 0; transform: scale(0.5) rotateY(90deg); }
  60%  { transform: scale(1.1) rotateY(0deg); }
  100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

.ws-anim-bounce { animation: ws-bounce 0.9s ease; }
.ws-anim-shake  { animation: ws-shake 0.5s ease; }

/* ══════════════════════════════════════════════════════════════════════
   WELCOME SCREEN
══════════════════════════════════════════════════════════════════════ */
.ws-welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: var(--space-sm) 0 var(--space-xl);
}

.ws-title-playful {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 7vw, 3rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--ws-primary), #f39c12);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(2px 2px 4px rgba(230, 126, 34, 0.18));
  margin-bottom: var(--space-xs);
  line-height: 1.25;
}

.ws-subtitle-friendly {
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  color: var(--pa-color-text-muted);
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.ws-level-selection-card {
  background-color: #fff;
  border-radius: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
  padding: var(--space-lg) var(--space-md);
  margin-bottom: var(--space-md);
  width: 100%;
}

.ws-level-card-header {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--ws-primary);
  text-align: center;
  margin-bottom: var(--space-lg);
}

.ws-level-cards-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.ws-level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background-color: #fff;
  border-radius: 24px;
  padding: var(--space-md) var(--space-sm);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  outline: none;
  font-family: inherit;
  border: 2px solid #eef2f6;
}

.ws-level-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
  border-color: #cbd5e1;
}

.ws-level-card.ws-active {
  border: 4px solid var(--ws-primary);
  box-shadow: 0 0 20px rgba(230, 126, 34, 0.22);
  background-color: #fff8f2;
}

.ws-level-card-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  line-height: 1;
}

.ws-level-card-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: var(--font-size-md);
  color: var(--pa-color-text);
  margin-bottom: 4px;
}

.ws-level-card-desc {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--pa-color-text-muted);
  line-height: 1.4;
  margin-bottom: 3px;
}

.ws-level-card-example {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  color: var(--ws-primary);
  opacity: 0.8;
}

.ws-badges-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  width: 100%;
  align-items: center;
}

.ws-badges-row {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
}

.ws-badge-pill {
  background-color: #fff;
  border: 1.5px solid var(--pa-color-border, #e8e0f0);
  border-radius: var(--radius-pill, 999px);
  padding: 8px 18px;
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--pa-color-text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ws-badge-highlight {
  color: var(--ws-primary);
  font-weight: 800;
}

.ws-actions-row {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: var(--space-sm);
}

.ws-start-btn {
  background: linear-gradient(135deg, var(--ws-primary), #f39c12);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(230, 126, 34, 0.35);
  transition: all 0.2s ease;
  width: 100%;
  max-width: 240px;
}

.ws-start-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(230, 126, 34, 0.45);
}

.ws-start-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* ══════════════════════════════════════════════════════════════════════
   RESULT SCREEN
══════════════════════════════════════════════════════════════════════ */
.ws-result-screen {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  box-sizing: border-box;
}

.ws-result-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-sm) var(--space-lg);
}

.ws-result-header {
  text-align: center;
  width: 100%;
}

.ws-result-emoji {
  font-size: 4.2rem;
  line-height: 1;
  margin-bottom: var(--space-sm);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.12));
}

.ws-result-heading {
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  margin: 0 0 var(--space-xs);
  line-height: 1.15;
}

.ws-result-heading--win  { color: var(--ws-primary); }
.ws-result-heading--loss { color: var(--ws-error); }

.ws-result-subheading {
  margin: 0;
  font-size: var(--font-size-md);
  color: var(--pa-color-text-muted);
  line-height: 1.4;
}

.ws-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  width: 100%;
}

.ws-metric-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-xs);
  background-color: #fff;
  border-radius: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  padding: var(--space-md) var(--space-xs);
  min-height: 7.5rem;
}

.ws-metric-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.ws-metric-value {
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 800;
  color: var(--ws-primary);
  line-height: 1.1;
}

.ws-metric-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--pa-color-text-muted);
  text-transform: uppercase;
}

.ws-level-badge {
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  color: var(--pa-color-text-muted);
  background: #fff;
  border: 1.5px solid #eee;
  border-radius: var(--radius-pill);
  padding: 6px 20px;
}

.ws-level-badge strong {
  color: var(--ws-primary);
}

/* Try Again CTA */
.ws-try-again-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  width: 100%;
  background-color: #fff;
  border: none;
  border-radius: 26px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  padding: var(--space-lg) var(--space-md);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  text-align: center;
}

.ws-try-again-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -5px rgba(0, 0, 0, 0.1);
}

.ws-try-again-card:disabled { opacity: 0.7; cursor: wait; }

.ws-try-again-icon {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.ws-try-again-title {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--ws-primary);
}

.ws-try-again-note {
  font-size: var(--font-size-sm);
  color: var(--pa-color-text-muted);
  max-width: 18rem;
  line-height: 1.45;
}

/* Sign-in */
.ws-signin-prompt {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--pa-color-text-muted);
  text-align: center;
}

.ws-signin-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--ws-primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

/* Leaderboard card */
.ws-leaderboard-card {
  width: 100%;
  background-color: #fff;
  border-radius: 26px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  box-sizing: border-box;
}

.ws-leaderboard-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-sm);
}

.ws-leaderboard-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--ws-primary);
}

.ws-leaderboard-message {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--pa-color-text-muted);
}

.ws-leaderboard-message--link {
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: var(--font-size-sm);
  color: var(--ws-primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.ws-leaderboard-message--link:hover { text-decoration: underline; }

/* Footer buttons */
.ws-result-footer {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  margin-top: var(--space-xs);
  box-sizing: border-box;
}

.ws-footer-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  border: none;
  border-radius: var(--radius-pill);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-heading);
  font-size: var(--font-size-md);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  min-height: 3.25rem;
}

.ws-footer-btn:hover  { transform: translateY(-2px); }
.ws-footer-btn:disabled { opacity: 0.7; cursor: wait; }

.ws-footer-btn--play {
  background: linear-gradient(135deg, var(--ws-primary), #f39c12);
  color: #fff;
}

.ws-footer-btn--play:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(230, 126, 34, 0.4);
}

.ws-footer-btn--games {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff;
}

.ws-footer-btn--games:hover {
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.4);
}

.ws-footer-btn-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 500px) {
  .ws-level-cards-container {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .ws-metrics-row {
    gap: 0.35rem;
  }

  .ws-metric-card {
    border-radius: 20px;
    padding: var(--space-sm) 0.25rem;
    min-height: 6.5rem;
  }

  .ws-metric-icon { font-size: 1.35rem; }

  .ws-result-footer { gap: 0.35rem; }

  .ws-footer-btn {
    font-size: var(--font-size-sm);
    padding: var(--space-xs) var(--space-sm);
    min-height: 2.75rem;
  }

  .ws-slot {
    width: 30px;
    height: 38px;
    font-size: var(--font-size-lg);
    border-radius: 6px;
  }

  .ws-tile {
    width: 38px;
    height: 44px;
    font-size: var(--font-size-lg);
    border-radius: 8px;
  }

  .ws-clue-area {
    width: 72px;
    height: 72px;
  }

  .ws-clue-emoji { font-size: 2.5rem; }
  .ws-clue-image { width: 50px; height: 50px; }
}
