/* Graphite (Skill Builder game). Black and white, built on the site's tokens. */

body.mode-sb .toolbar,
body.mode-sb .main,
body.mode-sb .header-right {
  display: none;
}

.game-root {
  padding-top: 16px;
  --g-radius: 8px;
  --g-shadow: 4px 4px 0 var(--text);
  --g-stage-h: clamp(420px, calc(100vh - 230px), 660px);
}

.g-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Buttons ---------- */

.g-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 14px;
  border: 1.5px solid var(--text);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.08s ease;
}

.g-btn:hover:not(:disabled) {
  background: var(--hover);
}

.g-btn:active:not(:disabled) {
  transform: translate(1px, 1px);
}

.g-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.g-btn:focus-visible,
.g-move:focus-visible,
.g-choice:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.g-btn-primary {
  background: var(--text);
  color: #fff;
}

.g-btn-primary:hover:not(:disabled) {
  background: #000;
  box-shadow: 3px 3px 0 #bdbdbd;
}

.g-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
}

.g-btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--hover);
}

.g-btn-danger:hover:not(:disabled) {
  background: var(--text);
  color: #fff;
}

.g-btn-wide {
  width: 100%;
  padding: 11px 14px;
}

.g-btn small {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.75;
}

.g-link {
  font: inherit;
  font-weight: 700;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.g-muted {
  color: var(--muted);
}

.g-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Top bar ---------- */

.g-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--g-radius);
}

.g-top-hero {
  display: flex;
  align-items: center;
  gap: 10px;
}

.g-avatar {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text);
}

.g-avatar i {
  position: absolute;
  top: 10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
}

.g-avatar i:first-child {
  left: 14px;
}

.g-avatar i:last-child {
  left: 20px;
}

.g-top-id {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.g-top-name {
  font-size: 0.9rem;
}

.g-top-level {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.g-xp {
  width: 120px;
  height: 7px;
  border: 1.5px solid var(--text);
  border-radius: 4px;
  overflow: hidden;
}

.g-xp i {
  display: block;
  height: 100%;
  background: var(--text);
  transition: width 0.6s ease;
}

.g-top-stats {
  display: flex;
  gap: 6px;
}

.g-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-dark);
  border-radius: 999px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.g-ink-drop {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-top: 2px;
  background: var(--text);
  border-radius: 0 50% 50% 50%;
  transform: rotate(45deg);
}

.g-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-left: auto;
}

/* ---------- Stage + panel ---------- */

.g-main {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.g-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: var(--g-stage-h);
  overflow: hidden;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}

.g-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.g-scene-ui,
.g-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.g-scene-ui > *,
.g-overlay > * {
  pointer-events: auto;
}

.g-main.is-battle .g-stage {
  flex: 1 1 56%;
}

.g-panel {
  flex: 0 0 44%;
  max-width: 580px;
  height: var(--g-stage-h);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--g-radius);
  background: #fff;
}

.g-panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 200px;
  height: 100%;
  font-size: 0.9rem;
  text-align: center;
  color: var(--muted);
}

.g-spinner {
  width: 26px;
  height: 26px;
  margin: 8px auto;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- Title ---------- */

.g-title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 24px 20%;
  text-align: center;
}

.g-title-kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--muted);
}

.g-logo {
  font-size: clamp(3rem, 9vw, 6.4rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.g-logo::after {
  content: "";
  display: block;
  width: 62%;
  height: 7px;
  margin: 12px auto 0;
  border-radius: 4px;
  background: var(--text);
  clip-path: polygon(0 0, 96% 0, 100% 50%, 96% 100%, 0 100%);
}

.g-tagline {
  margin-bottom: 14px;
  font-size: 1rem;
  color: var(--muted);
}

.g-title-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.g-title-actions .g-btn {
  min-width: 190px;
  padding: 12px 22px;
  font-size: 1rem;
}

.g-title-actions .g-btn-primary {
  box-shadow: 4px 4px 0 #c4c4c4;
}

.g-title-foot {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- Dialogue ---------- */

.g-dialog {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 10;
  width: min(720px, calc(100% - 24px));
  padding: 12px 16px 8px;
  transform: translateX(-50%);
  border: 2px solid var(--text);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--g-shadow);
  cursor: pointer;
  animation: g-rise 0.2s ease both;
}

.g-dialog-name {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--text);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.g-dialog-text {
  min-height: 3em;
  font-size: 0.98rem;
  line-height: 1.5;
}

.g-dialog.is-narrator {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
  text-align: center;
}

.g-dialog.is-narrator .g-dialog-name {
  display: none;
}

.g-dialog.is-narrator .g-dialog-text {
  font-size: 1.08rem;
  font-style: italic;
}

.g-dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.g-dialog-skip {
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 2px 0;
  text-decoration: underline;
  cursor: pointer;
}

.g-dialog-next {
  font-size: 0.7rem;
  opacity: 0;
}

.g-dialog.is-done .g-dialog-next {
  opacity: 1;
  animation: g-bob 0.8s ease-in-out infinite;
}

.g-dialog.is-asking {
  cursor: default;
}

.g-dialog.is-asking .g-dialog-foot {
  display: none;
}

.g-name-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.g-name-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 1rem;
  border: 1.5px solid var(--text);
  border-radius: 6px;
}

/* ---------- World map ---------- */

.g-node {
  position: absolute;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.g-node:hover:not(.is-locked) {
  box-shadow: 0 0 0 5px rgba(26, 26, 26, 0.12);
}

.g-node:focus-visible {
  outline: 2px dashed var(--text);
  outline-offset: 6px;
}

.g-node.is-locked {
  cursor: not-allowed;
}

.g-node-label {
  position: absolute;
  top: 100%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
  padding: 2px 6px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  pointer-events: none;
}

.g-node-label b {
  font-size: 0.8rem;
}

.g-node-label small {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.g-node.is-locked .g-node-label b {
  color: var(--muted);
}

.g-node.is-side .g-node-label {
  top: 50%;
  left: 100%;
  align-items: flex-start;
  margin: 0 0 0 10px;
  transform: translateY(-50%);
}

.g-node.is-shaking {
  animation: g-shake 0.35s ease;
}

.g-road-label {
  position: absolute;
  padding: 2px 6px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
}

/* ---------- Realm ---------- */

.g-realm-head {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: min(440px, 58%);
  padding: 8px 14px 10px 6px;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
  background: rgba(255, 255, 255, 0.94);
}

.g-realm-head h3 {
  font-size: 1.15rem;
  line-height: 1.2;
}

.g-realm-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.g-back {
  flex-shrink: 0;
  font-size: 0.78rem;
}

.g-flag-hit {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.g-flag-hit:hover:not(.is-locked) {
  background: rgba(26, 26, 26, 0.05);
}

.g-flag-hit:focus-visible {
  outline: 2px dashed var(--text);
}

.g-flag-hit.is-locked {
  cursor: not-allowed;
}

.g-stage-card-slot {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(300px, 40%);
}

.g-card {
  padding: 14px 16px;
  border: 2px solid var(--text);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--g-shadow);
}

.g-card h3 {
  margin: 2px 0 4px;
  font-size: 1.2rem;
  line-height: 1.2;
}

.g-card-sub {
  font-size: 0.82rem;
  color: #444;
}

.g-card-stars {
  margin-top: 6px;
  letter-spacing: 2px;
}

.g-card-stars span {
  font-size: 1.25rem;
  color: #d9d9d9;
}

.g-card-stars span.on {
  color: var(--text);
}

.g-card-hint {
  margin: 4px 0 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.g-stage-card .g-btn-primary {
  width: 100%;
  margin-top: 4px;
}

.g-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.g-card-actions .g-btn-primary {
  flex: 1 1 auto;
}

/* ---------- Battle HUD ---------- */

.g-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.g-hud-card {
  width: min(250px, 38%);
  padding: 7px 10px;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
  background: rgba(255, 255, 255, 0.94);
  transition: box-shadow 0.2s ease;
}

.g-hud-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.g-hud-top b {
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-hud-top span {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.g-hp {
  position: relative;
  height: 10px;
  margin: 5px 0 4px;
  overflow: hidden;
  border: 1.5px solid var(--text);
  border-radius: 5px;
  background: #fff;
}

.g-hp i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
}

.g-hp-lag {
  background: #c4c4c4;
  transition: width 0.7s ease 0.3s;
}

.g-hp-fill {
  background: var(--text);
  transition: width 0.25s ease;
}

.g-hud-card.is-low .g-hp-fill {
  background: repeating-linear-gradient(45deg, var(--text) 0 4px, #555 4px 8px);
  animation: g-pulse 0.9s ease-in-out infinite;
}

.g-hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 12px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.g-burst {
  display: inline-flex;
  gap: 3px;
}

.g-burst.is-hidden {
  display: none;
}

.g-burst i {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--text);
  border-radius: 50%;
}

.g-burst i.on {
  background: var(--text);
}

.g-hud-hero.is-guarded {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--text);
}

.g-hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 4px;
  font-size: 0.72rem;
  text-align: center;
  color: var(--muted);
}

.g-hud-mid b {
  font-size: 0.78rem;
  color: var(--text);
}

.g-hud-enemy.is-empty {
  visibility: hidden;
}

.g-hud-enemy.is-charging {
  animation: g-jitter 0.25s linear infinite;
}

.g-enemy-status {
  font-weight: 800;
  color: var(--text);
}

.g-retreat {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 0.75rem;
}

/* ---------- Questions ---------- */

.g-q-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

.g-q-move {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--text);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.g-q-tag {
  flex: 1;
  min-width: 0;
  color: var(--muted);
}

.g-q-diff {
  padding: 2px 8px;
  border: 1.5px solid var(--text);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}

.g-q-diff.d-M {
  background: linear-gradient(90deg, var(--text) 50%, #fff 50%);
  color: #fff;
  text-shadow: 0 0 2px var(--text);
}

.g-q-diff.d-H {
  background: var(--text);
  color: #fff;
}

.g-q-timer {
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.g-q .viewer-stimulus {
  margin-bottom: 12px;
}

.g-q .viewer-stem {
  margin-bottom: 0;
}

.g-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.g-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: left;
  color: var(--text);
  border: 1.5px solid var(--border-dark);
  border-radius: var(--g-radius);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease, box-shadow 0.08s ease;
}

.g-choice:hover:not(:disabled) {
  border-color: var(--text);
  background: var(--hover);
}

.g-choice.is-selected {
  border-color: var(--text);
  box-shadow: 3px 3px 0 var(--text);
  transform: translate(-1px, -1px);
}

.g-choice:disabled,
div.g-choice {
  cursor: default;
}

.g-choice-letter {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--text);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 800;
}

.g-choice.is-selected .g-choice-letter,
.g-choice.is-correct .g-choice-letter {
  background: var(--text);
  color: #fff;
}

.g-choice-content {
  flex: 1;
  min-width: 0;
}

.g-choice.is-correct {
  border: 2.5px solid var(--text);
  box-shadow: none;
  transform: none;
}

.g-choice.is-correct::after,
.g-choice.is-wrong::after {
  flex-shrink: 0;
  margin-left: auto;
  font-weight: 900;
}

.g-choice.is-correct::after {
  content: "✓";
}

.g-choice.is-wrong {
  border-style: dashed;
  border-color: var(--text);
  color: var(--muted);
  box-shadow: none;
  transform: none;
}

.g-choice.is-wrong::after {
  content: "✗";
  color: var(--text);
}

.g-choice.is-wrong .g-choice-letter {
  background: #fff;
  color: var(--muted);
  border-style: dashed;
}

.g-choice.is-erased {
  opacity: 0.35;
  border-style: dashed;
}

.g-choice.is-erased .g-choice-content,
.g-choice.is-wrong .g-choice-content {
  text-decoration: line-through;
}

.g-q-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.g-lock {
  min-width: 130px;
  margin-left: auto;
  padding: 10px 16px;
}

.g-lock:not(:disabled) {
  box-shadow: 3px 3px 0 #bdbdbd;
}

/* ---------- Review ---------- */

.g-review,
.g-moves,
.g-continue {
  scroll-margin: 16px;
}

.g-review {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid var(--text);
  animation: g-rise 0.25s ease both;
}

.g-result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.g-result-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--text);
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 900;
}

.g-review.is-right .g-result-icon,
.g-review.is-burst .g-result-icon {
  background: var(--text);
  color: #fff;
}

.g-review.is-wrong .g-result-icon {
  border-style: dashed;
}

.g-result b {
  display: block;
  font-size: 1rem;
}

.g-result span {
  font-size: 0.86rem;
  color: #444;
}

.g-explain {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--g-radius);
  background: #fafafa;
}

.g-explain summary {
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.g-explain-body {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #333;
}

.g-explain-body p {
  margin-bottom: 0.5em;
}

/* ---------- Moves ---------- */

.g-moves {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.g-panel > .g-moves:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.g-moves-note {
  margin-bottom: 12px;
  font-size: 0.95rem;
  line-height: 1.45;
}

.g-moves-warn {
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1.5px dashed var(--text);
  border-radius: var(--g-radius);
  font-size: 0.85rem;
  line-height: 1.45;
}

.g-move-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.g-move {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: var(--text);
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
  background: #fff;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.g-move:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--text);
}

.g-move:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.g-move kbd {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

.g-move-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.g-move-text b {
  font-size: 0.92rem;
}

.g-move-text small {
  font-size: 0.74rem;
  color: var(--muted);
}

.g-move em {
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}

.g-move.is-ready {
  background: var(--text);
  color: #fff;
  animation: g-glow 1.1s ease-in-out infinite;
}

.g-move.is-ready small,
.g-move.is-ready em {
  color: #d0d0d0;
}

.g-item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.g-item small {
  display: inline;
  margin-left: 4px;
}

.g-moves-hint {
  margin-left: auto;
  font-size: 0.74rem;
  color: var(--muted);
}

.g-continue {
  margin-top: 16px;
}

/* ---------- Sheets, modals, toasts ---------- */

.g-sheet-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(2px);
  animation: g-fade 0.15s ease both;
}

.g-sheet {
  width: min(480px, 100%);
  margin: auto 0;
  animation: g-rise 0.2s ease both;
}

.g-sheet.is-wide {
  width: min(780px, 100%);
}

.g-sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.g-sheet-head > :first-child {
  flex: 1;
}

.g-sheet-head h3 {
  font-size: 1.3rem;
}

.g-results-title {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.g-results-sub {
  margin-top: 4px;
  font-size: 0.9rem;
  color: #444;
}

.g-results-stars {
  margin: 4px 0 2px;
}

.g-results-stars span {
  display: inline-block;
  font-size: 2.4rem;
  color: #dcdcdc;
  animation: g-star-pop 0.45s ease both;
}

.g-results-stars span.on {
  color: var(--text);
}

.g-results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.g-results-grid > div {
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  text-align: center;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
}

.g-results-grid b {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.g-results-grid span {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.g-levelup {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--g-radius);
  background: var(--text);
  color: #fff;
  font-size: 0.85rem;
  animation: g-rise 0.3s ease 0.3s both;
}

.g-levelup b {
  font-size: 1rem;
}

.g-newmove {
  color: #e0e0e0;
}

.g-newmove b {
  display: inline;
  font-size: inherit;
  color: #fff;
}

.g-results-note {
  margin: 8px 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #444;
}

.g-modal {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.g-modal-card {
  width: min(390px, 100%);
}

.g-modal-card h3 {
  margin-bottom: 6px;
}

.g-modal-card p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #444;
}

.g-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 40;
  padding: 8px 14px;
  transform: translateX(-50%);
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  animation: g-toast 2.2s ease both;
}

/* ---------- Notebook ---------- */

.g-nb-h {
  margin: 18px 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.g-nb-intro {
  margin: -2px 0 10px;
  font-size: 0.8rem;
}

.g-nb-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(60px, 1fr) 56px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.g-nb-name b {
  display: block;
  font-size: 0.85rem;
}

.g-nb-name small {
  font-size: 0.7rem;
  color: var(--muted);
}

.g-nb-bar {
  height: 9px;
  overflow: hidden;
  border: 1.5px solid var(--text);
  border-radius: 5px;
}

.g-nb-bar i {
  display: block;
  height: 100%;
  background: var(--text);
}

.g-nb-num {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  font-weight: 800;
  text-align: right;
}

.g-nb-num small {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
}

.g-nb-q {
  margin-bottom: 6px;
  border: 1px solid var(--border-dark);
  border-radius: var(--g-radius);
}

.g-nb-q summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.g-nb-q summary small {
  margin-left: auto;
  color: var(--muted);
}

.g-nb-q-body {
  padding: 4px 12px 12px;
}

.g-nb-q-body .g-explain-body {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.g-nb-empty {
  padding: 16px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
  border: 1.5px dashed var(--border-dark);
  border-radius: var(--g-radius);
}

/* ---------- Stationer ---------- */

.g-shop-wallet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1.5px solid var(--text);
  border-radius: 999px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.g-shop-items {
  display: grid;
  gap: 8px;
}

.g-shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
}

.g-shop-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.g-shop-text b {
  font-size: 0.95rem;
}

.g-shop-text small {
  font-size: 0.76rem;
  color: var(--muted);
}

.g-shop-icon {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
}

.g-icon-eraser::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 6px;
  width: 20px;
  height: 10px;
  border: 2px solid var(--text);
  border-radius: 3px;
  background: linear-gradient(90deg, var(--text) 42%, #fff 42%);
  transform: rotate(-20deg);
}

.g-icon-tonic::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 9px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--text);
  border-radius: 50%;
  background: linear-gradient(transparent 48%, var(--text) 48%);
}

.g-icon-tonic::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 14px;
  width: 5px;
  height: 9px;
  border: 2px solid var(--text);
  border-bottom: 0;
}

.g-shop-hats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.g-hat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  text-align: center;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--g-radius);
}

.g-hat.is-on {
  border-color: var(--text);
  box-shadow: 3px 3px 0 var(--text);
}

.g-hat canvas {
  width: 90px;
  height: 90px;
}

.g-hat b {
  font-size: 0.82rem;
}

.g-hat .g-btn {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.75rem;
}

/* ---------- Menu ---------- */

.g-rename label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.g-rename-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.g-menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.g-menu-foot {
  margin-top: 12px;
  font-size: 0.75rem;
}

/* ---------- Motion ---------- */

@keyframes g-rise {
  from {
    opacity: 0;
    translate: 0 8px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes g-fade {
  from {
    opacity: 0;
  }
}

@keyframes g-bob {
  50% {
    transform: translateY(3px);
  }
}

@keyframes g-pulse {
  50% {
    opacity: 0.55;
  }
}

@keyframes g-glow {
  50% {
    box-shadow: 0 0 0 4px rgba(26, 26, 26, 0.18);
  }
}

@keyframes g-jitter {
  25% {
    translate: -1px 0;
  }
  75% {
    translate: 1px 0;
  }
}

@keyframes g-shake {
  20%,
  60% {
    translate: -6px 0;
  }
  40%,
  80% {
    translate: 6px 0;
  }
}

@keyframes g-star-pop {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-30deg);
  }
  70% {
    transform: scale(1.25);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes g-toast {
  from {
    opacity: 0;
    translate: 0 -8px;
  }
  10%,
  85% {
    opacity: 1;
    translate: 0 0;
  }
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .g-dialog.is-done .g-dialog-next,
  .g-move.is-ready,
  .g-hud-card.is-low .g-hp-fill,
  .g-hud-enemy.is-charging {
    animation: none;
  }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1000px) {
  .game-root {
    --g-stage-h: clamp(360px, 62vh, 560px);
    --g-battle-h: clamp(210px, 36vh, 320px);
  }

  .g-main {
    flex-direction: column;
    align-items: stretch;
  }

  .g-main.is-battle .g-stage {
    position: sticky;
    top: 0;
    z-index: 5;
    flex: none;
    height: var(--g-battle-h);
  }

  .g-panel {
    flex: none;
    max-width: none;
    height: auto;
    min-height: 240px;
    overflow: visible;
  }

  .g-review,
  .g-moves,
  .g-continue {
    scroll-margin-top: calc(var(--g-battle-h) + 16px);
  }

  .g-sheet-layer {
    position: fixed;
    z-index: 1000;
  }
}

@media (max-width: 640px) {
  .g-topbar {
    gap: 8px;
    padding: 6px 8px;
  }

  .g-xp {
    width: 64px;
  }

  .g-top-actions {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .g-top-actions .g-btn {
    padding: 5px 7px;
    font-size: 0.76rem;
  }

  .g-hud {
    top: 6px;
    left: 6px;
    right: 6px;
  }

  .g-hud-card {
    width: 46%;
    padding: 4px 7px;
  }

  .g-hud-top {
    font-size: 0.72rem;
  }

  .g-hud-mid {
    display: none;
  }

  .g-hp {
    height: 8px;
    margin: 3px 0;
  }

  .g-hud-bottom {
    font-size: 0.64rem;
  }

  .g-retreat {
    padding: 3px 7px;
    font-size: 0.7rem;
  }

  .g-realm-head {
    right: 10px;
    left: 10px;
    top: 10px;
    max-width: none;
  }

  .g-stage-card-slot {
    top: 92px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  .g-card {
    padding: 10px 12px;
  }

  .g-card-hint {
    display: none;
  }

  .g-results-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .g-dialog {
    bottom: 8px;
    padding: 10px 12px 6px;
  }

  .g-dialog-text {
    font-size: 0.9rem;
  }

  .g-move-list {
    grid-template-columns: 1fr;
  }

  .g-panel {
    padding: 14px 12px;
  }

  .g-title-actions .g-btn {
    min-width: 150px;
  }

  .g-title {
    justify-content: flex-start;
    padding: 12% 16px 0;
  }

  .g-logo {
    font-size: 3.3rem;
  }

  .g-title-foot {
    display: none;
  }

  .g-main.is-world .g-stage {
    height: clamp(560px, 165vw, 720px);
  }

  .g-node-label b {
    font-size: 0.74rem;
  }

  .g-node-label small {
    font-size: 0.64rem;
  }

  .g-road-label {
    font-size: 0.6rem;
    letter-spacing: 0.08em;
  }
}

/* ---------- Question settings (shared by SAT Quest and SAT Run) ---------- */

.q-pool-overlay {
  position: fixed;
  inset: 0;
  z-index: 960;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
}

.q-pool {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px 20px 16px;
  border: 2px solid var(--text);
  border-radius: 10px;
  background: #fff;
  box-shadow: 4px 4px 0 var(--text);
}

.q-pool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.q-pool-head h3 {
  font-size: 1.25rem;
  font-weight: 900;
}

.q-pool-x {
  width: 30px;
  height: 30px;
  font: inherit;
  border: 1.5px solid var(--text);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.q-pool-note {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.q-pool-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.q-pool-label span {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.q-pool .multi-select-trigger {
  width: 100%;
  max-width: none;
}

.q-pool .multi-select-menu {
  width: 100%;
  max-width: none;
  max-height: 260px;
}

.q-pool-diffs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.q-pool-diffs button {
  padding: 7px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1.5px solid var(--text);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.q-pool-diffs button.on {
  background: var(--text);
  color: #fff;
}

.q-pool-count {
  margin-top: 14px;
  font-size: 0.86rem;
}

.q-pool-count span {
  color: var(--muted);
}

.q-pool-count.is-empty {
  color: var(--wrong-border, #c62828);
}

.q-pool-cb {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.q-pool-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.q-pool-actions span {
  flex: 1;
}

/* Student-produced response (grid-in) */

.q-spr {
  margin: 4px 0 6px;
}

.q-spr-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.q-spr-input {
  width: min(260px, 100%);
  padding: 10px 12px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  border: 2px solid var(--text);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.q-spr-input:focus {
  outline: 3px solid rgba(26, 26, 26, 0.18);
}

.q-spr-input.is-correct {
  background: #f1f1f1;
}

.q-spr-input.is-wrong {
  border-style: dashed;
  color: var(--muted);
}

.q-spr-hint {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.q-pool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1.5px dashed var(--text);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.q-pool-chip b {
  font-weight: 800;
}

.q-pool-chip:hover {
  border-style: solid;
}

@media (max-width: 640px) {
  .q-pool-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .q-pool {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 12px 12px 0 0;
    border-bottom: 0;
    box-shadow: none;
  }
}

.g-title-pool {
  margin-top: 14px;
}

.g-nb-spr {
  margin: 8px 0;
  font-size: 0.9rem;
}

/* Question settings card on each game's title screen (settings are shared by every game) */

.q-pool-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  width: min(420px, 100%);
  padding: 10px 14px;
  font: inherit;
  text-align: left;
  border: 2px solid var(--text);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: 3px 3px 0 var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.q-pool-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--text);
}

.q-pool-card:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--text);
}

.q-pool-card:focus-visible {
  outline: 2px dashed var(--text);
  outline-offset: 3px;
}

.q-pool-card-k {
  grid-column: 1 / -1;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.q-pool-card-k i {
  margin-left: 6px;
  padding: 0 5px;
  font-style: normal;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-dark, #bdbdbd);
  border-radius: 4px;
}

.q-pool-card > b {
  font-size: 0.98rem;
  line-height: 1.25;
}

.q-pool-card-go {
  grid-row: 2 / span 2;
  grid-column: 2;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.q-pool-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.q-pool-card-tags em {
  padding: 1px 7px;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 600;
  border: 1px solid var(--text);
  border-radius: 999px;
}
