/* Root variables for better scaling */
:root {
  --primary-color: #1976d2;
  --secondary-color: #2196f3;
  --text-color: #333;
  --background-start: #87ceeb;
  --background-end: #f0f8ff;
  --border-radius: 8px;
  --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial,
    sans-serif;
  overflow-x: hidden;
  position: relative;
  background: linear-gradient(
    to bottom,
    var(--background-start),
    var(--background-end)
  );
  transition: background 1s linear;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(20px, 5vw, 40px) clamp(10px, 3vw, 20px);
}

/* ---- Responsive Table Design (No Containers) ---- */
.marks-table {
  border-collapse: collapse;
  width: 100%;
  max-width: min(95vw, 600px);
  background-color: white;
  box-shadow: var(--shadow);
  margin-bottom: clamp(20px, 5vw, 40px);
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: clamp(12px, 2.5vw, 16px);
}

table {
  border-collapse: collapse;
  width: 100%;
  max-width: min(95vw, 600px);
  background-color: white;
  box-shadow: var(--shadow);
  margin-bottom: clamp(20px, 5vw, 40px);
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: clamp(12px, 2.5vw, 16px);
}

th,
td {
  border: 1px solid #ccc;
  padding: clamp(6px, 2vw, 12px);
  text-align: center;
  vertical-align: middle;
  word-wrap: break-word;
  hyphens: auto;
}

/* Enhanced input styling */
input[type="text"] {
  width: 100%;
  min-width: 60px;
  padding: clamp(4px, 1.5vw, 8px);
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: max(16px, 1rem);
  transition: all 0.2s ease;
  background-color: white;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
  transform: scale(1.02);
}

th {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: clamp(13px, 2.8vw, 17px);
}

tr:nth-child(even) td {
  background-color: #f9f9f9;
}

/* Responsive Typography */
h1 {
  text-align: center;
  color: #2b3e50;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  line-height: 1.2;
  margin: clamp(10px, 3vw, 20px) 0;
  padding: 0 clamp(10px, 3vw, 20px);
}

h2 {
  text-align: center;
  color: var(--text-color);
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  line-height: 1.3;
  margin: clamp(15px, 4vw, 25px) 0;
  padding: 0 clamp(10px, 3vw, 20px);
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  padding: 10px;
  width: 100%;
  max-width: 100%;
}

.exam {
  background-color: white;
  border: 2px solid #2196f3;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  padding: clamp(14px, 3.5vw, 20px);
  margin: 8px 0;
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 500;
  color: #333;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.25s ease;
  cursor: pointer;
  text-align: center;
  position: relative;
  display: block;       /* acts like your topic box */
  text-decoration: none;
}

.exam:hover {
  background-color: #e3f2fd;
  transform: translateY(-2px);
}

.exam a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
  pointer-events: auto;
}


.topic {
  background-color: white;
  border: 2px solid #2196f3;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  padding: clamp(14px, 3.5vw, 20px);
  margin: 8px 0;
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 500;
  color: #333;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.25s ease;
  cursor: pointer;
  text-align: center;
  position: relative;
}

.topic:hover {
  background-color: #e3f2fd;
  transform: translateY(-2px);
}

/* Mobile: Subtopics appear below */
.subtopics {
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin-top: 10px;
  width: 100%;
  display: none;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.subtopics ul {
  list-style-type: disc;
  margin: 0;
  padding-left: 20px;
}

.subtopics ol {
  margin: 10px 0;
  padding-left: 25px;
}

.subtopics li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  color: #333;
  line-height: 1.6;
  text-align: left;
}

.subtopics li:last-child {
  border-bottom: none;
}

/* Android-specific optimizations */
@supports (-webkit-appearance: none) {
  .topic {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Large phones and small tablets */
@media screen and (min-width: 414px) and (max-width: 768px) {
  .container {
    max-width: 95vw;
  }

  .topic {
    max-width: 85vw;
  }

  table {
    font-size: 15px;
  }

  th,
  td {
    padding: 8px 6px;
  }
}

/* Tablet landscape and small desktop */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 0 30px;
    max-width: 85vw;
  }

  .topic {
    max-width: 450px;
    font-size: 18px;
  }

  .subtopics {
    width: 320px;
    left: calc(100% + 25px);
  }

  table {
    max-width: 700px;
    font-size: 16px;
  }
}

/* Mobile devices */
@media screen and (max-width: 768px) {
  section {
    padding: clamp(15px, 4vw, 25px) clamp(5px, 2vw, 15px);
  }

  .topic {
    max-width: none;
    margin: 0 5px;
  }

  .subtopics {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 400px);
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 2000;
    -webkit-overflow-scrolling: touch;
    border-radius: 15px;
  }

  .subtopics::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
  }

  /* Make table more compact on mobile */
  table {
    font-size: 14px;
  }

  th,
  td {
    padding: 6px 4px;
  }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
  .subtopics li {
    font-size: 14px;
    padding: 8px;
  }

  input[type="text"] {
    min-width: 50px;
    font-size: 16px;
  }

  table {
    font-size: 13px;
  }

  th,
  td {
    padding: 5px 3px;
  }
}

/* Very small devices */
@media screen and (max-width: 360px) {
  h1 {
    font-size: 1.3rem;
  }

  h2 {
    font-size: 1.1rem;
  }

  .topic {
    font-size: 14px;
    padding: 10px;
    min-height: 50px;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 4px 2px;
  }

  input[type="text"] {
    font-size: 16px;
    padding: 4px;
    min-width: 45px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .topic,
  .subtopics {
    border-width: 0.5px;
  }
}

/* Large desktop screens */
@media screen and (min-width: 1200px) {
  section {
    padding: clamp(40px, 8vw, 80px) 20px;
  }

  .container {
    max-width: 1000px;
  }

  .topic {
    max-width: 500px;
  }

  .subtopics {
    width: 350px;
    left: calc(100% + 35px);
  }

  table {
    max-width: 800px;
  }
}

/* Ultra-wide screens */
@media screen and (min-width: 1600px) {
  .container {
    max-width: 1200px;
  }

  section {
    padding: 100px 40px;
  }

  table {
    max-width: 900px;
  }
}

/* Landscape orientation adjustments */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .subtopics {
    max-height: 60vh;
    width: min(70vw, 350px);
  }

  h1 {
    font-size: 1.2rem;
    margin: 10px 0;
  }

  h2 {
    font-size: 1rem;
    margin: 8px 0;
  }

  .topic {
    padding: 8px 15px;
    min-height: 40px;
  }

  table {
    margin-bottom: 15px;
  }
}

/* Make download button bigger and touch-friendly */
.download-btn {
  font-size: 20px;
  text-decoration: none;
  padding: 12px 18px;
  background-color: #4caf50;
  color: white;
  border-radius: 5px;
  display: inline-block;
  margin: 20px 0;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.image-gallery img {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}