*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Nunito', 'Helvetica Neue', sans-serif;
  --bg: #FFF8F0;
  --radius: 20px;
  --shadow: 0 4px 20px rgba(0,0,0,.12);
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); overflow: hidden; }

/* ── SCREENS ── */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; overflow-y: auto; }
.screen.active { display: flex; }

/* ── MENU ── */
#screen-menu {
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, #667eea 0%, #764ba2 100%);
  color: #fff; text-align: center; padding: 2rem;
}
.menu-logo { font-size: 6rem; line-height: 1; }
.menu-title { font-size: 3.5rem; font-weight: 900; margin: .5rem 0; letter-spacing: -1px; }
.menu-sub { font-size: 1.3rem; opacity: .85; margin-bottom: 2.5rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font); font-weight: 800;
  border: none; border-radius: 50px; cursor: pointer;
  transition: transform .1s; user-select: none;
}
.btn-primary { background: #FF6B35; color: #fff; box-shadow: 0 6px 0 #B84A20; }
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #B84A20; }
.btn-white { background: #fff; color: #764ba2; box-shadow: 0 6px 0 rgba(0,0,0,.15); }
.btn-white:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.btn-xl { font-size: 1.6rem; padding: .9rem 2.8rem; }

.icon-btn {
  background: rgba(255,255,255,.2); border: none; border-radius: 50%;
  width: 48px; height: 48px; font-size: 1.3rem; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,.35); }

/* ── TOP BAR ── */
.top-bar {
  display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; flex-shrink: 0;
}
.top-bar h2 { font-size: 1.5rem; font-weight: 800; flex: 1; text-align: center; }
.spacer { width: 48px; flex-shrink: 0; }

/* ── DIFFICULTY SCREEN ── */
#screen-difficulties { background: var(--bg); }
.diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem; padding: 1.25rem; overflow-y: auto;
}
.diff-card {
  border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center;
  cursor: pointer; color: #fff; border: none; font-family: var(--font);
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
}
.diff-card:hover { transform: translateY(-4px); box-shadow: 0 8px 28px rgba(0,0,0,.2); }
.diff-card:active { transform: scale(.95); }
.dc-icon { font-size: 2.2rem; }
.dc-num  { font-size: .7rem; font-weight: 700; opacity: .8; text-transform: uppercase; letter-spacing: 1px; }
.dc-name { font-size: .95rem; font-weight: 800; line-height: 1.2; }
.dc-prog { font-size: .8rem; opacity: .9; }
.dc-stars { font-size: 1rem; min-height: 1.2rem; }

/* ── EXERCISE SCREEN ── */
#screen-exercise { background: var(--bg); }
.level-meta { flex: 1; display: flex; flex-direction: column; align-items: center; }
.meta-diff  { font-size: .8rem; opacity: .8; font-weight: 700; }
.meta-level { font-size: 1.1rem; font-weight: 900; }

.prog-bar-wrap { height: 10px; background: #E0E0E0; flex-shrink: 0; }
.prog-bar-fill { height: 100%; background: linear-gradient(90deg, #FFB800, #FF6B35); transition: width .4s; border-radius: 0 5px 5px 0; }

.ex-main {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem 1.25rem 2rem; gap: 1.5rem; overflow-y: auto;
  max-width: 520px; margin: 0 auto; width: 100%;
}
.ex-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem 2rem; font-size: clamp(1.8rem, 7vw, 3rem);
  font-weight: 900; width: 100%; text-align: center; color: #333; letter-spacing: -1px;
}

.ans-area { display: flex; flex-direction: column; gap: .9rem; width: 100%; }
.ans-row  { display: flex; align-items: center; gap: .75rem; }
.ans-label { font-size: 1.1rem; font-weight: 800; color: #555; min-width: 110px; text-align: right; }
.ans-input {
  font-family: var(--font); font-size: 2.4rem; font-weight: 900;
  width: 150px; padding: .4rem .75rem; border: 4px solid #CCC;
  border-radius: var(--radius); text-align: center; transition: border-color .2s;
  background: #fff; color: #333; -moz-appearance: textfield;
}
.ans-input::-webkit-outer-spin-button,
.ans-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ans-input:focus { outline: none; border-color: #667eea; }
.ans-input.ok  { border-color: #4CAF50; background: #F1FBF1; color: #2E7D32; }
.ans-input.err { border-color: #F44336; background: #FFF1F0; color: #C62828; }

.feedback { font-size: 1.6rem; font-weight: 900; text-align: center; min-height: 2.5rem; }
.feedback.ok  { color: #4CAF50; }
.feedback.err { color: #F44336; }

/* ── CELEBRATE ── */
.celebrate-screen {
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f093fb 0%, #f5576c 100%);
  color: #fff; text-align: center; padding: 2rem;
}
.cel-emoji { font-size: 6rem; animation: bounce .8s infinite alternate; }
@keyframes bounce { to { transform: translateY(-18px); } }
.celebrate-inner h2 { font-size: 2.2rem; font-weight: 900; margin: 1rem 0 .5rem; }
.celebrate-inner p  { font-size: 1.2rem; opacity: .9; margin-bottom: 2rem; }

/* ── PIZARRA ── */
.pizarra-overlay {
  position: fixed; inset: 0; background: #1B6B3A; z-index: 100;
  display: flex; flex-direction: column;
}
.pizarra-overlay.hidden { display: none; }
.piz-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem; background: rgba(0,0,0,.3); gap: 1rem; flex-wrap: wrap;
}
.piz-label { color: #fff; font-size: 1.8rem; font-weight: 900; flex: 1; text-align: center; }
.piz-actions { display: flex; gap: .5rem; }
.piz-btn {
  font-family: var(--font); font-weight: 700; font-size: 1rem;
  border: none; border-radius: 12px; padding: .5rem 1rem;
  cursor: pointer; color: #fff; background: rgba(255,255,255,.2);
  transition: background .15s;
}
.piz-btn:hover { background: rgba(255,255,255,.35); }
.piz-btn-close { background: rgba(220,50,50,.55); }
.piz-btn-close:hover { background: rgba(220,50,50,.8); }
#piz-canvas { flex: 1; width: 100%; display: block; cursor: crosshair; touch-action: none; }

/* ── ANIMACIONES ── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  15%     { transform: translateX(-10px); }
  35%     { transform: translateX(10px); }
  55%     { transform: translateX(-7px); }
  75%     { transform: translateX(7px); }
  90%     { transform: translateX(-3px); }
}
@keyframes pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.07); }
  65%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes menuPulse {
  0%,100% { box-shadow: 0 6px 0 #B84A20; }
  50%     { box-shadow: 0 6px 24px rgba(255,107,53,.55), 0 6px 0 #B84A20; }
}
.anim-shake { animation: shake 0.45s ease; }
.anim-pop   { animation: pop 0.35s ease; }
.anim-slide { animation: slideUp 0.35s ease both; }
#screen-menu .btn-primary { animation: menuPulse 2.2s ease-in-out infinite; }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .menu-title { font-size: 2.5rem; }
  .ex-card { padding: 1.25rem; }
  .ans-input { font-size: 2rem; width: 130px; }
  .diff-grid { grid-template-columns: repeat(2, 1fr); }
  .btn-xl { font-size: 1.3rem; padding: .8rem 2rem; }
}
@media (min-width: 800px) {
  .diff-grid { grid-template-columns: repeat(3, 1fr); max-width: 700px; margin: 0 auto; }
}
