/* The Game Maker page (templates/game_create.html, js/game.js). Colours come from app.css's tokens (light / dark). */

.game-page { padding-top: 26px; padding-bottom: 60px; display: grid; gap: 22px; }

/* ---------------------------------------------------------------- the idea */
.game-hero { display: grid; grid-template-columns: 1fr 1.1fr; gap: 28px; align-items: center; position: relative; overflow: hidden; }
/* a game on screen: the idea box shrinks to one line of "make another" */
.game-page.viewing .game-hero { grid-template-columns: 1fr; padding: 14px 18px; }
.game-page.viewing .game-hero-copy, .game-page.viewing #game-examples, .game-page.viewing .prompt-foot,
.game-page.viewing #game-left, .game-page.viewing .game-form .field-label { display: none; }
.game-page.viewing .game-form { grid-template-columns: 1fr auto; align-items: center; gap: 10px 14px; }
.game-page.viewing .game-form .textarea { min-height: 0; height: 48px; font-size: 0.98rem; }
.game-page.viewing .game-go { margin: 0; }
.game-page.viewing .game-price { display: none; }
.game-hero h1 { font-size: clamp(1.8rem, 3.4vw, 2.7rem); line-height: 1.08; margin: 0 0 12px; }
.game-hero h1 .mark { background: linear-gradient(180deg, transparent 60%, var(--yellow) 60%, var(--yellow) 90%, transparent 90%); padding: 0 2px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.game-hero .lead { margin: 0; color: var(--ink-2); }
.game-form { display: grid; gap: 8px; position: relative; z-index: 1; }
.game-form .textarea { min-height: 96px; font-size: 1.05rem; }
.prompt-foot { display: flex; justify-content: space-between; gap: 10px; }
.game-form .chips { display: flex; gap: 8px; overflow-x: auto; }
.game-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 6px; }
.game-price { margin: 0; font-size: 0.95rem; }
.game-price b { font-family: var(--font-display); }

/* ---------------------------------------------------------------- the run */
.game-run { display: grid; gap: 18px; }
.game-run-head { display: grid; grid-template-columns: 1fr minmax(160px, 320px) auto; align-items: center; gap: 18px; padding: 18px 22px; }
.game-run-title h2 { font-size: 1.45rem; }
.game-meter { height: 16px; border-radius: 999px; background: var(--surface-3, var(--blue-soft)); border: 2px solid var(--line); overflow: hidden; }
.game-meter-fill { height: 100%; width: 0; border-radius: 999px; background: repeating-linear-gradient(-45deg, var(--green) 0 12px, var(--green-d) 12px 24px);
  background-size: 34px 34px; animation: game-stripes 1s linear infinite; transition: width 0.6s cubic-bezier(.3,.8,.4,1); }
.game-run[data-status="done"] .game-meter-fill { animation: none; background: var(--green); }
.game-run[data-status="failed"] .game-meter-fill { animation: none; background: var(--pink); }
@keyframes game-stripes { to { background-position: 34px 0; } }
.game-pct { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; min-width: 3.2em; text-align: right; }

.game-grid { display: grid; grid-template-columns: minmax(250px, 330px) 1fr; gap: 18px; align-items: start; }
.game-steps { list-style: none; margin: 0; padding: 14px; display: grid; gap: 4px; position: sticky; top: calc(var(--header-h) + 12px); }
.game-step { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: start; padding: 9px 8px; border-radius: var(--r-sm); transition: background 0.3s; }
.game-step-body { display: grid; gap: 2px; }
.game-step-body b { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.game-step-text { font-size: 0.86rem; color: var(--ink-3, var(--ink-2)); min-height: 1em; }
.game-step-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--line);
  background: var(--surface); font-family: var(--font-display); font-weight: 700; color: var(--ink-3, var(--ink-2)); position: relative; }
.game-step[data-state="waiting"] { opacity: 0.6; }
.game-step[data-state="running"] { background: var(--yellow-soft); }
.game-step[data-state="running"] .game-step-dot { border-color: var(--yellow-d); color: var(--ink); }
.game-step[data-state="running"] .game-step-dot::after { content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--orange); animation: game-spin 0.9s linear infinite; }
.game-step[data-state="done"] .game-step-dot { background: var(--green); border-color: var(--green-d); color: #fff; animation: game-pop 0.45s ease-out; }
.game-step[data-state="done"] .game-step-dot .n { display: none; }
.game-step[data-state="done"] .game-step-dot::before { content: ""; width: 12px; height: 7px; border: solid #fff; border-width: 0 0 3px 3px; transform: translateY(-2px) rotate(-45deg); }
.game-step[data-state="failed"] .game-step-dot { background: var(--pink); border-color: var(--pink-d); color: #fff; }
@keyframes game-spin { to { transform: rotate(360deg); } }
@keyframes game-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

.game-live { display: grid; gap: 18px; min-width: 0; }
.game-panel { animation: game-rise 0.5s cubic-bezier(.3,.8,.4,1); min-width: 0; }
@keyframes game-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 1.15rem; }
.badge-purple { background: var(--purple); color: #fff; box-shadow: 0 2px 0 var(--purple-d); }

.map-shots { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.map-shots img, .ui-shots img { width: 100%; display: block; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface-3, var(--blue-soft)); }
.map-shots img { aspect-ratio: 16 / 10; object-fit: cover; }
.map-shots .big { grid-row: span 2; height: 100%; }
.ui-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ui-shot { display: grid; gap: 4px; font-size: 0.82rem; color: var(--ink-2); background: none; border: 0; padding: 0; cursor: zoom-in; text-align: left; font-family: inherit; }
.ui-shot img { aspect-ratio: 16 / 9; object-fit: cover; }

.sys-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.sys { border: 2px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; display: grid; gap: 4px; background: var(--surface);
  animation: game-rise 0.4s both; }
.sys b { font-family: var(--font-display); font-weight: 600; }
.sys .why { font-size: 0.78rem; color: var(--blue); font-weight: 700; }
.sys p { margin: 0; font-size: 0.86rem; color: var(--ink-2); }
.sys.lead { border-color: var(--yellow-d); background: var(--yellow-soft); }

.anim-list, .check-list { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.anim-list li, .check-list li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.anim-list li::before { content: "▶"; color: var(--purple); font-size: 0.8rem; margin-top: 3px; }
.check-list li::before { content: "✔"; color: var(--green-d); font-weight: 800; }
.check-list li.bad::before { content: "✖"; color: var(--pink-d); }
.place-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.stat { border: 2px solid var(--line); border-radius: var(--r-sm); padding: 10px; text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.35rem; }
.stat span { font-size: 0.8rem; color: var(--ink-2); }

/* ---------------------------------------------------------------- the end */
.game-export { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; border-color: var(--green-d);
  background: linear-gradient(135deg, var(--green-soft), var(--surface) 70%); animation: game-rise 0.6s cubic-bezier(.3,.8,.4,1); }
.game-export h2 { font-size: 1.6rem; }
.game-export-go { display: grid; gap: 6px; justify-items: center; }
.game-export ul { margin: 10px 0 0; padding-left: 18px; }
.btn-xl { font-size: 1.2rem; padding: 14px 26px; }
.game-failed { border-color: var(--pink-d); display: grid; gap: 10px; justify-items: start; }

.game-mine h2 { font-size: 1.2rem; }
.mine-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.mine { display: grid; gap: 4px; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--r); background: var(--surface);
  color: inherit; text-decoration: none; box-shadow: 0 4px 0 var(--drop); }
.mine b { font-family: var(--font-display); font-weight: 600; }
.mine span { font-size: 0.84rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.game-zoom { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 80; padding: 16px; cursor: zoom-out; }
.game-zoom img { max-width: min(1200px, 100%); max-height: 90vh; border-radius: var(--r); border: 3px solid var(--line); }

.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 90; pointer-events: none; animation: game-fall linear forwards; }
@keyframes game-fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 860px) {
  .game-hero { grid-template-columns: 1fr; }
  .game-grid { grid-template-columns: 1fr; }
  .game-steps { position: static; }
  .game-run-head { grid-template-columns: 1fr auto; }
  .game-meter { grid-column: 1 / -1; grid-row: 2; }
  .game-export { grid-template-columns: 1fr; }
  .map-shots { grid-template-columns: 1fr 1fr; }
  .map-shots .big { grid-column: 1 / -1; grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .game-meter-fill, .game-step-dot::after, .game-panel, .sys, .game-export { animation: none !important; }
}
