/* OneOneTyping v6 — games hub and game player. */

/* ------------------------------------------------------------------ hub */

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.game-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
  background: var(--bg-elevated);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.game-cover {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-sunken);
}

.game-cover svg {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.4s var(--ease);
}

.game-card:hover .game-cover svg {
  transform: scale(1.04);
}

.game-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  padding: 16px 18px 18px;
}

.game-body h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
}

.game-body p {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 6px;
}

.game-best {
  display: flex;
  flex-direction: column;
  color: var(--text-dim);
  font-size: 12px;
}

.game-best b {
  color: var(--text-strong);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.game-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.game-note {
  display: flex;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--bg-elevated);
}

.game-note svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.game-note b {
  display: block;
  margin-bottom: 3px;
  color: var(--text-strong);
  font-size: 14px;
}

.game-note span {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 960px) {
  .game-grid,
  .game-notes {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------- player */

.game-page {
  min-height: 100vh;
  background: var(--bg);
}

.game-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-elevated);
}

.game-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.game-back {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-muted);
}

.game-back:hover {
  background: var(--bg-sunken);
  color: var(--text-strong);
}

.game-back svg {
  width: 20px;
  height: 20px;
}

.game-title b {
  display: block;
  color: var(--text-strong);
  font-size: 15px;
}

.game-title span {
  color: var(--text-dim);
  font-size: 12px;
}

.game-hud {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.game-hud b {
  color: var(--text-strong);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.game-lives {
  display: inline-flex;
  gap: 3px;
  color: var(--red);
}

.game-lives svg {
  width: 17px;
  height: 17px;
}

.game-lives .is-lost {
  color: var(--line);
}

.game-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.game-tools button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.game-tools button:hover,
.game-tools button[aria-pressed='true'] {
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.game-tools svg {
  width: 19px;
  height: 19px;
}

.game-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
}

.game-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.25s;
}

.game-main {
  display: flex;
  justify-content: center;
  padding: 24px 20px 40px;
}

.game-stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  /* Room for the start/result card even when the play area is short (the
     race track is 250 units tall; its result card was clipped). */
  min-height: min(640px, calc(100vh - 110px));
}

.game-canvas-box {
  position: relative;
  width: 100%;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-sunken);
  box-shadow: var(--shadow-md);
}

.game-canvas-box canvas {
  display: block;
}

.game-canvas-box.is-shake {
  animation: game-shake 0.35s;
}

@keyframes game-shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

.game-banner {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 30px;
  font-weight: var(--fw-bold);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
}

.game-banner:empty {
  display: none;
}

.game-extra:empty {
  display: none;
}

/* The race passage. */
.race-text {
  margin-top: 18px;
  padding: 22px 26px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 24px;
  line-height: 1.9;
  white-space: pre-wrap;
}

.race-text span.is-done {
  color: var(--text-strong);
}

.race-text span.is-cur {
  color: var(--text-strong);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.race-text span.is-wrong {
  background: var(--red-soft);
  color: var(--red-ink);
  box-shadow: inset 0 -3px 0 var(--red);
}

/* Start, pause and result cards float over the stage. */
.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 18px;
  background: rgba(16, 17, 19, 0.38);
  backdrop-filter: blur(3px);
}

.game-overlay[hidden] {
  display: none;
}

.game-card-panel {
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 28px;
  border-radius: 20px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.game-card-panel h2 {
  font-size: 24px;
}

.game-card-panel .gp-howto {
  margin: 10px auto 0;
  max-width: 400px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.gp-group {
  margin-top: 18px;
  text-align: left;
}

.gp-group > span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: var(--fw-semibold);
}

.gp-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gp-options button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text-strong);
  font: inherit;
  font-size: 13.5px;
  font-weight: var(--fw-semibold);
  cursor: pointer;
  text-align: left;
}

.gp-options button small {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: var(--fw-medium);
}

.gp-options button[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.gp-options button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gp-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.gp-hint {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.gp-hint kbd,
.gp-howto kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.gp-score {
  margin-top: 12px;
  color: var(--text-strong);
  font-size: 56px;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gp-score small {
  display: block;
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: var(--fw-medium);
}

.gp-newbest {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-ink);
  font-size: 12.5px;
  font-weight: var(--fw-bold);
}

.gp-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.gp-stats div {
  padding: 12px 6px;
}

.gp-stats div + div {
  border-left: 1px solid var(--line-soft);
}

.gp-stats b {
  display: block;
  color: var(--text-strong);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.gp-stats span {
  color: var(--text-dim);
  font-size: 11.5px;
}

.gp-lines {
  margin-top: 14px;
  text-align: left;
}

.gp-lines div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px dashed var(--line-soft);
  color: var(--text-muted);
  font-size: 13px;
}

.gp-lines b {
  color: var(--text-strong);
  font-weight: var(--fw-semibold);
  text-align: right;
}

.game-mobile-note {
  display: none;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 12.5px;
}

@media (hover: none) and (pointer: coarse) {
  .game-mobile-note {
    display: block;
  }
}

@media (max-width: 720px) {
  .game-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0 12px;
  }
  .game-title span,
  .game-hud-label {
    display: none;
  }
  .game-tools {
    display: none;
  }
  .game-main {
    padding: 14px 10px 30px;
  }
  .race-text {
    font-size: 18px;
    padding: 16px;
  }
  .game-banner {
    font-size: 20px;
  }
}

/* A small ribbon on a game's card (manifest badge: 新 / 更新). */
.game-card { position: relative; }
.game-ribbon { position: absolute; top: 12px; right: 12px; z-index: 2; padding: 3px 10px; border-radius: 999px; background: #ff5a7a; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; box-shadow: 0 4px 10px -4px rgba(255, 60, 110, 0.6); }
