/* Sudoku Escolar — visual alegre para ensino fundamental */

:root {
  --sky: #4fc3f7;
  --sky-deep: #0288d1;
  --sun: #ffd54f;
  --sun-deep: #ffb300;
  --coral: #ff7043;
  --coral-deep: #e64a19;
  --mint: #66bb6a;
  --mint-deep: #2e7d32;
  --lavender: #ba68c8;
  --ink: #1a237e;
  --ink-soft: #3949ab;
  --paper: #fffef8;
  --card: #ffffff;
  --line: #c5cae9;
  --shadow: 0 12px 32px rgba(2, 136, 209, 0.18);
  --radius: 22px;
  --font-display: "Fredoka", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 213, 79, 0.55), transparent 42%),
    radial-gradient(circle at 88% 12%, rgba(79, 195, 247, 0.5), transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(255, 112, 67, 0.28), transparent 45%),
    radial-gradient(circle at 20% 85%, rgba(102, 187, 106, 0.3), transparent 40%),
    linear-gradient(160deg, #e3f2fd 0%, #fff8e1 45%, #fce4ec 100%);
  background-attachment: fixed;
}

a {
  color: var(--sky-deep);
  text-decoration: none;
  font-weight: 700;
}

a:hover {
  text-decoration: underline;
}

.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: floaty 8s ease-in-out infinite;
}

.blob-1 {
  width: 180px;
  height: 180px;
  background: var(--sun);
  top: 8%;
  left: -40px;
}

.blob-2 {
  width: 140px;
  height: 140px;
  background: var(--coral);
  bottom: 12%;
  right: -30px;
  animation-delay: -3s;
}

.blob-3 {
  width: 100px;
  height: 100px;
  background: var(--mint);
  top: 55%;
  left: 8%;
  animation-delay: -5s;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.05); }
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 28px 0 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  background: linear-gradient(135deg, var(--sun), var(--coral));
  box-shadow: 0 8px 18px rgba(230, 74, 25, 0.25);
  animation: bounceSoft 2.4s ease-in-out infinite;
}

@keyframes bounceSoft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.brand h1,
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.1rem);
  margin: 0;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--sky-deep), var(--coral-deep), var(--lavender));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 6px 0 28px;
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 42ch;
}

.panel {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}

.panel + .panel {
  margin-top: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
}

@media (max-width: 860px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 1rem;
  cursor: pointer;
  background: #e8eaf6;
  color: var(--ink-soft);
  transition: transform 0.15s ease, background 0.2s ease;
}

.tab.active {
  background: linear-gradient(135deg, var(--sky), var(--sky-deep));
  color: white;
  box-shadow: 0 6px 14px rgba(2, 136, 209, 0.35);
}

.tab:hover {
  transform: translateY(-2px);
}

label {
  display: block;
  font-weight: 800;
  margin: 12px 0 6px;
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(79, 195, 247, 0.25);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  padding: 13px 22px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--coral), var(--sun));
  color: #4a148c;
  box-shadow: 0 8px 18px rgba(255, 112, 67, 0.35);
}

.btn-primary:hover {
  color: #4a148c;
}

.btn-sky {
  background: linear-gradient(135deg, var(--sky), var(--sky-deep));
  color: white;
  box-shadow: 0 8px 18px rgba(2, 136, 209, 0.3);
}

.btn-sky:hover {
  color: white;
}

.btn-mint {
  background: linear-gradient(135deg, #a5d6a7, var(--mint-deep));
  color: white;
  box-shadow: 0 8px 18px rgba(46, 125, 50, 0.28);
}

.btn-mint:hover {
  color: white;
}

.btn-ghost {
  background: white;
  color: var(--ink-soft);
  border: 3px solid var(--line);
}

.btn-block {
  width: 100%;
  margin-top: 16px;
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
  font-weight: 700;
  display: none;
}

.alert.show {
  display: block;
  animation: popIn 0.35s ease;
}

.alert-erro {
  background: #ffebee;
  color: #c62828;
  border: 2px solid #ef9a9a;
}

.alert-ok {
  background: #e8f5e9;
  color: #2e7d32;
  border: 2px solid #a5d6a7;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.hero-card {
  background: linear-gradient(145deg, #fff59d, #81d4fa 55%, #ffab91);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hero-card::before {
  content: "9";
  position: absolute;
  font-family: var(--font-display);
  font-size: 12rem;
  opacity: 0.18;
  right: -10px;
  top: -30px;
  line-height: 1;
}

.hero-card h2 {
  font-family: var(--font-display);
  margin: 0 0 8px;
  font-size: 1.8rem;
  color: var(--ink);
  position: relative;
}

.hero-card p {
  margin: 0;
  position: relative;
  font-weight: 700;
  color: #283593;
}

.nivel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.nivel-opt {
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  transition: transform 0.15s ease, border-color 0.2s ease;
  color: white;
}

.nivel-opt:hover {
  transform: translateY(-3px);
}

.nivel-opt input {
  display: none;
}

.nivel-opt.facil { background: linear-gradient(135deg, #81c784, #43a047); }
.nivel-opt.medio { background: linear-gradient(135deg, #64b5f6, #1e88e5); }
.nivel-opt.dificil { background: linear-gradient(135deg, #ffb74d, #fb8c00); }
.nivel-opt.expert { background: linear-gradient(135deg, #e57373, #e53935); }

.nivel-opt.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.25);
  transform: scale(1.03);
}

.codigo-mega {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.8rem);
  letter-spacing: 0.28em;
  text-align: center;
  background: linear-gradient(135deg, #fffde7, #e1f5fe);
  border: 4px dashed var(--sky-deep);
  border-radius: 20px;
  padding: 18px;
  margin: 12px 0;
  color: var(--ink);
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(2, 136, 209, 0.2); }
  50% { box-shadow: 0 0 0 10px rgba(2, 136, 209, 0); }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}

@media (max-width: 700px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat {
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  color: white;
  font-weight: 800;
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  line-height: 1.1;
}

.stat-entrou { background: linear-gradient(135deg, #4fc3f7, #0288d1); }
.stat-jogando { background: linear-gradient(135deg, #ffd54f, #ff8f00); color: #4e342e; }
.stat-concluiu { background: linear-gradient(135deg, #81c784, #2e7d32); }
.stat-saiu { background: linear-gradient(135deg, #b0bec5, #546e7a); }

.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 2px solid #e8eaf6;
}

th {
  font-family: var(--font-display);
  background: #e3f2fd;
  color: var(--ink);
}

tr:hover td {
  background: #fffde7;
}

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  color: white;
}

.badge-entrou { background: #0288d1; }
.badge-jogando { background: #fb8c00; color: #fff8e1; }
.badge-concluiu { background: #2e7d32; }
.badge-saiu { background: #607d8b; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.sala-lista {
  display: grid;
  gap: 12px;
}

.sala-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(90deg, #e3f2fd, #fff8e1);
  border: 2px solid #bbdefb;
}

.sala-item strong {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.12em;
}

/* ===== JOGO ===== */

.game-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.pill {
  background: white;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 0.95rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
  width: min(100%, 520px);
  aspect-ratio: 1;
  background: #1a237e;
  border: 5px solid #1a237e;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 0 auto;
}

.cell {
  display: grid;
  place-items: center;
  background: #fffef8;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3.5vw, 1.7rem);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid #c5cae9;
  border-bottom: 1px solid #c5cae9;
  transition: background 0.15s ease, transform 0.1s ease;
}

.cell:nth-child(9n) { border-right: none; }
.cell:nth-child(n+73) { border-bottom: none; }

.cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 3px solid #1a237e;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 3px solid #1a237e;
}

.cell.fixed {
  background: #e3f2fd;
  color: #0d47a1;
  cursor: default;
}

.cell.selected {
  background: #fff59d !important;
  transform: scale(1.04);
  z-index: 2;
}

.cell.same-num {
  background: #b3e5fc;
}

.cell.error {
  background: #ffcdd2 !important;
  color: #b71c1c;
  animation: shake 0.35s ease;
}

.cell.ok-flash {
  background: #c8e6c9 !important;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 280px);
  margin: 0 auto;
}

.num-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: 16px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  cursor: pointer;
  color: white;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease;
}

.num-btn:hover { transform: scale(1.06); }
.num-btn:active { transform: scale(0.95); }

.num-btn:nth-child(1) { background: #ef5350; }
.num-btn:nth-child(2) { background: #ff7043; }
.num-btn:nth-child(3) { background: #ffa726; }
.num-btn:nth-child(4) { background: #66bb6a; }
.num-btn:nth-child(5) { background: #26a69a; }
.num-btn:nth-child(6) { background: #42a5f5; }
.num-btn:nth-child(7) { background: #5c6bc0; }
.num-btn:nth-child(8) { background: #ab47bc; }
.num-btn:nth-child(9) { background: #ec407a; }

.erase-btn {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  padding: 12px;
  background: #78909c;
  font-size: 1.1rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 35, 126, 0.55);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.overlay.show {
  display: grid;
  animation: popIn 0.3s ease;
}

.overlay-card {
  background: white;
  border-radius: 24px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 0 0 10px;
  color: var(--mint-deep);
}

.footer-note {
  text-align: center;
  margin-top: 28px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.credito {
  text-align: center;
  margin: 18px 0 8px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.85;
}

.hidden { display: none !important; }

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
