#korttipaja {
  --kortin-muste: #294a41;
  --kortin-reuna: #b88960;
  width: min(844px, calc(100dvw - 24px));
  position: fixed;
  inset-inline: auto;
  top: 50dvh;
  bottom: auto;
  left: 50dvw;
  translate: -50% -50%;
  margin: 0;
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0;
  border-radius: 19px;
  border: 2px solid var(--kortin-reuna);
  overscroll-behavior: contain;
}
.korttipaja-otsake {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 19px 5px 22px;
}
#korttipaja h2 { margin: 0; color: var(--kortin-muste); }
#kortti-sulje {
  font-size: 1.55rem;
  line-height: 1;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
}
.korttipaja-tyo {
  display: grid;
  grid-template-columns: 1.14fr 1fr;
  align-items: center;
  gap: clamp(14px, 2.7vw, 34px);
  padding: 9px 22px 23px;
}
.korttipaja-kuva {
  display: grid;
  place-items: center;
  padding: 10px;
  min-width: 0;
  min-height: 280px;
  margin: 0;
  background: #f1dfc580;
  border: 1px solid #d4b692;
  border-radius: 12px;
}
#kortti-esikatselu {
  display: none;
  height: auto;
  width: auto;
  max-width: 100%;
  max-height: min(59dvh, 566px);
  border-radius: 5px;
  box-shadow: 0 4px 14px #5737233f;
}
#kortti-esikatselu[data-valmis] { display: block; }
.korttipaja-saadot {
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
}
.korttipaja-muodot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 0; }
.korttipaja-muodot label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #b39577;
  color: #4f3b30;
  background: #fffbf2;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 680;
}
.korttipaja-muodot label:has(:checked) {
  color: white;
  border-color: #35574c;
  background: #35574c;
}
.korttipaja-muodot label:has(:focus-visible) { outline: 3px solid #126c99; outline-offset: 2px; }
.korttipaja-muodot i {
  display: block;
  width: 12px;
  aspect-ratio: 4 / 5;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}
.korttipaja-muodot input[value="tarina"] + i { width: 9px; aspect-ratio: 9 / 16; }
.korttipaja-muodot input[value="nelio"] + i { aspect-ratio: 1; }
.korttipaja-saadot label > span { min-width: 0; }
.korttipaja-kentta {
  display: grid;
  align-content: start;
  gap: 3px;
  font-size: .82rem;
  font-weight: 690;
  color: var(--kortin-muste);
}
.korttipaja-rinta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#korttipaja :is(select, input[type="text"]) {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #aa8971;
  border-radius: 8px;
  color: #392f28;
  background: #fffbf2;
  font: 550 16px/1.2 var(--tekstikirjasin);
}
.korttipaja-valinnainen {
  float: inline-end;
  color: #765c4a;
  font-size: .73rem;
  font-weight: 500;
}
.korttipaja-qr {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: #563f30;
  font-size: .82rem;
  cursor: pointer;
}
#korttipaja input[type="checkbox"] { accent-color: #35574c; margin: 0; padding: 0; width: 18px; height: 18px; min-height: 0; }
.korttipaja-toimi { display: grid; gap: 5px; }
#kortti-laheta { width: 100%; border-radius: 10px; border-color: #83382e; }
#kortti-tila { font-size: .82rem; margin: 0; color: #684036; }
@media (max-width: 620px) {
  #korttipaja { width: min(470px, calc(100dvw - 16px)); max-height: calc(100dvh - 16px); }
  .korttipaja-otsake { padding: 7px 10px 5px 14px; }
  .korttipaja-tyo { display: block; padding: 3px 12px 0; }
  .korttipaja-kuva { min-height: calc(37dvh + 12px); padding: 6px; margin-bottom: 10px; }
  #kortti-esikatselu { max-height: 37dvh; }
  .korttipaja-saadot { display: contents; }
  .korttipaja-saadot > :not(.korttipaja-toimi) { margin-bottom: 7px; }
  .korttipaja-toimi {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--paperi);
    padding: 7px 0 10px;
  }
}
@media (max-width: 620px) and (max-height: 700px) {
  .korttipaja-kuva { min-height: calc(30dvh + 12px); }
  #kortti-esikatselu { max-height: 30dvh; }
}
