/* God Alone - Quran learning games */

.game-stage {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-raise) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  position: relative;
  overflow: hidden;
  min-height: 24rem;
}
.game-stage h2 {
  text-align: center;
  font-size: var(--step-2);
  font-weight: 640;
  margin-bottom: 1.25rem;
}
.game-loading {
  text-align: center;
  color: var(--text-mute);
  padding: 4rem 0;
}

/* Language selection */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}
.lang-card {
  padding: 1.1rem;
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
  text-align: center;
}
.lang-card:hover:not(:disabled) {
  border-color: var(--acc-dark);
  transform: translateY(-2px);
}
.lang-card.selected {
  border-color: var(--acc);
  background: var(--acc-tint);
}
.lang-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.lang-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--text);
}
.lang-soon {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-faint);
}
.lang-note {
  text-align: center;
  color: var(--text-mute);
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
}
.how-box {
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-left: 3px solid var(--acc);
  border-radius: var(--radius-s);
  padding: 1rem 1.25rem;
  margin-bottom: 1.4rem;
  color: var(--text-soft);
  line-height: 1.7;
  font-size: 0.95rem;
}
.rtl .how-box {
  border-left: 1px solid var(--border);
  border-right: 3px solid var(--acc);
}
.game-start {
  display: block;
  margin: 0 auto;
}

/* HUD */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.9rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-mute);
}
.game-hud strong {
  color: var(--acc);
  font-size: 1.05rem;
}
.hud-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  justify-content: center;
  min-width: 10rem;
}
.timer-bar {
  width: min(14rem, 40vw);
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.timer-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--acc-dark), var(--acc));
  transition: width 0.1s linear;
}

/* Flash messages */
.game-flash {
  position: absolute;
  top: 4.2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.9rem;
  z-index: 5;
  animation: flashUp 0.9s ease both;
  pointer-events: none;
}
.game-flash.bad {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.4);
}
.game-flash.good {
  background: var(--acc-tint);
  color: var(--acc);
  border: 1px solid var(--acc-dark);
}
@keyframes flashUp {
  from { opacity: 0; transform: translate(-50%, 8px); }
  20% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -8px); }
}

/* Drag mechanics */
.draggable {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.drag-ghost {
  position: fixed;
  z-index: 100;
  opacity: 0.92;
  pointer-events: none;
  transform: scale(1.04) rotate(1.5deg);
  box-shadow: var(--shadow-3);
}
.drag-source {
  opacity: 0.35;
}
.drop-hover {
  outline: 2px dashed var(--acc) !important;
  outline-offset: 2px;
}
.shake {
  animation: gaShake 0.45s ease;
}
@keyframes gaShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ---- Verse Match ---- */
.vm-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.7rem;
  align-items: stretch;
}
.vm-card {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text-soft);
  padding: 0.7rem 0.85rem;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
  transform: rotate(var(--tilt, 0deg)) translateY(var(--shift, 0));
  transition: border-color 0.15s ease, opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.6rem;
  word-break: break-word;
}
.vm-card.vm-ref {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--acc);
  border-color: var(--acc-dark);
  background: var(--acc-tint);
}
.vm-card:hover:not(.locked) {
  border-color: var(--acc);
}
.vm-card.matched {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

/* ---- Missing Words ---- */
.mw-verse {
  margin-bottom: 1.1rem;
}
.mw-subtitle {
  text-align: center;
  color: var(--acc);
  font-weight: 640;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}
.mw-text {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 2.15;
  color: var(--text);
}
.mw-ref {
  color: var(--acc);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 650;
}
.mw-gap {
  display: inline-block;
  min-width: 6.5rem;
  border-bottom: 2px dashed var(--acc-dark);
  background: var(--acc-tint);
  border-radius: 4px 4px 0 0;
  height: 1.5em;
  vertical-align: bottom;
  margin: 0 0.15rem;
  transition: background 0.15s ease;
}
.mw-gap.filled {
  border-bottom-style: solid;
  border-bottom-color: var(--acc);
  color: var(--acc-bright);
  height: auto;
  min-width: 0;
  padding: 0 0.3rem;
  font-style: italic;
}
.mw-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  padding: 1rem;
  margin-top: 1.25rem;
  background: var(--bg-raise);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-m);
}
.mw-chip {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-family: var(--font-serif);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.mw-chip:hover:not(.locked) {
  border-color: var(--acc);
  transform: translateY(-1px);
}

/* ---- Verse Builder ---- */
.vb-ref {
  text-align: center;
  color: var(--acc);
  font-weight: 650;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  margin-bottom: 0.9rem;
}
.vb-answer {
  min-height: 4.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-content: flex-start;
  padding: 0.9rem;
  background: var(--bg-raise);
  border: 1px dashed var(--acc-dark);
  border-radius: var(--radius-m);
  margin-bottom: 1.2rem;
}
.vb-placed {
  background: var(--acc-tint);
  border: 1px solid var(--acc-dark);
  color: var(--acc-bright);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  animation: fadeUp 0.25s ease both;
}
.vb-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}
.vb-tile {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.85rem;
  font-family: var(--font-serif);
  font-size: 1rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.vb-tile:hover:not(.locked) {
  border-color: var(--acc);
  transform: translateY(-2px);
}

/* Game over */
.game-stage.over {
  text-align: center;
  padding-top: 3rem;
}
.over-score {
  font-size: var(--step-1);
  margin-bottom: 0.4rem;
}
.over-round {
  color: var(--text-mute);
  margin-bottom: 1.6rem;
}
.name-label {
  display: block;
  color: var(--text-soft);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
#player-name {
  width: min(16rem, 80%);
  margin: 0 auto 1.3rem;
  display: block;
  text-align: center;
  font-size: 1.1rem;
  padding: 0.65rem;
  background: var(--bg-raise);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
}
#player-name:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-glow);
}
.over-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
}
.save-status {
  margin-top: 1rem;
  color: var(--acc);
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* Games hub cards */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.game-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 1.4rem 1.3rem;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--acc-dark);
  box-shadow: 0 10px 30px -12px rgba(74, 222, 128, 0.25);
}
.game-card .gc-icon {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  display: block;
}
.game-card h3 {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 650;
  margin-bottom: 0.35rem;
}
.game-card p {
  color: var(--text-mute);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0;
}

/* Leaderboard page */
.lb-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.lb-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 1.2rem 1.25rem;
}
.lb-panel h3 {
  text-align: center;
  color: var(--acc);
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.lb-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.lb-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.32rem 0.2rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.lb-list li:last-child {
  border-bottom: 0;
}
.lb-rank {
  color: var(--text-faint);
  font-size: 0.78rem;
  min-width: 1.6rem;
  text-align: right;
}
.lb-list li:nth-child(1) .lb-rank,
.lb-list li:nth-child(2) .lb-rank,
.lb-list li:nth-child(3) .lb-rank {
  color: var(--acc);
  font-weight: 700;
}
.lb-name {
  color: var(--text);
  font-weight: 570;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score {
  color: var(--acc);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.lb-round {
  color: var(--text-faint);
  font-size: 0.75rem;
}
.lb-empty,
.lb-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: 1rem 0;
}

@media (max-width: 600px) {
  .vm-board {
    grid-template-columns: repeat(2, 1fr);
  }
  .vm-card {
    font-size: 0.74rem;
    min-height: 3.2rem;
  }
  .mw-gap {
    min-width: 4.5rem;
  }
}
