* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Tahoma, Verdana, "DejaVu Sans", Arial, sans-serif;
  color: #2d3640;
  background: linear-gradient(180deg, #5d6b7d 0%, #8f9cad 22%, #c3ccd7 55%, #dfe5ec 100%) fixed;
  min-height: 100vh;
}
[hidden] { display: none !important; }

.screen {
  max-width: 1000px; margin: 0 auto; padding: 14px 16px 10px;
  min-height: 100vh; display: flex; flex-direction: column;
}

.panel {
  background: linear-gradient(180deg, #f4f6f8 0%, #e4e8ed 100%);
  border: 1px solid #c3cad3; border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.label { font-size: 15px; color: #2d3640; }

/* top */
.top { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.who, .timer { width: 40%; min-width: 0; padding: 7px 10px 9px; }
.who .label { margin-bottom: 6px; }
.namebox {
  background: #fff; border: 1px solid #a9b2bd; border-radius: 2px;
  font-size: 11px; text-transform: uppercase; padding: 3px 6px; min-height: 20px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.timer-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.time { font-weight: bold; font-size: 22px; letter-spacing: 1px; color: #1f262d; }
.bar { height: 16px; background: #fff; border: 1px solid #a9b2bd; border-radius: 2px; padding: 2px; }
.bar-fill {
  height: 100%; width: 100%;
  background: repeating-linear-gradient(90deg, #8693a3 0 4px, transparent 4px 6px);
  border-radius: 1px; transition: width .5s linear;
}

main { flex: 1; }

/* start */
.start { max-width: 460px; margin: 60px auto 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.start input {
  font: inherit; font-size: 15px; padding: 6px 8px; border: 1px solid #a9b2bd; border-radius: 2px; background: #fff;
}
.start .btn { align-self: flex-end; }
/* parse progress badge */
.prog {
  position: fixed; right: 12px; bottom: 12px; z-index: 10; max-width: calc(100% - 24px);
  background: rgba(244,246,248,.96); border: 1px solid #a9b2bd; border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); padding: 6px 10px; font-size: 12px; color: #2d3640;
}
.prog-bar { height: 4px; margin-top: 5px; background: #d3d9e0; border-radius: 2px; overflow: hidden; }
body.has-prog .screen { padding-bottom: 56px; }
#progFill { height: 100%; width: 0; background: #5f7190; }
.msg { font-size: 13px; color: #8a2e2e; min-height: 1em; }

/* exam */
.exam { padding: 10px 14px 14px; }
.qhead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.qtext { flex: 1; text-align: center; font-weight: bold; font-size: 14px; line-height: 1.35; padding-top: 4px; }
.qnum {
  flex: none; min-width: 40px; height: 24px; line-height: 24px; text-align: center;
  background: linear-gradient(180deg, #8193b0, #5f7190); color: #fff; font-size: 12px;
  border-radius: 3px; border: 1px solid #52627d; margin-top: 4px;
}
.qbody { display: flex; gap: 16px; align-items: flex-start; }
.qimg {
  flex: 0 0 42%; background: #fff; border: 1px solid #c3cad3; border-radius: 3px; padding: 6px;
  display: flex; justify-content: center; align-items: center;
}
.qimg img { max-width: 100%; max-height: 340px; display: block; }
.answers { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ans { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.ans input { position: absolute; opacity: 0; pointer-events: none; }
.radio {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 4px solid #7a8697; background: #eef1f4; box-shadow: inset 0 1px 2px rgba(0,0,0,.25);
}
.ans input:checked + .radio { background: radial-gradient(circle, #2f3a47 0 4px, #eef1f4 5px); border-color: #56657a; }
.ans input:focus-visible + .radio { outline: 2px solid #5f7190; outline-offset: 2px; }
.ans-text {
  flex: 1; background: #fbfcfd; border: 1px solid #c9d0d8; border-radius: 3px;
  font-size: 12px; line-height: 1.35; padding: 5px 8px; min-height: 26px;
}
.ans:hover .ans-text { background: #fff; border-color: #a9b2bd; }
.ans input:checked ~ .ans-text { background: #fff; border-color: #7a8697; }
.actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.btn {
  font: inherit; font-size: 12px; font-weight: bold; color: #fff;
  background: linear-gradient(180deg, #8a939e 0%, #5f6873 100%);
  border: 1px solid #4f5761; border-radius: 4px; padding: 6px 28px; min-width: 180px;
  box-shadow: 0 1px 2px rgba(0,0,0,.3); cursor: pointer;
}
.btn:hover:not(:disabled) { background: linear-gradient(180deg, #98a1ac, #69727d); }
.btn:disabled { opacity: .55; cursor: default; }

/* result */
.result { text-align: center; padding-top: 10vh; }
.review { text-align: left; margin-top: 36px; display: flex; flex-direction: column; gap: 12px; }
.rv { padding: 10px 14px 14px; scroll-margin-top: 12px; }
.rv.rv-bad { border: 2px solid #b8423c; box-shadow: 0 0 0 1px rgba(184,66,60,.25), 0 1px 3px rgba(0,0,0,.25); }
.rv .qimg img { max-height: 260px; }
.rv.rv-bad .qnum { background: linear-gradient(180deg, #e07a72, #b53a33); border-color: #8c2a26; }
.rv.rv-ok .qnum { background: linear-gradient(180deg, #8cca5c, #4f9a2e); border-color: #3f7d24; }
.rv-ans { display: flex; align-items: center; gap: 10px; }
.rv-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #b5bec9; background: #eef1f4;
  font-size: 13px; font-weight: bold; line-height: 18px; text-align: center; color: #fff; }
.rv-ans.correct .ans-text { background: #e3f3d8; border-color: #6aae45; }
.rv-ans.correct .rv-mark { background: #5da33a; border-color: #3f7d24; }
.rv-ans.chosen.ok .ans-text { font-weight: bold; }
.rv-ans.chosen.bad .ans-text { background: #f8dedc; border-color: #b8423c; font-weight: bold; }
.rv-ans.chosen.bad .rv-mark { background: #b8423c; border-color: #8c2a26; }
.rv-none { color: #b8423c; font-weight: bold; font-size: 13px; padding-left: 32px; }
.score { font-size: 40px; color: #5da33a; letter-spacing: 1px; }
.result.failed .score { color: #b8423c; }
.verdict { font-size: 18px; margin: 10px 0 22px; color: #4a8a2b; }
.result.failed .verdict { color: #b8423c; }

/* bottom squares */
.nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 14px 0 4px; }
.sq {
  width: 32px; height: 32px; padding: 0; font: inherit; font-size: 14px; line-height: 30px; text-align: center;
  color: #3c4650; border: 1px solid #8f9aa7; border-radius: 3px;
  background: linear-gradient(180deg, #f3f5f7, #cfd6de); cursor: pointer;
}
.sq:disabled { cursor: default; }
.sq.cur { border-color: #3e4d63; box-shadow: 0 0 0 1px #3e4d63; background: linear-gradient(180deg, #fff, #dbe2ea); font-weight: bold; }
.sq.ok { color: #fff; border-color: #3f7d24; background: linear-gradient(180deg, #8cca5c, #4f9a2e); }
.sq.bad { color: #fff; border-color: #8c2a26; background: linear-gradient(180deg, #e07a72, #b53a33); }

@media (max-width: 640px) {
  .screen { padding: 10px 16px; }
  .top { flex-direction: column; gap: 8px; margin-bottom: 10px; }
  .who, .timer { width: 100%; }
  .qbody { flex-direction: column; }
  .qimg { flex: none; width: 100%; }
  .actions .btn { width: 100%; }
  .start { margin-top: 24px; }
  .score { font-size: 28px; }
  .result { padding-top: 4vh; }
  .review { margin-top: 24px; }
  .rv { padding: 8px 10px 12px; }
  body.has-prog .screen { padding-bottom: 64px; }
  .prog { left: 8px; right: 8px; bottom: 8px; max-width: none; }
  .sq { width: 30px; height: 30px; line-height: 28px; font-size: 13px; }
}
