﻿/**
 * MindsEvo Shell-1 — Game Common Styles
 * ─────────────────────────────────────────────────────────
 * Shared CSS for ALL Shell-1 games.
 * Games only override theme variables via shell.createGame({ theme: {...} }).
 * Class prefix: s1-
 * ─────────────────────────────────────────────────────────
 */

/* ── Language display control ──────────────────────────── */
html[lang="en"]    .zh { display: none; }
html[lang="zh-CN"] .en { display: none; }

/* ── Theme variables (game overrides via <style> injection) */
:root {
  --s1-primary:  #667eea;
  --s1-primary2: #764ba2;
  --s1-green:    #10b981;
  --s1-yellow:   #f59e0b;
  --s1-red:      #ef4444;
  --s1-text:     #1e293b;
  --s1-muted:    #64748b;
  --s1-bg:       #f8faff;
  --s1-card:     #ffffff;
  --s1-border:   #e2e8f0;
}

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "SF Pro Display", "Helvetica Neue", Arial,
               "Microsoft YaHei", "PingFang SC", sans-serif;
  background: linear-gradient(135deg, var(--s1-primary) 0%, var(--s1-primary2) 100%);
  min-height: 100vh;
  display: flex; justify-content: center; align-items: center;
  padding: 20px;
  color: var(--s1-text);
  line-height: 1.65;
}

/* ── Main card wrapper ────────────────────────────────── */
.s1-wrap {
  background: var(--s1-card);
  border-radius: 24px;
  padding: 36px 40px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
  width: 100%; max-width: 680px;
}

.s1-hidden { display: none !important; }

/* ── Fade-in animation ────────────────────────────────── */
@keyframes s1-fadeIn {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.s1-screen { animation: s1-fadeIn 0.35s ease; }

/* ══════════════════════════════════════════════════════════
   HOME SCREEN
   ══════════════════════════════════════════════════════════ */

.s1-hdr {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.s1-title    { font-size: 36px; color: var(--s1-primary); font-weight: 900; }
.s1-sub      { font-size: 15px; color: var(--s1-muted); margin-bottom: 32px; }
.s1-controls { display: flex; gap: 8px; }

.s1-btn {
  background: white; border: 2px solid var(--s1-border);
  border-radius: 20px; padding: 7px 14px;
  font-size: 14px; cursor: pointer; font-weight: 700;
  transition: all 0.2s;
}
.s1-btn:hover  { border-color: var(--s1-primary); }
.s1-btn.s1-active { background: var(--s1-primary); color: white; border-color: var(--s1-primary); }

/* Unit cards */
.s1-units { display: flex; flex-direction: column; gap: 16px; }

.s1-card {
  border-radius: 14px; padding: 18px 22px;
  display: flex; align-items: center; gap: 18px;
  cursor: pointer; border: 2px solid var(--s1-border);
  background: white;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.s1-card:not(.s1-locked):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  border-color: var(--s1-primary);
}
.s1-card.s1-locked { opacity: 0.48; cursor: not-allowed; background: #f8fafc; }

.s1-cicon { font-size: 40px; min-width: 50px; text-align: center; }
.s1-cinfo { flex: 1; }
.s1-cname { font-size: 20px; font-weight: 800; margin-bottom: 3px; color: var(--s1-text); }
.s1-cdesc { font-size: 14px; color: var(--s1-muted); }
.s1-cstat {
  font-size: 13px; font-weight: 700; color: var(--s1-muted);
  text-align: right; white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   GAME SCREEN
   ══════════════════════════════════════════════════════════ */

.s1-ghdr {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.s1-back   { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.s1-utitle { font-size: 24px; font-weight: 800; color: var(--s1-primary); }

.s1-ginfo {
  display: flex; justify-content: space-between;
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
}
.s1-prog  { color: var(--s1-primary); font-weight: 800; }
.s1-score { color: var(--s1-green);   font-weight: 800; }

/* Progress dots */
.s1-dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 22px; }
.s1-dot  {
  width: 9px; height: 9px; border-radius: 50%; background: var(--s1-border);
  transition: all 0.3s;
}
.s1-dot.s1-cur  { background: var(--s1-primary); transform: scale(1.4); }
.s1-dot.s1-done { background: var(--s1-green); }

/* Sequence display */
.s1-seq {
  background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
  border-radius: 16px; padding: 28px 24px;
  font-size: 40px; font-weight: 900; letter-spacing: 5px;
  text-align: center; margin-bottom: 24px; position: relative;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  display: flex; align-items: center; justify-content: center;
  min-height: 110px; flex-wrap: wrap; gap: 8px;
}
.s1-replay {
  position: absolute; top: 10px; right: 12px;
  background: rgba(255,255,255,0.85); border: none; border-radius: 50%;
  width: 36px; height: 36px; font-size: 18px;
  cursor: pointer; transition: transform 0.2s;
}
.s1-replay:hover { transform: scale(1.12); }

/* Mystery token (shared by all games) */
.mystery {
  display: inline-block; background: var(--s1-red); color: white;
  padding: 4px 18px; border-radius: 10px; font-size: 36px;
  vertical-align: middle;
}

/* Options grid */
.s1-opts {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 18px;
}
.s1-opt {
  min-height: 64px; padding: 16px; font-size: 22px; font-weight: 800;
  border: 2.5px solid var(--s1-border); border-radius: 14px;
  background: white; cursor: pointer; color: var(--s1-text);
  transition: all 0.25s;
  display: flex; align-items: center; justify-content: center;
}
.s1-opt:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  border-color: var(--s1-primary);
}
.s1-opt:disabled { cursor: not-allowed; opacity: 0.7; }

@keyframes s1-pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }
@keyframes s1-shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.s1-opt.s1-correct {
  background: var(--s1-green); color: white; border-color: var(--s1-green);
  animation: s1-pulse 0.45s ease;
}
.s1-opt.s1-wrong {
  background: var(--s1-red); color: white; border-color: var(--s1-red);
  animation: s1-shake 0.45s ease;
}

/* Feedback */
.s1-fb {
  min-height: 48px; font-size: 20px; font-weight: 800;
  text-align: center; margin-bottom: 14px; padding: 8px;
}
.s1-fb-ok  { color: var(--s1-green); }
.s1-fb-err { color: var(--s1-red); }

/* Hint box */
.s1-hint {
  font-size: 16px; font-weight: 600; color: var(--s1-text);
  background: #fef9c3; padding: 12px 20px;
  border-radius: 10px; border: 2px solid #fbbf24;
  margin-bottom: 14px;
}

/* Action buttons row */
.s1-acts { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }

.s1-abtn {
  padding: 13px 34px; font-size: 18px; font-weight: 800;
  border: none; border-radius: 12px; cursor: pointer; transition: all 0.22s;
}
.s1-primary {
  background: linear-gradient(135deg, var(--s1-primary), var(--s1-primary2));
  color: white; box-shadow: 0 4px 14px rgba(102,126,234,0.28);
}
.s1-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(102,126,234,0.38); }
.s1-secondary { background: var(--s1-yellow); color: white; }
.s1-secondary:hover { transform: translateY(-2px); }
.s1-outline { background: white; color: var(--s1-primary); border: 2.5px solid var(--s1-primary); }
.s1-outline:hover { background: var(--s1-bg); transform: translateY(-2px); }

/* ══════════════════════════════════════════════════════════
   RESULT SCREEN
   ══════════════════════════════════════════════════════════ */

.s1-result-screen { text-align: center; }
.s1-rem    { font-size: 72px; text-align: center; margin-bottom: 16px; }
.s1-rtitle {
  font-size: 32px; font-weight: 900; color: var(--s1-primary);
  text-align: center; margin-bottom: 24px;
}
.s1-rstats {
  background: var(--s1-bg); border-radius: 16px;
  padding: 24px; margin-bottom: 24px; text-align: center;
}
.s1-rscore { font-size: 48px; font-weight: 900; color: var(--s1-green); margin-bottom: 8px; }
.s1-rdet   { font-size: 16px; color: var(--s1-muted); line-height: 1.9; }
.s1-rmsg {
  font-size: 18px; font-weight: 700; color: var(--s1-text);
  background: #fef9c3; border-radius: 12px;
  padding: 14px 20px; margin-bottom: 28px; text-align: center;
}

/* ══════════════════════════════════════════════════════════
   PRACTICE SUMMARY (折叠报告)
   ══════════════════════════════════════════════════════════ */

.s1-summary { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.s1-sums    { border-radius: 14px; border: 1.5px solid var(--s1-border); overflow: hidden; }

.s1-sum-hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; cursor: pointer; background: var(--s1-bg);
  font-size: 18px; font-weight: 700; user-select: none; transition: background 0.2s;
}
.s1-sum-hdr:hover { background: #eef2ff; }
.s1-arrow { font-size: 14px; color: var(--s1-muted); }

.s1-sum-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease; background: white;
}
.s1-sum-body.s1-open { max-height: 700px; }

.s1-empty {
  padding: 20px 16px; text-align: center;
  font-size: 15px; color: var(--s1-muted);
}

/* Session table */
.s1-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.s1-table thead tr { background: var(--s1-bg); border-bottom: 1.5px solid var(--s1-border); }
.s1-table th {
  padding: 10px; font-weight: 700; font-size: 14px;
  color: var(--s1-muted); text-align: center;
}
.s1-table th:first-child { text-align: left; padding-left: 16px; }
.s1-table td {
  padding: 12px 10px; text-align: center;
  border-bottom: 1px solid #f1f5f9; font-weight: 600;
}
.s1-table td.s1-tname { text-align: left; padding-left: 16px; font-weight: 700; }
.s1-table td.s1-tok  { color: #16a34a; font-weight: 800; }
.s1-table td.s1-terr { color: var(--s1-red); font-weight: 800; }
.s1-table tr.s1-tidle td { color: var(--s1-muted); }
.s1-table tr:last-child td { border-bottom: none; }

/* History stats */
.s1-hstats {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 8px; padding: 18px 16px 14px;
  border-bottom: 1px solid var(--s1-border);
}
.s1-hstat  { text-align: center; }
.s1-hsval  { font-size: 26px; font-weight: 900; color: var(--s1-text); }
.s1-hslbl  { font-size: 13px; color: var(--s1-muted); margin-top: 4px; font-weight: 600; }
.s1-hclear { padding: 12px 16px; }
.s1-clearbtn {
  background: none; border: 1.5px solid #fca5a5; border-radius: 8px;
  color: var(--s1-red); font-size: 15px; font-weight: 700;
  padding: 7px 16px; cursor: pointer; transition: all 0.2s;
}
.s1-clearbtn:hover { background: #fef2f2; }

/* ══════════════════════════════════════════════════════════
   VOICE TRANSCRIPT BAR
   ══════════════════════════════════════════════════════════ */

.s1-transcript {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(7,18,37,0.92); backdrop-filter: blur(12px);
  color: #fff; padding: 10px 20px; font-size: 14px; font-weight: 600;
  text-align: center; border-top: 1px solid rgba(255,255,255,0.12);
  z-index: 1000; transition: transform 0.3s ease;
}
.s1-transcript.s1-hidden { transform: translateY(100%); }

/* ══════════════════════════════════════════════════════════
   HELP / VIDEO OVERLAY
   ══════════════════════════════════════════════════════════ */

.s1-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}

.s1-overlay-card {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.26);
  overflow: hidden;
}

.s1-overlay-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--s1-bg);
  border-bottom: 1px solid var(--s1-border);
}

.s1-overlay-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--s1-text);
}

.s1-overlay-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--s1-muted);
}

.s1-overlay-body {
  padding: 16px;
  color: var(--s1-text);
  font-size: 15px;
  line-height: 1.7;
}

.s1-overlay-body p {
  margin: 0;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 820px) {
  body     { align-items: flex-start; padding: 12px; }
  .s1-wrap { max-width: 100%; border-radius: 18px; }
}

@media (max-width: 520px) {
  body       { padding: 0; }
  .s1-wrap   { border-radius: 0; padding: 20px 16px 28px; min-height: 100svh; }
  .s1-title  { font-size: 26px; }
  .s1-seq    { font-size: 28px; letter-spacing: 2px; padding: 20px 12px; min-height: 90px; }
  .mystery   { font-size: 28px; padding: 3px 12px; }
  .s1-opt    { font-size: 17px; min-height: 54px; }
  .s1-abtn   { padding: 10px 18px; font-size: 15px; }
  .s1-cname  { font-size: 17px; }
  .s1-cicon  { font-size: 32px; min-width: 40px; }
  .s1-card   { padding: 14px 16px; gap: 12px; }
  .s1-hstats { grid-template-columns: repeat(3, 1fr); }
  .s1-rscore { font-size: 40px; }
  .s1-overlay { padding: 12px; }
  .s1-overlay-title { font-size: 16px; }
}

/* Very small phones (e.g. iPhone SE) */
@media (max-width: 375px) {
  .s1-title  { font-size: 22px; }
  .s1-seq    { font-size: 24px; padding: 16px 8px; min-height: 80px; }
  .mystery   { font-size: 24px; padding: 2px 10px; }
  .s1-opt    { font-size: 15px; min-height: 48px; padding: 10px; }
  .s1-utitle { font-size: 18px; }
  .s1-abtn   { padding: 9px 14px; font-size: 14px; }
}

/* Phone landscape - height constrained */
@media (max-height: 500px) and (orientation: landscape) {
  body     { align-items: flex-start; padding: 8px; }
  .s1-wrap { min-height: unset; padding: 12px 20px 16px; border-radius: 12px; }
  .s1-seq  { padding: 12px 16px; min-height: 70px; font-size: 26px; }
  .s1-dots { margin-bottom: 10px; }
  .s1-ginfo { margin-bottom: 8px; }
  .s1-summary { display: none; }
}

/* Touch optimization - prevent iOS double-tap zoom */
.s1-btn, .s1-opt, .s1-abtn, .s1-back, .s1-replay, .s1-card,
.s1-sum-hdr, .s1-clearbtn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ══════════════════════════════════════════════════════════
   COLOR GAME COMPONENTS (used by color-pattern-hunter etc.)
   ══════════════════════════════════════════════════════════ */

/* Single color dot */
.s1-cdot {
  display: inline-block;
  border-radius: 50%;
  border: 2.5px solid rgba(0,0,0,0.15);
  vertical-align: middle;
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
  flex-shrink: 0;
}

/* Color pair capsule (for L4 color-pair questions) */
.s1-ccapsule {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  background: #f1f5f9;
  border-radius: 32px;
  padding: 6px 12px;
  border: 2px solid #e2e8f0;
  vertical-align: middle;
  transition: background 0.2s, border-color 0.2s;
}
.s1-opt:hover:not(:disabled) .s1-ccapsule { background: #e0f2fe; border-color: var(--s1-primary); }
.s1-opt.s1-correct .s1-ccapsule { background: var(--s1-green); border-color: var(--s1-green); }
.s1-opt.s1-wrong   .s1-ccapsule { background: var(--s1-red);   border-color: var(--s1-red); }

/* Color grid (for L2 color-cycle questions) */
.s1-cgrid {
  display: grid;
  gap: 10px 16px;
  justify-items: center;
  align-items: center;
}
.s1-cgrid-sep {
  grid-column: 1 / -1;
  height: 1.5px;
  background: rgba(0,0,0,0.10);
  border-radius: 1px;
  width: 90%;
  margin: 4px 0;
}

/* Responsive: shrink dots on small screens */
@media (max-width: 520px) {
  .s1-cdot { border-width: 2px; }
  .s1-ccapsule { padding: 5px 9px; gap: 4px; }
  .s1-cgrid { gap: 8px 12px; }
}

/* ══════════════════════════════════════════════════════════
   MOTION GAME COMPONENTS (used by motion-pattern-hunter etc.)
   ══════════════════════════════════════════════════════════ */

/* Direction / action card (displayed in sequence row) */
.s1-motion-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 54px; min-height: 54px;
  background: white;
  border-radius: 12px;
  border: 2px solid var(--s1-border);
  padding: 6px 10px;
  font-size: 28px;
  line-height: 1.2;
  vertical-align: middle;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.s1-motion-card small {
  font-size: 12px;
  font-weight: 700;
  color: var(--s1-muted);
  margin-top: 2px;
  line-height: 1;
}

/* Track style (overrides yellow gradient for position-jump) */
.s1-seq.s1-seq--track {
  background: #f8faff;
  border: 1.5px solid var(--s1-border);
  letter-spacing: 0;
  flex-direction: column;
  align-items: stretch;
  min-height: auto;
  padding: 16px 20px 12px;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Position track grid */
.s1-track {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.s1-track-cell {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--s1-border);
  background: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--s1-muted);
  flex-shrink: 0;
  transition: all 0.2s;
}
.s1-track-cell.s1-track-vis {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.s1-track-cell.s1-track-cur {
  background: var(--s1-primary);
  border-color: var(--s1-primary);
  color: white;
  transform: scale(1.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Step summary text below track */
.s1-track-steps {
  text-align: center;
  font-size: 14px; font-weight: 600;
  color: var(--s1-muted);
  padding: 0 4px;
}

/* Number badge for position options */
.s1-pos-badge {
  display: inline-flex;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--s1-bg);
  border: 2.5px solid var(--s1-border);
  align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900;
  color: var(--s1-text);
}

/* Responsive */
@media (max-width: 520px) {
  .s1-track-cell { width: 28px; height: 28px; font-size: 11px; border-radius: 6px; }
  .s1-motion-card { min-width: 44px; min-height: 44px; font-size: 22px; padding: 4px 8px; }
  .s1-pos-badge { width: 42px; height: 42px; font-size: 18px; }
  .s1-track-steps { font-size: 12px; }
}

/* ──────────────────────────────────────────────────────────────
   TRACK ANIMATION (position-jump sequential reveal)
   ────────────────────────────────────────────────────────────── */

/* Cell wrapper: positions badge+arrow below each visited cell */
.s1-track-cell-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* Bounce-in reveal keyframe */
@keyframes trackReveal {
  0%   { transform: scale(0.55) translateY(-6px); opacity: 0; }
  65%  { transform: scale(1.18) translateY(0);    opacity: 1; }
  100% { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* Fade-in keyframe for badge and arrow */
@keyframes trackFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Apply reveal to visited/current cells */
.s1-track-reveal {
  opacity: 0;
  animation: trackReveal 0.42s cubic-bezier(.34,1.56,.64,1) forwards;
}

/* Step number badge below visited cell (①②③…) */
.s1-track-badge {
  font-size: 13px;
  font-weight: 800;
  color: var(--s1-primary);
  opacity: 0;
  animation: trackFadeIn 0.3s ease forwards;
  line-height: 1;
}

/* Arrow connecting adjacent visited cells + final ? */
.s1-track-arrow {
  font-size: 13px;
  font-weight: 700;
  color: var(--s1-muted);
  opacity: 0;
  animation: trackFadeIn 0.3s ease forwards;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* The ? token inline in the last arrow */
.s1-track-q {
  font-size: 14px !important;
  padding: 2px 8px !important;
  border-radius: 6px !important;
  vertical-align: middle;
}

/* Responsive */
@media (max-width: 520px) {
  .s1-track-badge { font-size: 11px; }
  .s1-track-arrow { font-size: 11px; }
  .s1-track-q     { font-size: 12px !important; padding: 1px 6px !important; }
}

