:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #687386;
  --line: #dce3ee;
  --paper: #ffffff;
  --panel: #f4f3fa;
  --violet: #7c5cc4;
  --violet-dark: #5c3da8;
  --orange: #f49a21;
  --green: #24856b;
  --shadow: 0 20px 58px rgba(38, 29, 67, 0.12);
}

@font-face {
  font-family: "Montserrat";
  src: url("../palabras-cruzadas/assets/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("../palabras-cruzadas/assets/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-display: swap;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Montserrat", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(124, 92, 196, 0.17), transparent 30rem),
    radial-gradient(circle at 95% 4%, rgba(244, 154, 33, 0.13), transparent 27rem),
    linear-gradient(180deg, #fcfbff, #f0f2f8);
}

button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; }

.app-shell { min-height: 100vh; padding: 24px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 22px;
  max-width: 1380px;
  margin: 0 auto;
}

.control-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: #b9abd9 transparent;
}

.library-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 12px;
  padding: 0 13px;
  border: 1px solid #ddd6ef;
  border-radius: 999px;
  color: var(--violet-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  background: #fff;
}

.library-link::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.brand-block {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid #e1daef;
  border-radius: 11px;
  background: linear-gradient(135deg, #fff, #f8f5ff);
  box-shadow: 0 10px 24px rgba(38, 29, 67, 0.06);
}

.brand-mark {
  width: 54px;
  height: 54px;
  padding: 6px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 9px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 10px 20px rgba(38, 29, 67, 0.1);
}

.brand-block > div::before {
  content: "SCOLATIO.COM";
  display: block;
  margin-bottom: 3px;
  color: var(--green);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

h1 { font-size: 1.2rem; line-height: 1.05; font-weight: 900; }

.brand-block p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 700;
  line-height: 1.28;
}

.controls { display: grid; gap: 13px; }

label {
  display: grid;
  gap: 7px;
  color: #374155;
  font-size: 0.84rem;
  font-weight: 800;
}

select, input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fcfbff;
  font-weight: 700;
}

select:focus, input:focus, button:focus-visible {
  outline: 3px solid rgba(124, 92, 196, 0.2);
  outline-offset: 2px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  gap: 10px;
}

input[type="range"] { width: 100%; accent-color: var(--violet); }

output {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 8px;
  color: var(--violet-dark);
  background: #f0ebff;
  font-weight: 900;
}

.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--violet); }

.button-stack { display: grid; gap: 10px; margin-top: 18px; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fcfbff;
  cursor: pointer;
  font-weight: 900;
}

button:hover { border-color: #b9abd9; background: #f8f5ff; }
.primary-btn { border-color: var(--violet); color: #fff; background: var(--violet); }
.primary-btn:hover { border-color: var(--violet-dark); background: var(--violet-dark); }
.activity-panel { min-width: 0; }

.worksheet {
  overflow: hidden;
  border: 1px solid #d9deea;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.worksheet-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 30px 20px;
  border-top: 8px solid var(--orange);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(124, 92, 196, 0.1), transparent 40%),
    linear-gradient(135deg, #fff, #faf8ff);
}

.masthead-brand {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.worksheet-logo {
  width: 62px;
  height: 62px;
  padding: 6px;
  border-radius: 9px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 12px 24px rgba(38, 29, 67, 0.12);
}

.worksheet-kicker {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#worksheet-title {
  margin-top: 3px;
  color: #121625;
  font-size: clamp(2rem, 3.3vw, 3.05rem);
  line-height: 1;
  font-weight: 900;
}

.issue-card {
  min-width: 190px;
  display: grid;
  gap: 6px;
  min-height: 52px;
  padding: 8px 0 8px 18px;
  border-left: 3px solid var(--violet);
  color: #344055;
  font-weight: 800;
  text-align: right;
}

.student-strip {
  display: grid;
  grid-template-columns: 1.5fr 0.85fr;
  gap: 18px;
  padding: 14px 30px;
  border-bottom: 1px solid var(--line);
  color: #38445a;
  background: #fcfbff;
  font-weight: 800;
}

.student-strip p { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 10px; }
.student-strip p::after { content: ""; border-bottom: 1.5px solid #334055; transform: translateY(-3px); }

.activity-instructions {
  padding: 15px 30px 2px;
  color: #252d40;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.4;
}

.activity-instructions strong { font-weight: 900; }
.activity-instructions p { margin-top: 3px; color: var(--muted); }

.riddle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 20px 30px 26px;
}

.riddle-card {
  --card: var(--violet);
  --card-soft: #f3efff;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--card);
  border-radius: 9px;
  background: linear-gradient(150deg, var(--card-soft), #fff 52%);
  page-break-inside: avoid;
}

.color-blue { --card: #235f9f; --card-soft: #edf5fd; }
.color-green { --card: #24856b; --card-soft: #edf9f5; }
.color-orange { --card: #d77c13; --card-soft: #fff6e9; }
.color-pink { --card: #bd4778; --card-soft: #fff0f6; }
.color-teal { --card: #148b8d; --card-soft: #ecfbfb; }
.color-indigo { --card: #4c5fb8; --card-soft: #eff1ff; }
.color-gold { --card: #a7740d; --card-soft: #fff9e8; }

.riddle-card-head {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
}

.riddle-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  background: var(--card);
  font-size: 0.78rem;
  font-weight: 900;
}

.riddle-passport { min-width: 0; }

.riddle-category {
  display: block;
  color: var(--card);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.riddle-era {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #737b8b;
  font-size: 0.61rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.difficulty-chip {
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--card) 24%, #fff);
  border-radius: 999px;
  color: var(--card);
  background: #fff;
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
}

.riddle-text {
  flex: 1;
  margin: 12px 0 13px;
  color: #1c2434;
  font-size: 0.89rem;
  font-weight: 700;
  line-height: 1.45;
}

.answer-line {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 9px;
  min-height: 25px;
}

.answer-label { color: #717b8c; font-size: 0.66rem; font-weight: 800; }

.answer-value {
  min-height: 22px;
  padding: 1px 5px 3px;
  border-bottom: 1.5px solid #707b8c;
  color: var(--card);
  font-size: 0.78rem;
  font-weight: 900;
}

.answer-line.is-revealed .answer-value { border-color: var(--card); background: var(--card-soft); }

.clue-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  margin: 0 0 10px;
  padding: 7px 9px;
  border-radius: 7px;
  color: #4b5363;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.68rem;
  line-height: 1.3;
}

.clue-strip strong { color: var(--card); }

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

.choice-option {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 31px;
  padding: 5px;
  border: 1px solid #d9dfeb;
  border-radius: 7px;
  color: #3a4354;
  background: #fff;
  font-size: 0.62rem;
  font-weight: 800;
}

.choice-option.is-answer { border-color: var(--green); color: #12604c; background: #eaf8f3; }
.choice-letter { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 999px; color: #fff; background: var(--card); font-size: 0.58rem; }
.choice-text { overflow-wrap: anywhere; }

.worksheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 30px 14px;
  border-top: 1px solid var(--line);
  color: #606b7d;
  background: #f9fafc;
  font-size: 0.72rem;
  font-weight: 700;
}

@media (max-width: 1040px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { position: static; max-height: none; overflow: visible; }
}

@media (max-width: 680px) {
  .app-shell { padding: 12px; }
  .worksheet-masthead { display: grid; padding: 20px; }
  .issue-card { min-width: 0; text-align: left; }
  .student-strip { grid-template-columns: 1fr; padding: 13px 20px; }
  .activity-instructions { padding-inline: 20px; }
  .riddle-grid { grid-template-columns: 1fr; padding: 18px 20px; }
  .worksheet-footer { display: grid; padding-inline: 20px; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .control-panel, .account-widget { display: none !important; }
  .app-shell { padding: 0; }
  .workspace { display: block; max-width: none; margin: 0; }
  .worksheet { width: 210mm; height: 297mm; border: 0; border-radius: 0; box-shadow: none; }
  .worksheet-masthead { padding: 8mm 12mm 6mm; border-top-width: 2.2mm; }
  .worksheet-logo { width: 16mm; height: 16mm; }
  .masthead-brand { grid-template-columns: 17mm minmax(0, 1fr); gap: 3mm; }
  #worksheet-title { font-size: 24pt; }
  .worksheet-kicker { font-size: 7pt; }
  .student-strip { padding: 3.4mm 12mm; font-size: 8.5pt; }
  .activity-instructions { padding: 3.4mm 12mm 0.5mm; font-size: 7.4pt; }
  .riddle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5mm; padding: 3.5mm 12mm 3mm; }
  .riddle-card { min-height: 0; height: 48mm; padding: 2.5mm 3mm; border-radius: 2mm; border-top-width: 1.2mm; }
  .riddle-grid[data-count="5"] .riddle-card, .riddle-grid[data-count="6"] .riddle-card { height: 55mm; }
  .riddle-card-head { grid-template-columns: 7mm minmax(0, 1fr) auto; gap: 2mm; }
  .riddle-number { width: 6.5mm; height: 6.5mm; font-size: 7pt; }
  .riddle-category { font-size: 6.2pt; }
  .riddle-era { max-width: 52mm; font-size: 5.2pt; }
  .difficulty-chip { padding: 0.8mm 1.2mm; font-size: 4.8pt; }
  .riddle-text { margin: 2.3mm 0; font-size: 7.4pt; line-height: 1.3; }
  .answer-label { font-size: 5.7pt; }
  .answer-value { min-height: 5mm; font-size: 6.5pt; }
  .clue-strip { margin-bottom: 1.5mm; padding: 1.2mm 1.5mm; font-size: 5.5pt; }
  .choice-list { gap: 1mm; }
  .choice-option { min-height: 6mm; padding: 0.8mm; grid-template-columns: 4mm minmax(0, 1fr); font-size: 5pt; }
  .choice-letter { width: 3.7mm; height: 3.7mm; font-size: 4.7pt; }
  .worksheet-footer { padding: 2.4mm 12mm 2.8mm; font-size: 6pt; }
}
