:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --accent: #2563eb;
  --correct: #166534;
  --wrong: #991b1b;
  --shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.control-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.control-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

select,
button {
  font: inherit;
}

select {
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin-top: 0;
}

.practice-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.net-panel h3,
.question-panel h3 {
  margin: 0 0 10px;
}

.net-host {
  min-height: clamp(180px, 30vh, 300px);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
  background: #fbfcff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.net-grid {
  display: grid;
  gap: 6px;
  align-content: center;
  justify-content: center;
}

.net-cell {
  border: 2px solid #111827;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.pattern-svg {
  width: 72%;
  height: 72%;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.option-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  padding: 8px;
  display: grid;
  gap: 8px;
  justify-items: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.option-card:hover {
  transform: translateY(-1px);
  border-color: #9ca3af;
}

.option-card.selected {
  border-color: var(--accent);
}

.option-card.correct {
  border-color: var(--correct);
  background: #eefaf1;
}

.option-card.wrong {
  border-color: var(--wrong);
  background: #fff1f2;
}

.option-label {
  font-weight: 700;
  width: 100%;
  text-align: left;
}

.cube-svg {
  width: 100%;
  height: auto;
  max-width: 150px;
}

.cube-svg.compact {
  max-width: 120px;
}

.button-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.top-actions {
  margin-top: 0;
  justify-content: flex-end;
}
.question-actions {
  margin-top: 8px;
  justify-content: flex-start;
}

button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 7px 11px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #9ca3af;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.feedback {
  min-height: 1.5em;
  margin: 8px 0 0;
  font-weight: 600;
}

.feedback.correct {
  color: var(--correct);
}

.feedback.wrong {
  color: var(--wrong);
}

.feedback.neutral {
  color: var(--text);
}

.explanation {
  margin-top: 8px;
  border-left: 4px solid var(--accent);
  background: #eff6ff;
  padding: 8px;
  border-radius: 8px;
  line-height: 1.35;
}
.explanation-overview {
  margin: 0 0 8px;
}
.explanation-heading {
  margin: 0 0 6px;
  font-weight: 700;
}
.explanation-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.explanation-item.correct {
  color: var(--correct);
}
.explanation-item.wrong {
  color: var(--wrong);
}

.hidden {
  display: none !important;
}


@media (max-width: 920px) {
  .options-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .net-host {
    min-height: clamp(150px, 22vh, 220px);
  }
}

@media (max-width: 640px) {
  .app {
    padding: 12px 10px 20px;
  }

  .control-bar {
    margin-top: 12px;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .control-left {
    justify-content: space-between;
  }

  .control-bar select {
    width: min(62vw, 240px);
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .panel {
    margin-top: 12px;
    padding: 10px;
  }

  .panel h2 {
    margin-bottom: 10px;
  }

  .net-panel h3,
  .question-panel h3 {
    margin-bottom: 8px;
  }

  .net-host {
    min-height: clamp(130px, 18vh, 180px);
    padding: 8px;
  }

  .options-grid {
    gap: 8px;
  }

  .option-card {
    padding: 6px;
    gap: 6px;
  }

  .cube-svg {
    max-width: 120px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .app-header,
  .control-bar,
  .question-panel {
    display: none !important;
  }

  .panel {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }
}
