@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Sora:wght@400;500;600&display=swap');

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

:root {
  --accent: #7F77DD;
  --accent-light: #EEEDFE;
  --accent-dark: #3C3489;
  --ok: #1D9E75;
  --ok-light: #E1F5EE;
  --ng: #E24B4A;
  --ng-light: #FCEBEB;
  --font-main: 'Sora', var(--font-sans), sans-serif;
  --font-mono: 'DM Mono', var(--font-mono), monospace;
}

body {
  font-family: var(--font-main);
  color: var(--color-text-primary);
  font-size: 15px;
  line-height: 1.6
}

.screen {
  display: none;
  padding: 1.5rem 0 2rem
}

.screen.active {
  display: block;
  max-width: 80vw;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem
}

.app-logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center
}

.app-logo svg {
  width: 20px;
  height: 20px;
  fill: white
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px
}

.app-sub {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 1px
}

.section {
  margin-bottom: 1.25rem
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 10px
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px
}

@media(max-width:400px) {
  .ops-grid {
    grid-template-columns: repeat(2, 1fr)
  }
}

.op-tile {
  position: relative;
  cursor: pointer
}

.op-tile input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0
}

.op-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1.5px solid var(--color-border-tertiary);
  border-radius: 12px;
  transition: border-color .15s, background .15s
}

.op-tile input:checked+.op-face {
  border-color: var(--accent);
  background: var(--accent-light)
}

.op-sym {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--accent-dark)
}

.op-name {
  font-size: 11px;
  color: var(--color-text-secondary)
}

.op-tile input:checked+.op-face .op-name {
  color: var(--accent-dark)
}

.fields-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px
}

@media(max-width:420px) {
  .fields-row {
    grid-template-columns: 1fr
  }
}

.field-box {
  background: var(--color-background-secondary);
  border-radius: 10px;
  padding: 12px;
  transition: background .15s
}

.field-box:focus-within {
  background: var(--accent-light)
}

.field-box label {
  font-size: 11px;
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: 8px;
  transition: color .15s
}

.field-box:focus-within label {
  color: var(--accent-dark)
}

.field-box input[type=number] {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  text-align: center;
  border: none;
  border-bottom: 2px solid var(--color-border-secondary);
  background: transparent;
  color: var(--color-text-primary);
  outline: none;
  padding-bottom: 4px;
  transition: border-color .15s;
  -moz-appearance: textfield
}

.field-box input[type=number]:focus {
  border-bottom-color: var(--accent)
}

.field-box input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px
}

.mode-tile {
  position: relative;
  cursor: pointer
}

.mode-tile input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0
}

.mode-face {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px solid var(--color-border-tertiary);
  border-radius: 12px;
  transition: border-color .15s, background .15s
}

.mode-tile input:checked+.mode-face {
  border-color: var(--accent);
  background: var(--accent-light)
}

.mode-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-background-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0
}

.mode-tile input:checked+.mode-face .mode-icon {
  background: var(--accent);
  color: white
}

.mode-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--color-text-secondary)
}

.mode-tile input:checked+.mode-face .mode-icon svg {
  fill: white
}

.mode-text strong {
  display: block;
  font-size: 13px;
  font-weight: 500
}

.mode-text span {
  font-size: 11px;
  color: var(--color-text-secondary)
}

.err-msg {
  font-size: 12px;
  color: var(--ng);
  margin-top: 6px;
  min-height: 16px
}

.err-global {
  font-size: 13px;
  color: var(--ng);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ng-light);
  margin-bottom: 12px;
  display: none
}

.err-global.show {
  display: block
}

.start-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: .02em;
  transition: opacity .15s
}

.start-btn:hover {
  opacity: .88
}

.prog-bar-wrap {
  margin-bottom: 1.5rem
}

.prog-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 6px
}

.prog-track {
  height: 4px;
  background: var(--color-background-secondary);
  border-radius: 2px;
  overflow: hidden
}

.prog-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s ease
}

.q-card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem
}

.q-expr {
  font-family: var(--font-mono);
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 500;
  text-align: center;
  padding: 1rem 0;
  letter-spacing: .02em;
  color: var(--color-text-primary)
}

.q-mark {
  color: var(--accent)
}

.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 1rem
}

@media(max-width:360px) {
  .choices-grid {
    grid-template-columns: 1fr
  }
}

.choice-btn {
  padding: 14px 10px;
  border: 1.5px solid var(--color-border-tertiary);
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  width: 100%
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-light)
}

.choice-btn:disabled {
  cursor: not-allowed
}

.choice-btn.correct {
  border-color: var(--ok);
  background: var(--ok-light);
  color: var(--ok)
}

.choice-btn.wrong {
  border-color: var(--ng);
  background: var(--ng-light);
  color: var(--ng)
}

.desc-area {
  margin-top: 1rem
}

.desc-input-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch
}

.desc-input-wrap input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  text-align: center;
  border: 1.5px solid var(--color-border-secondary);
  border-radius: 12px;
  padding: 12px;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color .15s
}

.desc-input-wrap input:focus {
  border-color: var(--accent)
}

.desc-input-wrap input:disabled {
  opacity: .55
}

.submit-btn {
  padding: 12px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap
}

.submit-btn:hover {
  opacity: .85
}

.submit-btn:disabled {
  opacity: .4;
  cursor: not-allowed
}

.verdict-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1.25rem;
  padding: 12px;
  border-radius: 10px
}

.verdict-row.ok {
  background: var(--ok-light)
}

.verdict-row.ng {
  background: var(--ng-light)
}

.verdict-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0
}

.verdict-row.ok .verdict-icon {
  background: var(--ok)
}

.verdict-row.ng .verdict-icon {
  background: var(--ng)
}

.verdict-icon svg {
  width: 11px;
  height: 11px;
  fill: white
}

.verdict-text {
  font-size: 14px;
  font-weight: 500
}

.verdict-row.ok .verdict-text {
  color: var(--ok)
}

.verdict-row.ng .verdict-text {
  color: var(--ng)
}

.ans-reveal {
  text-align: center;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 8px
}

.ans-reveal strong {
  font-family: var(--font-mono);
  color: var(--color-text-primary)
}

.next-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 13px;
  border: 1.5px solid var(--color-border-secondary);
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background .15s, border-color .15s
}

.next-btn:hover {
  background: var(--color-background-secondary);
  border-color: var(--color-border-primary)
}

.result-hero {
  text-align: center;
  padding: 1.5rem 0
}

.result-rate {
  font-family: var(--font-mono);
  font-size: clamp(48px, 12vw, 72px);
  font-weight: 500;
  color: var(--accent);
  line-height: 1
}

.result-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 6px
}

.result-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 1.25rem 0
}

.metric-card {
  background: var(--color-background-secondary);
  border-radius: 12px;
  padding: 1rem;
  text-align: center
}

.metric-num {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500
}

.metric-lbl {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 4px
}

.result-comment {
  font-size: 14px;
  color: var(--color-text-secondary);
  text-align: center;
  margin: 0.75rem 0 1.25rem
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s
}

.btn-primary:hover {
  opacity: .87
}

.btn-secondary {
  width: 100%;
  padding: 13px;
  border: 1.5px solid var(--color-border-secondary);
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 14px;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background .15s
}

.btn-secondary:hover {
  background: var(--color-background-secondary)
}