*{ box-sizing:border-box; }
body{
  margin:0;
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:28px;
  color:var(--text);
  font-family: ui-rounded, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 10% 20%, var(--bg-accent-a), transparent 55%),
    radial-gradient(900px 700px at 90% 10%, var(--bg-accent-b), transparent 60%),
    radial-gradient(900px 700px at 80% 90%, var(--bg-accent-c), transparent 55%),
    linear-gradient(135deg, var(--bg1), var(--bg2) 35%, var(--bg3) 100%);
  overflow-x:hidden;
}

.wrap{ width:min(920px, 100%); display:flex; flex-direction:column; gap:14px; }

header{
  display:flex; flex-wrap:wrap; gap:10px 14px;
  align-items:baseline; justify-content:space-between;
  padding:6px 4px;
}
.title{ display:flex; flex-direction:column; gap:4px; }
.title-main{
  display:flex;
  align-items:center;
  gap:8px;
}
.title h1{ margin:0; font-size: clamp(20px, 3vw, 28px); letter-spacing:.2px; }
.title .subtitle{ margin:0; color:var(--muted); font-size:14px; line-height:1.25; }
.theme-reference-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:26px;
  height:26px;
  border-radius:999px;
  text-decoration:none;
  font-size:15px;
  line-height:1;
  color:var(--text);
  background: var(--pill-bg);
  border:1px solid var(--pill-border);
  transition: transform .08s ease, filter .15s ease;
}
.theme-reference-link:hover{
  filter: brightness(1.08);
}
.theme-reference-link:focus-visible{
  outline:2px solid var(--ok-border);
  outline-offset:2px;
}
.theme-reference-link:active{
  transform: translateY(1px);
}

.topRight{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end;
  margin-left:auto;
}

.scorechip{
  padding:10px 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  box-shadow: var(--chip-shadow);
  font-weight: 650;
  display:flex; align-items:center; gap:10px;
  user-select:none;
  white-space:nowrap;
  margin-left:auto;
}
.scorechip .dot{
  width:10px;height:10px;border-radius:50%;
  background: var(--score-dot-bg);
  box-shadow: 0 0 0 6px var(--score-dot-shadow);
  flex:0 0 auto;
}

.modeToggle{
  display:flex; gap:6px;
  padding:6px;
  border-radius: 999px;
  background: var(--mode-bg);
  border: 1px solid var(--mode-border);
  box-shadow: var(--mode-shadow);
  user-select:none;
}
.modeToggle button{
  border:0;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
  letter-spacing:.2px;
  background: transparent;
  color: var(--mode-text);
  cursor:pointer;
  transition: background .15s ease, transform .08s ease, color .15s ease;
  min-width: 130px;
}
.modeToggle button.active{
  background: var(--mode-active-bg);
  color: var(--mode-active-text);
  box-shadow: inset 0 1px 0 var(--mode-active-shadow);
}
.modeToggle button:active{ transform: translateY(1px); }

#gameBox{
  position:relative;
  padding: 22px 22px 18px;
  border-radius: 22px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height: 360px;
}
#gameBox::before{
  content:"";
  position:absolute;
  inset:-2px;
  background: var(--gamebox-overlay);
  pointer-events:none;
  opacity:.9;
}

.panel{ position:relative; z-index:1; display:flex; flex-direction:column; gap:14px; animation: popIn .22s ease-out; }
@keyframes popIn{ from{ transform: translateY(6px) scale(.99); opacity:0; } to{ transform: translateY(0) scale(1); opacity:1; } }

.kicker{ display:flex; align-items:center; justify-content:space-between; gap:12px; color:var(--muted); font-size:13px; letter-spacing:.2px; }
.pill{ padding:6px 10px; border-radius:999px; background: var(--pill-bg); border:1px solid var(--pill-border); white-space:nowrap; }

.question{ font-size: clamp(18px, 2.6vw, 22px); line-height:1.25; font-weight: 800; letter-spacing:.2px; margin:0; text-shadow: var(--question-shadow); }
.hint{ margin:0; color: var(--muted); font-size: 14px; line-height: 1.4; }

.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:stretch; }

.data-entry-fields{
  display:grid;
  gap:10px;
}
.data-entry-field{
  display:flex;
  align-items:center;
  gap:10px;
}
.data-entry-field.data-entry-field-multiline{
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.data-entry-field label{
  font-size:13px;
  font-weight:700;
  color:var(--muted);
  min-width:140px;
  flex:0 0 140px;
}
.data-entry-field.data-entry-field-multiline label{
  min-width: 0;
  flex: 0 0 auto;
}
.data-entry-field input{
  width:100%;
  flex:1 1 auto;
}
.data-entry-error{
  color:var(--error);
  font-weight:700;
}

@media (max-width: 700px){
  .data-entry-field{
    flex-direction:column;
    align-items:stretch;
    gap:6px;
  }
  .data-entry-field label{
    min-width:0;
    flex:0 0 auto;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

input[type="text"]{
  flex: 1 1 260px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  outline:none;
  font-size: 15px;
  box-shadow: inset 0 1px 0 var(--input-inner-shadow);
}
input[type="text"]::placeholder{ color: var(--input-placeholder); }
textarea[data-entry-field]{
  flex: 1 1 260px;
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  font-size: 15px;
  box-shadow: inset 0 1px 0 var(--input-inner-shadow);
  resize: vertical;
  font-family: inherit;
}
textarea[data-entry-field]::placeholder{ color: var(--input-placeholder); }

button.primary{
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--text);
  font-weight: 900;
  letter-spacing:.2px;
  cursor:pointer;
  transition: transform .08s ease, filter .2s ease;
  user-select:none;
  min-width: 160px;
}
button.primary:hover{ filter: brightness(1.08); }
button.primary:active{ transform: translateY(1px); }
button.primary:disabled{ opacity:.55; cursor:not-allowed; filter:saturate(.6); }

.choices{ display:flex; flex-direction:column; gap:10px; margin-top: 6px; }
.choices.layout-horizontal{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:10px;
}
.choice{
  display:flex; gap:10px; align-items:flex-start;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--choice-border);
  background: var(--choice-bg);
  cursor:pointer;
  transition: transform .06s ease, filter .15s ease, background .15s ease;
  user-select:none;
  position:relative;
}
.choice:hover{ filter: brightness(1.06); }
.choice:active{ transform: translateY(1px); }
.choice input[type="radio"]{
  position:absolute;
  opacity:0;
  width:0;
  height:0;
  pointer-events:none;
}
.choice.selected{
  border-color: var(--ok-border);
  box-shadow: inset 0 0 0 2px var(--ok-border);
  background: var(--feedback-bg);
}
.choice.selected.selected-animate{
  animation: choiceSelectEmphasis .34s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes choiceSelectEmphasis{
  0%{
    transform: scale(1);
    box-shadow: inset 0 0 0 2px var(--ok-border), 0 0 0 0 rgba(90,255,170,.0);
  }
  45%{
    transform: scale(1.03);
    box-shadow: inset 0 0 0 2px var(--ok-border), 0 0 0 8px rgba(90,255,170,.18);
  }
  100%{
    transform: scale(1);
    box-shadow: inset 0 0 0 2px var(--ok-border), 0 0 0 0 rgba(90,255,170,.0);
  }
}
.choice .label{ font-weight: 800; letter-spacing:.2px; line-height: 1.2; }
.choice-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:auto;
  height:auto;
  margin-right:8px;
  font-size: 18px;
  vertical-align: middle;
}
.choice-icon img{
  width:22px;
  height:22px;
  object-fit: contain;
  border-radius: 4px;
}
.choice-icon-text{
  width:auto;
  min-width:0;
  padding:0;
  font-size:11px;
  font-weight:700;
}
.choices.layout-horizontal .choice{
  align-items:center;
  justify-content:center;
  aspect-ratio: 1 / 1;
  min-height: 180px;
}
.choices.layout-horizontal .choice > div{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  width:100%;
  height:100%;
}
.choices.layout-horizontal .choice .choice-icon{
  margin-right:0;
  margin-bottom:8px;
  font-size: 54px;
  line-height: 1;
}
.choices.layout-horizontal .choice .choice-icon img{
  width:66px;
  height:66px;
}
.choices.layout-horizontal .choice .label{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
  text-align:center;
}

@media (max-width: 700px){
  .choices.layout-horizontal{
    grid-template-columns: 1fr;
  }
}
.choice .small{ display:block; color: var(--muted); font-weight: 650; font-size: 12px; margin-top: 2px; }

.feedback{
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--feedback-border);
  background: var(--feedback-bg);
  display:flex; flex-direction:column; gap:8px;
}
.feedback .line{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; font-weight: 900; }
.badge{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--badge-border);
  background: var(--badge-bg);
  font-size: 13px;
  letter-spacing:.2px;
  font-weight: 900;
}
.badge.ok{ border-color: var(--ok-border); color: var(--ok); }
.badge.no{ border-color: var(--no-border); color: var(--no); }

.funfact-wrap{
  margin-top: 4px;
}
.funfact-title{
  margin: 0 0 6px 0;
  color: var(--text);
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 900;
  line-height: 1.2;
}
.funfact-text{
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 2.1vw, 20px);
  line-height: 1.45;
}

.result{
  min-height: 320px;
  display:flex; align-items:center; justify-content:center;
  text-align:center; padding: 18px;
}
.result .big{
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.0;
  margin:0;
  font-weight: 950;
  letter-spacing:.2px;
  text-shadow: var(--result-big-shadow);
}
.result .small{ margin: 14px 0 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.result .score{
  margin-top: 10px;
  font-size: 18px;
  font-weight: 950;
  letter-spacing:.3px;
  padding: 10px 14px;
  display:inline-block;
  border-radius: 999px;
  border: 1px solid var(--result-score-border);
  background: var(--result-score-bg);
}

.confetti{ position:absolute; inset:0; pointer-events:none; opacity:0; z-index:3; overflow:hidden; }
.confetti.on{ opacity:1; }
.confetti i{
  position:absolute;
  width:8px;height:8px;border-radius:2px;
  transform: translateY(-20px) rotate(0deg);
  animation: fall 1.1s ease-in forwards;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.25));
  opacity: .95;
}
@keyframes fall{ to{ transform: translateY(420px) rotate(260deg); opacity:0; } }

footer{
  color: var(--footer-text);
  font-size: 12px;
  padding: 0 4px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.load-error{
  margin: 8px 4px 2px;
  color: var(--error);
  font-weight: 800;
  font-size: 13px;
}

.points-float-toast{
  position: fixed;
  transform: translate(-50%, -50%) translateY(0) scale(0.9);
  opacity: 0;
  color: #24d06f;
  font-weight: 900;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  text-shadow: 0 6px 18px rgba(0,0,0,.28);
  pointer-events: none;
  z-index: 9999;
  transition: transform .7s cubic-bezier(0.2, 0.8, 0.2, 1), opacity .7s ease;
}
.points-float-toast.animate{
  opacity: 1;
  transform: translate(-50%, -50%) translateY(-110px) scale(1.03);
}

@media (max-width: 900px){
  body{
    min-height: 100dvh;
    align-items: flex-start;
    padding: 16px;
  }
  .wrap{
    width: 100%;
    gap: 12px;
  }
  header{
    align-items: stretch;
    gap: 10px;
    padding: 0;
  }
  .title{
    width: 100%;
  }
  .topRight{
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .modeToggle{
    flex: 1 1 auto;
    min-width: 0;
  }
  .modeToggle button{
    min-width: 0;
    flex: 1 1 0;
    padding: 10px 10px;
  }
  .scorechip{
    margin-left: 0;
  }
  #gameBox{
    min-height: 300px;
    padding: 16px 14px 14px;
    border-radius: 16px;
  }
  .panel{
    gap: 12px;
  }
  .kicker{
    flex-wrap: wrap;
    gap: 8px;
  }
  .pill{
    white-space: normal;
  }
  .question{
    font-size: clamp(18px, 5vw, 22px);
  }
  .row{
    gap: 8px;
  }
  button.primary{
    min-height: 44px;
  }
  .result{
    min-height: 260px;
    padding: 10px;
  }
  .points-float-toast{
    font-size: clamp(24px, 7vw, 36px);
  }
}

@media (max-width: 560px){
  body{
    padding: 10px;
  }
  .title h1{
    font-size: clamp(18px, 6vw, 24px);
  }
  .title .subtitle{
    font-size: 13px;
  }
  .topRight{
    flex-direction: column;
    align-items: stretch;
  }
  .modeToggle{
    width: 100%;
  }
  .scorechip{
    width: 100%;
    justify-content: center;
  }
  #gameBox{
    padding: 14px 12px 12px;
    min-height: 260px;
  }
  input[type="text"]{
    font-size: 16px;
    min-height: 44px;
  }
  button.primary{
    width: 100%;
  }
  .data-entry-fields{
    gap: 8px;
  }
  .data-entry-field{
    gap: 4px;
  }
  .data-entry-field label{
    min-width: 0;
    flex: 0 0 auto;
    font-size: 12px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .data-entry-field input{
    min-height: 36px;
    max-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
    line-height: 1.2;
  }
  .data-entry-field textarea[data-entry-field]{
    min-height: 90px;
    padding-top: 8px;
    padding-bottom: 8px;
    line-height: 1.3;
  }
  .choice{
    padding: 12px;
  }
  .choices.layout-horizontal .choice{
    aspect-ratio: unset;
    min-height: 120px;
    border-radius: 14px;
  }
  .choices.layout-horizontal .choice .choice-icon{
    font-size: 44px;
  }
  .choices.layout-horizontal .choice .choice-icon img{
    width: 54px;
    height: 54px;
  }
  .funfact-title{
    font-size: clamp(18px, 5vw, 22px);
  }
  .funfact-text{
    font-size: clamp(15px, 4.2vw, 18px);
  }
  footer{
    font-size: 11px;
    gap: 6px;
  }
}
