/* DuOpen mini-game: "Corrige el examen". Everything is scoped under .dg-root. */
.dg-root {
  --dg-navy: #14213D;
  --dg-turq: #2EC4B6;
  --dg-coral: #FF6B6B;
  --dg-paper: #F7F5EF;
  --dg-ink: #1F5FBF;
  --dg-hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", cursive;
  --dg-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  background: var(--dg-navy);
  color: #fff;
  font-family: var(--dg-sans);
  font-size: 14px;
  line-height: 1.25;
  text-align: left;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(20, 33, 61, 0.25);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dg-root *,
.dg-root *::before,
.dg-root *::after { box-sizing: border-box; }

/* ---------- HUD ---------- */
.dg-hud {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 14px;
}
.dg-stat { display: flex; flex-direction: column; min-width: 58px; }
.dg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}
.dg-score {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.dg-combo {
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  transition: background-color 0.2s, color 0.2s;
}
.dg-combo.dg-hot { background: var(--dg-coral); color: var(--dg-navy); }
.dg-combo.dg-pop { animation: dg-pop 0.28s ease-out; }
.dg-gauges { display: flex; gap: 12px; flex: 1 1 200px; min-width: 0; }
.dg-gauge { flex: 1 1 0; min-width: 0; }
.dg-bar {
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.dg-bar > i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 0.18s linear;
}
.dg-gauge-tape .dg-bar > i { background: linear-gradient(90deg, var(--dg-turq), #9af0e7); }
.dg-gauge-ink .dg-bar > i { background: linear-gradient(90deg, var(--dg-ink), #6fa5f5); }
.dg-gauge.dg-low .dg-label { color: var(--dg-coral); }
.dg-gauge.dg-low .dg-bar { animation: dg-blink 0.7s ease-in-out infinite; }
.dg-lives { display: flex; gap: 3px; align-items: center; }
.dg-lives svg { width: 20px; height: 20px; fill: var(--dg-coral); transition: transform 0.25s, fill 0.25s, opacity 0.25s; }
.dg-lives svg.dg-lost { fill: #fff; opacity: 0.2; transform: scale(0.8); }
.dg-sound {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dg-sound svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; }
.dg-sound[aria-pressed="false"] { color: rgba(255, 255, 255, 0.55); }
.dg-sound:hover { background: rgba(255, 255, 255, 0.1); }
.dg-root button:focus-visible { outline: 3px solid var(--dg-turq); outline-offset: 2px; }

.dg-narrow .dg-hud { padding: 8px 10px; gap: 6px 10px; }
.dg-narrow .dg-gauges { order: 5; flex-basis: 100%; }
.dg-narrow .dg-stat { margin-right: auto; }
.dg-narrow .dg-score { font-size: 19px; }

/* ---------- Stage ---------- */
.dg-stage {
  position: relative;
  width: 100%;
  min-height: 300px;
  background: var(--dg-paper);
  overflow: hidden;
}
.dg-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}
.dg-playing .dg-canvas { touch-action: none; cursor: none; }

/* ---------- Overlays ---------- */
.dg-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(247, 245, 239, 0.88);
  color: var(--dg-navy);
  text-align: center;
  overflow: auto;
}
.dg-overlay[hidden] { display: none; }
.dg-card { max-width: 440px; width: 100%; animation: dg-rise 0.35s ease-out; }
.dg-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dg-turq);
  filter: brightness(0.8);
}
.dg-title {
  margin: 0 0 10px;
  font-family: var(--dg-hand);
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--dg-navy);
}
.dg-how { margin: 12px 0 16px; font-size: 15px; color: rgba(20, 33, 61, 0.82); }
.dg-how b { color: var(--dg-navy); }
.dg-demo {
  position: relative;
  display: inline-block;
  padding: 2px 10px;
  font-family: var(--dg-hand);
  font-size: 26px;
  line-height: 1.5;
  color: var(--dg-navy);
  border-bottom: 2px solid rgba(31, 95, 191, 0.25);
}
.dg-demo-tape {
  position: absolute;
  left: 2px;
  top: 14%;
  height: 72%;
  width: calc(100% - 4px);
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(20, 33, 61, 0.22);
  transform-origin: left center;
  animation: dg-demo-tape 3.6s ease-in-out infinite;
}
.dg-demo-fix {
  position: absolute;
  inset: 0;
  color: var(--dg-ink);
  animation: dg-demo-fix 3.6s ease-in-out infinite;
}
.dg-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  min-height: 48px;
  padding: 12px 34px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: var(--dg-turq);
  color: var(--dg-navy);
  font: 800 17px/1 var(--dg-sans);
  cursor: pointer;
  box-shadow: 0 4px 0 #1c9c90;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.dg-btn:hover { filter: brightness(1.06); }
.dg-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1c9c90; }
.dg-result { display: flex; justify-content: center; gap: 28px; margin: 6px 0 10px; }
.dg-result div { display: flex; flex-direction: column; }
.dg-result span { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: rgba(20, 33, 61, 0.6); }
.dg-result strong { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dg-rank { margin: 0 0 4px; font-family: var(--dg-hand); font-size: 22px; color: var(--dg-ink); }
.dg-record {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--dg-coral);
  color: var(--dg-navy);
  font-size: 12px;
  font-weight: 800;
}
.dg-record[hidden] { display: none; }
.dg-detail { margin: 0 0 14px; font-size: 13px; color: rgba(20, 33, 61, 0.7); }
.dg-slogan { margin: 14px 0 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: rgba(20, 33, 61, 0.55); }

@keyframes dg-pop { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes dg-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes dg-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes dg-demo-tape {
  0%, 18% { transform: scaleX(0); opacity: 1; }
  38%, 86% { transform: scaleX(1); opacity: 1; }
  96%, 100% { transform: scaleX(1); opacity: 0; }
}
@keyframes dg-demo-fix {
  0%, 42% { opacity: 0; }
  56%, 86% { opacity: 1; }
  96%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dg-card, .dg-combo.dg-pop, .dg-gauge.dg-low .dg-bar { animation: none; }
  .dg-demo-tape { animation: none; transform: none; }
  .dg-demo-fix { animation: none; opacity: 1; }
  .dg-bar > i, .dg-btn, .dg-lives svg { transition: none; }
}
