:root {
  --bg: #f3f8ff;
  --bg-soft: #dbe9fa;
  --card: rgba(255, 255, 255, 0.85);
  --text: #10223a;
  --muted: #425a78;
  --accent: #aa7b12;
  --accent-2: #0f6eb2;
  --success: #1f9c5f;
  --danger: #c63737;
  --border: rgba(16, 34, 58, 0.2);
  --shadow: 0 10px 24px rgba(24, 55, 92, 0.18);
}

* {
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Book Antiqua", Palatino, "Palatino Linotype", serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 20%, rgba(126, 198, 255, 0.25), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(216, 181, 91, 0.2), transparent 30%),
    linear-gradient(145deg, var(--bg), var(--bg-soft));
  min-height: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.container {
  width: min(1120px, 92%);
  margin: 0 auto;
}

.glass {
  background: var(--card);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 12px auto;
  width: min(1160px, 95%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}

.brand img {
  width: 150px;
  height: 50px;
  object-fit: contain;
}

.top-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.top-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  transition: all 0.25s ease;
}

.top-nav a:hover,
.top-nav a.active {
  color: var(--text);
  background: rgba(126, 198, 255, 0.14);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.hero {
  margin-top: 24px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.82rem;
}

h1 {
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  margin: 0.35rem 0;
  line-height: 1.15;
}

.home-title {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.hero-actions,
.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: transform 0.2s ease, background 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(145deg, #d6b15a, #f4df9f);
  color: #12253d;
}

.btn-secondary {
  background: linear-gradient(145deg, #6fbaf5, #b4dcff);
  color: #0d2138;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.hero-card {
  padding: 20px;
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.cards-section {
  margin: 30px auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.card {
  padding: 18px;
  min-width: 0;
}

.link-arrow {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
}

.leaderboard {
  margin: 22px auto 28px;
  padding: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 8px;
}

.test-layout {
  margin-top: 24px;
  display: grid;
  gap: 16px;
  padding-bottom: 22px;
}

.test-toolbar,
.upload-panel,
.test-shell,
.result-card,
.certificate-controls {
  padding: 14px;
}

.test-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.test-shell,
.upload-panel,
.result-card,
.certificate-controls,
.certificate-sheet,
.hero-card,
.leaderboard {
  min-width: 0;
  width: 100%;
}

.home-content-panel {
  width: min(1160px, 95%);
}

.group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.stats-inline {
  font-size: 0.95rem;
}

select,
input,
textarea {
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  max-width: 100%;
}

textarea {
  width: 100%;
  resize: vertical;
}

.text-display {
  height: 260px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  line-height: 1.75;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: clamp(1rem, 1.8vw, 1.14rem);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  scroll-behavior: smooth;
}

.text-display span {
  white-space: pre-wrap;
}

.text-display span.current {
  background: rgba(126, 198, 255, 0.25);
  border-radius: 4px;
}

.text-display span.correct {
  color: var(--success);
}

.text-display span.incorrect {
  color: var(--danger);
}

.text-display span.permanent-error {
  background: rgba(255, 98, 98, 0.2);
  color: var(--danger);
}

.typing-input {
  min-height: 120px;
  width: 100%;
}

.result-card h2,
.upload-panel h1 {
  margin-top: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.hidden {
  display: none;
}

.certificate-page {
  margin-top: 20px;
  display: grid;
  gap: 18px;
}

.control-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px;
  align-items: center;
}

.certificate-sheet {
  background: #fffdf5;
  color: #192335;
  border: 10px solid #ccad62;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.certificate-inner {
  border: 2px solid #d6bf82;
  padding: 28px;
  text-align: center;
}

.cert-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.cert-sub {
  letter-spacing: 2px;
  color: #7f6619;
}

.cert-body {
  font-size: 1.2rem;
  margin: 28px auto;
  max-width: 760px;
  line-height: 1.65;
}

.cert-sign-row {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}

.cert-sign {
  width: 190px;
  max-width: 95%;
}

.muted {
  color: var(--muted);
}

.site-footer {
  text-align: center;
  padding: 24px 0;
  color: var(--muted);
}

.footer-links {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--accent-2);
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a.active {
  text-decoration: underline;
}

.page-content {
  margin: 20px auto 26px;
  padding: 18px;
  line-height: 1.8;
}

.page-content h2,
.page-content h3 {
  margin-top: 14px;
}

.page-content a {
  color: var(--accent-2);
  text-decoration: none;
}

.page-content a:hover {
  text-decoration: underline;
}

.breadcrumb-wrap {
  margin-top: 8px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
  padding: 10px 14px;
}

.breadcrumb a {
  color: var(--accent-2);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}


.reveal-up {
  opacity: 0;
  transform: translateY(14px);
  animation: revealUp 0.65s ease forwards;
}

.delay-1 { animation-delay: 0.12s; }
.delay-2 { animation-delay: 0.24s; }
.delay-3 { animation-delay: 0.36s; }

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .cards-section {
    grid-template-columns: repeat(2, 1fr);
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand img {
    width: 130px;
    height: 44px;
  }

  .top-nav {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .cards-section,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .test-toolbar {
    align-items: flex-start;
  }

  .brand img {
    width: 110px;
    height: 38px;
  }

  .header-inner {
    padding: 10px;
  }

  .test-toolbar,
  .upload-panel,
  .test-shell,
  .result-card,
  .certificate-controls,
  .page-content,
  .certificate-sheet,
  .certificate-inner {
    padding: 12px;
  }

  .cert-body {
    font-size: 1rem;
    margin: 20px auto;
  }

  .site-header {
    position: static;
  }
}

@media print {
  body {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .certificate-sheet {
    border-color: #c09f50;
    box-shadow: none;
    margin: 0;
  }
}
