:root {
  color-scheme: light;
  --background: #f3f6fa;
  --surface: #ffffff;
  --text: #182638;
  --muted: #526276;
  --primary: #205ac8;
  --primary-dark: #17469d;
  --border: #dce3ec;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

button,
input {
  font: inherit;
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--primary-dark);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #bc6900;
  outline-offset: 4px;
}

.container {
  width: min(100% - 32px, 960px);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--surface);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  padding: 22px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-name {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.04em;
}

.site-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.intro {
  padding: 48px 0 24px;
  max-width: 700px;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  letter-spacing: -0.055em;
}

h2 {
  margin: 0 0 20px;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  letter-spacing: -0.025em;
}

h3 {
  margin: 30px 0 14px;
  font-size: 1.1rem;
}

.intro p {
  color: var(--muted);
  font-size: 1.1rem;
}

.card {
  margin-bottom: 24px;
  padding: clamp(20px, 4vw, 36px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 5px 22px rgb(24 38 56 / 3%);
  scroll-margin-top: 20px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  font-weight: 700;
}

#numero-ohje {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.number-inputs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.number-inputs label {
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.number-inputs input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 66px;
  margin-top: 6px;
  padding: 4px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 750;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.number-inputs input::-webkit-inner-spin-button,
.number-inputs input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.number-inputs input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

button:hover:not(:disabled),
.button:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

button:disabled {
  background: #e6ebf2;
  color: #59687a;
  cursor: not-allowed;
}

button[type="reset"] {
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}

button[type="reset"]:hover {
  background: var(--background);
  color: var(--text);
}

#lataustila,
#aineiston-tiivistelma,
#viimeisin-tila {
  color: var(--muted);
  font-size: 0.9rem;
}

#lomakevirhe {
  padding: 12px 16px;
  border: 1px solid #efc2c2;
  border-radius: 10px;
  background: #fff3f3;
  color: #9d2424;
}

#tulosyhteenveto {
  font-size: 1.25rem;
  font-weight: 700;
}

#tarkistettu-rivi {
  display: inline-block;
  font-weight: 750;
}

#osumayhteenveto {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 24px;
  max-width: 420px;
  margin: 24px 0;
}

#osumayhteenveto dt,
#osumayhteenveto dd {
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

#osumayhteenveto dd {
  font-weight: 750;
  text-align: right;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

caption {
  padding-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--background);
  font-size: 0.85rem;
}

tbody tr:hover {
  background: #f7faff;
}

.lotto-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.lotto-numbers li {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 750;
}

.ad-slot {
  margin: 24px 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.ad-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

#tietoa p {
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer {
  margin-top: 40px;
  padding: 28px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 540px) {
  .intro {
    padding-top: 32px;
  }

  .number-inputs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .number-inputs input {
    height: 60px;
  }

  .form-actions button,
  #arvo-rivi,
  #arvo-uusi-rivi {
    width: 100%;
  }

  th,
  td {
    padding: 12px 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  /* Lisänumero: valkoinen pallo ja sininen reunus */
#viimeisin-lisanumero {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  margin-left: 8px;
  border: 2px solid #2563eb;
  border-radius: 50%;
  background: #ffffff;
  color: #2563eb;
  font-size: 1.15rem;
  font-weight: 750;
  line-height: 1;
  vertical-align: middle;
}
}
