:root {
  --bg-dark: #0d0f1a;
  --bg-panel: #1a1d33;
  --text: #e0e8ff;
  --muted: #a0a8c8;
  --accent-blue: #6fa8ff;
  --accent-pink: #ff7ac2;
  --accent-green: #6fe3a2;
  --accent-red: #ff6f6f;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --gradient: linear-gradient(45deg, var(--accent-blue), var(--accent-pink));
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  font-family: "Lexend", sans-serif;
  background: radial-gradient(circle at top, #1e2245, var(--bg-dark) 70%);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}
.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid #303560;
}
.title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.limit-badge,
.game-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-blue);
  line-height: 1;
  text-shadow: 0 0 6px #1a1d33;
}
.rule-text {
  font-size: 14px;
  color: var(--accent-pink);
  font-weight: 700;
  max-width: 460px;
}
.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 85px);
}
.left-panel {
  background: #000;
  border-radius: 16px;
  border: 1px solid #303560;
  box-shadow: var(--shadow);
  padding: 0;
  position: relative;
  overflow: hidden;
}
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.question-area {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.question-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.meta-item .label {
  font-size: 12px;
  color: var(--muted);
}
.meta-item .value {
  font-size: 24px;
  font-weight: 700;
  font-family: "Space Mono";
}
.question-card {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}
.question-card.hidden {
  display: none;
}
.question-card h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}
.choices {
  display: grid;
  gap: 10px;
}
.choice-btn {
  background: #2a2d4a;
  border: 1px solid #4a4f80;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  text-align: left;
  font-family: "Space Mono";
  font-size: 14px;
  cursor: pointer;
  position: relative;
}
.choice-btn.selected {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 2px var(--accent-green) inset;
}
.answer-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.answer-input {
  flex: 1 1 160px;
  position: relative;
}
.answer-input input {
  width: 100%;
  background: #0d0f1a;
  border: 1px solid #4a4f80;
  color: var(--text);
  padding: 12px 10px;
  border-radius: 10px;
  font-family: "Space Mono";
  font-size: 18px;
  text-align: center;
}
.answer-input .mark {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 18px;
}
.hint-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hint-panel.hidden {
  display: none;
}
#hintsUsed {
  font-size: 12px;
  color: var(--muted);
  min-height: 34px;
}
.feedback {
  min-height: 28px;
  font-size: 14px;
}
.actions-row {
  margin-top: auto;
  display: flex;
  gap: 12px;
}
button.primary {
  flex: 1;
  background: var(--gradient);
  border: none;
  color: #fff;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-shadow: 0 1px 3px #0005;
  transition: transform 0.2s;
}
button.primary:hover {
  transform: scale(1.02);
}
button.small {
  background: #262a47;
  border: 1px solid #4a4f80;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
button.small:hover {
  background: #303560;
}
.explain {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.5;
  height: 220px;
  overflow: auto;
}
.note {
  margin-bottom: 10px;
}
.progress-log {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
  overflow: auto;
}
.worksheet-summary {
  background: var(--bg-panel);
  border: 1px solid #303560;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.hidden {
  display: none;
}
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: #0d0f1acc;
  backdrop-filter: blur(8px);
  z-index: 100;
}
.overlay.visible {
  display: grid;
}
.card {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 24px;
  width: min(440px, 90vw);
  text-align: center;
  box-shadow: var(--shadow);
}
.card h2 {
  margin-top: 0;
}
.card label {
  display: block;
  text-align: left;
  margin-bottom: 12px;
  font-size: 14px;
}
.card input {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  border-radius: 10px;
  background: #0d0f1a;
  border: 1px solid #4a4f80;
  color: var(--text);
  font-family: "Space Mono";
}
.small-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: -4px;
  margin-bottom: 12px;
}
/* Marks */
.mark.correct {
  color: var(--accent-green);
}
.mark.incorrect {
  color: var(--accent-red);
}
/* Celebration */
#confettiCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.celebrate {
  position: relative;
}
@keyframes popIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.celebrate {
  animation: popIn 0.6s ease;
}
/* Responsive */
@media (max-width: 780px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .right-panel {
    order: -1;
  }
  .limit-badge,
  .game-title {
    font-size: 26px;
  }
}
