* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
}

button,
select,
input {
  font: inherit;
}

button, .abutton {
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: #111827;
  color: #ffffff;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

button:hover, .abutton:hover {
  transform: translateY(-1px);
}

.abutton  {display:inline-block;text-decoration:none;margin-right:10px;}

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

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
}

.subtitle {
  margin: 8px 0 0;
  color: #4b5563;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width:720px;
}

.panel {
  min-width: 0;
}

.card {
  background: #ffffff;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 8px;
}

.ion-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.ion-box {
  border-radius: 18px;
  padding: 16px;
  text-align: center;
}

.cation-box {
  background: #eff6ff;
}

.anion-box {
  background: #fef2f2;
}

.ion-type {
  font-size: 14px;
  color: #6b7280;
}

.ion-formula {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 700;
}

.ion-name {
  margin-top: 8px;
  font-size: 16px;
  color: #4b5563;
}

.ion-separator {
  font-size: 30px;
  font-weight: 700;
  color: #6b7280;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stats-grid.timer-active {
  grid-template-columns: 1fr 1fr 1fr;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

.inputs-line {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.answer-card input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 22px;
  outline: none;
  text-align: center;
}

.answer-card input:focus {
  border-color: #6b7280;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.15);
}

.equation-preview {
  margin-top: 18px;
  border-radius: 18px;
  background: #f9fafb;
  padding: 16px;
}

.assembly-preview {
  font-size: 24px;
  line-height: 1.5;
}

.compound-preview {
  margin-top: 12px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}

.compound-preview sup,
.assembly-preview sup {
  font-size: 0.65em;
}

.compound-preview sub,
.assembly-preview sub {
  font-size: 0.65em;
}

.feedback {
  border-radius: 18px;
  padding: 14px 16px;
  line-height: 1.45;
}

.feedback.success {
  background: #d1fae5;
  color: #065f46;
}

.feedback.error {
  background: #fef3c7;
  color: #92400e;
}

.hidden {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.teacher-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.teacher-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.teacher-actions select {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
}

#timerEnabled {
  width: 18px;
  height: 18px;
}

.info-card h2 {
  margin: 0 0 14px;
  font-size: 28px;
}

.info-card p {
  margin: 0 0 14px;
  line-height: 1.55;
}

.neutrality-rule {
  font-size: 24px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(460px, 100%);
  background: #ffffff;
  border-radius: 24px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.final-message {
  margin: 12px 0 20px;
  font-size: 18px;
  font-weight: 700;
}

#assemblyPreview, #compoundNamePreview {text-align:center;}

@media (max-width: 1100px) {
  /*.layout {
    grid-template-columns: 1fr;
  }*/

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    display: flex;
    justify-content: flex-start;
  }
}

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

  .topbar h1 {
    font-size: 24px;
  }

  .ion-pair,
  .stats-grid,
  .stats-grid.timer-active,
  .inputs-line {
    grid-template-columns: 1fr;
  }

  .ion-separator {
    text-align: center;
  }

  .ion-formula {
    font-size: 28px;
  }

  .assembly-preview,
  .compound-preview,
  .neutrality-rule {
    font-size: 20px;
  }
}
