:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --border: #DEDBD2;
  --text: #2C2C2A;
  --text-secondary: #5F5E5A;
  --accent: #0F6E56;
  --accent-dark: #085041;
  --danger: #A32D2D;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.screen.active { display: flex; }

/* ---- login ---- */

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card h1 { margin: 0 0 4px; font-size: 26px; font-weight: 500; }
.subtitle { color: var(--text-secondary); margin: 0 0 24px; }

.pin-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
  min-height: 56px;
}

.pin-display .pin-box {
  width: 44px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 500;
}

.pin-display .pin-box.filled { border-color: var(--accent); color: var(--accent-dark); }

.login-error {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin: 0 0 16px;
}

/* ---- welcome confirmation ---- */

.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.welcome-card h1 { margin: 0 0 4px; font-size: 26px; font-weight: 500; }

.welcome-name {
  font-size: 22px;
  font-weight: 500;
  color: var(--accent-dark);
  margin: 0 0 28px;
}

.btn-go {
  font-size: 22px;
  padding: 14px 56px;
  border-radius: 12px;
  margin-bottom: 12px;
}

#btn-not-me {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ---- quiz ---- */

.quiz-wrap { width: 100%; max-width: 920px; }

#quiz-setname {
  text-align: center;
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 16px;
  color: var(--text);
}

.quiz-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

#quiz-username { font-weight: 500; white-space: nowrap; }
#quiz-progress { color: var(--text-secondary); font-size: 14px; white-space: nowrap; }

.progress {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.quiz-body {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;   /* both cards grow to the same height */
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  flex: 1 1 400px;
  max-width: 440px;
  display: flex;
  flex-direction: column;
}

#question-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
}

.keyboard-card { display: flex; flex-direction: column; gap: 14px; }

/* The quiz keyboard stretches to fill whatever space remains after the input */
.quiz-keyboard.simple-keyboard { flex: 1; display: flex; flex-direction: column; }

.answer-input {
  font-size: 24px;
  text-align: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

/* ---- end screen ---- */

.end-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 420px;
}

.end-card h1 { margin: 0 0 8px; font-weight: 500; }
.end-card p { font-size: 18px; margin: 0 0 24px; }
.end-card .btn { margin: 0 6px; }

/* ---- simple-keyboard restyle: bigger, friendlier touch targets ---- */

.simple-keyboard.hg-theme-default {
  background: transparent;
  padding: 0;
}

/* Quiz keyboard: rows fill the keyboard height, buttons fill each row.
   Height is set via --quiz-btn-h, calculated in JS from the actual rendered
   card height (flex height propagation alone isn't reliable here). */
.quiz-keyboard .hg-rows {
  display: flex;
  flex-direction: column;
}

.quiz-keyboard .hg-row {
  display: flex;
}

.quiz-keyboard .hg-button {
  height: var(--quiz-btn-h, 80px) !important;
  flex: 1;
  font-size: 20px;
  border-radius: 10px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  box-shadow: none;
}

.simple-keyboard .hg-button {
  height: 56px;
  font-size: 20px;
  border-radius: 10px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  box-shadow: none;
}

.simple-keyboard .hg-button:active,
.simple-keyboard .hg-button.hg-activeButton {
  background: var(--accent);
  color: #fff;
}

.login-keyboard .hg-button { height: 64px; font-size: 22px; }

@media (max-width: 600px) {
  .login-card { padding: 28px 20px; }
  .quiz-card { padding: 12px; }
}
