body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 1rem;
  background-color: #f5f7fa;
  color: #222;
}

.banner {
  background-color: #f0f0f0;
  padding: 5px 20px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
  border-radius: 15px;
}

.banner a {
  display: inline-block;
  color: black;
  font-weight: bold;
  font-size: 1.1rem;
  text-decoration: none;
}

.banner a:hover {
  text-decoration: underline;
}

.banner img {
  width: 100%;
  height: auto;
  max-height: 120px; 
}


.container {
  max-width: none;
  width: 99%;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

h1, h2 {
  text-align: center;
  margin: 1.5rem 0;
  font-size: 2.4rem;
  color: #b30000;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 0 auto 2rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(0,0,0,0.05);
}

form section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

form section legend {
  font-weight: bold;
  font-size: 1.1rem;
}

form label {
  font-weight: 600;
  font-size: 1rem;
}

form select,
form input[type="checkbox"],
form input[type="number"] {
  font-size: 1rem;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  max-width: 250px;
  width: 100%;
}

.vaalityyppivalinnat {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  padding-top: 0.5rem;
}

.vaalityyppivalinnat label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.vaalityyppivalinnat input[type="checkbox"] {
  width: 1.2em;
  height: 1.2em;
  accent-color: #0077cc;
  cursor: pointer;
}

.ika-valinta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

input[name="minika"],
input[name="maxika"],
.ika-valinta input[type="number"],
section input[type="number"] {
  width: 100%;
  max-width: 80px;
  padding: 0.4rem;
  font-size: 1rem;
  text-align: center;
}

@media (max-width: 600px) {
  form section {
    flex-direction: column;
  }

  section:has(input[name="minika"]),
  section:has(input[name="maxika"]) {
    flex-direction: column;
    align-items: stretch;
  }

  section input[type="number"] {
    width: 100%;
  }

  .sivuotsikko h1 {
    font-size: 1.8rem;
  }

  .huomautus {
    font-size: 1.4rem;
  }
}

table, .lomaketaulukko {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background: #fff;
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: 0 0 8px rgba(0,0,0,0.05);
}

th, td {
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  font-size: 0.95rem;
  vertical-align: middle;
}

th {
  background-color: #f0f0f0;
  font-weight: bold;
  text-align: left;
}

.lomaketaulukko th,
.lomaketaulukko td {
  border: none;
}

@media (max-width: 768px) {
  table, .lomaketaulukko, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    display: none;
  }

  td {
    padding-left: 50%;
    text-align: right;
    position: relative;
  }

  td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    font-weight: bold;
    white-space: nowrap;
    text-align: left;
  }
}

.kirjainvalikko {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px 0;
}

.kirjainvalikko .kirjain {
  padding: 6px 10px;
  border-radius: 15px;
  background-color: #eee;
  text-decoration: none;
  color: #333;
  font-weight: bold;
  border: 1px solid #ccc;
  transition: all 0.2s ease-in-out;
}

.kirjainvalikko .kirjain:hover {
  background-color: white;
  color: #000;
}

.kirjainvalikko .valittu {
  background-color: #cc0000;
  color: #fff;
  border-color: #cc0000;
}

.huomautus {
  text-align: center;
  font-size: 1.2rem;
  font-style: italic;
  color: #444;
  margin: 2rem auto;
  padding: 1rem;
  max-width: 600px;
}

.sivuotsikko {
  max-width: 800px;
  margin: 2rem auto;
  padding: 1rem 1.5rem;
  text-align: center;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sivuotsikko .reset-link {
  font-size: 1rem;
  background-color: #e60000;
  color: white;
  padding: 8px 16px;
  border-radius: 30px;
  text-decoration: none;
  transition: background-color 0.3s ease, transform 0.2s ease;
  display: inline-block;
  margin-top: 0.5rem;
}

.sivuotsikko .reset-link:hover {
  background-color: #990000;
  transform: scale(1.04);
}

#chart,
#ehdokasChart {
  display: block;
  width: 100% !important;
  max-width: 900px;
  margin: 2rem auto;
  border-radius: 8px;
}

#chart {
  min-height: 450px;
  background: rgba(200,0,0,0.07);
  border: 1px dashed red;
}

#ehdokasChart {
  min-height: 400px;
  background: rgba(0, 150, 0, 0.06);
  border: 1px dashed #4caf50;
}

/* Pakollinen kenttätyyli */
.pakollinen select {
  border: 2px solid #cc0000;
  background-color: #fff5f5;
  color: #cc0000;
  font-weight: bold;
}

tr.pakollinen td {
  background-color: #fff5f5;
}

.kenttahuomautus {
  color: #cc0000;
  font-size: 0.9rem;
  margin-left: 0.5rem;
}
