/* Tumma pöytä, isot peukalonapit. Pystynäyttö 360–430 px. */
:root {
  --tausta: #0b1a12;
  --poyta: #0f5132;
  --poyta-reuna: #0a3a24;
  --teksti: #eef5ef;
  --himmea: #9fb8a8;
  --korostus: #f0c14b;
  --punainen: #c62828;
  --nappi: #1f6f4a;
  --nappi-vaara: #7a2a2a;
  --nappi-toinen: #2a3a33;
  --kortti: #fdfdfb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--tausta); color: var(--teksti); -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom); }
main { max-width: 480px; margin: 0 auto; padding-bottom: 12px; }
h1 { font-size: 1.5rem; margin: 18px 0 8px; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; color: var(--himmea); font-weight: 600; }
button, select, input {
  font: inherit; color: inherit; border-radius: 12px; border: 1px solid #2f4a3c; background: var(--nappi-toinen);
}
button { min-height: 56px; padding: 0 14px; font-weight: 650; font-size: 1.05rem; cursor: pointer; }
button:disabled { opacity: .45; }
button.paa { background: var(--nappi); border-color: #2d8a5f; }
button.vaara { background: var(--nappi-vaara); border-color: #a04040; }
select, input[type="text"] { min-height: 48px; padding: 0 10px; width: 100%; }
label { display: block; color: var(--himmea); font-size: .85rem; margin: 10px 0 4px; }

.yhteys { position: sticky; top: 0; z-index: 10; background: #8a5a00; color: #fff; text-align: center; padding: 8px; font-weight: 600; }
.ilmoitus {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #3a1d1d; border: 1px solid #a04040; padding: 10px 16px; border-radius: 12px; max-width: 90vw; z-index: 20;
}

/* Aula */
.liity { display: grid; gap: 10px; margin-top: 8vh; }
/* Perusta: profiilikortit, välilehdet, listat ja kuvakkeet. */
.profiilikortit { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.profiilikortti { min-height: 130px; display: grid; justify-items: center; align-content: center; gap: 8px; padding: 12px; }
.profiilikortti.valittu { background: var(--nappi); border-color: #2d8a5f; }
.uusi-pelaaja { display: grid; gap: 8px; margin-top: 14px; }
.avatar {
  width: var(--koko); height: var(--koko); border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  overflow: hidden; vertical-align: middle; box-shadow: 0 0 0 1px rgba(255,255,255,.18);
}
.avatar.kuva img { width: 100%; height: 100%; object-fit: cover; }
/* Logot vaalealla pohjalla: tummalla Gemman ohuet viivat katosivat (29.11.2026). */
.avatar.logo { background: #f3f1ea; }
.avatar.logo img { width: 66%; height: 66%; }
.avatar.kirjain { color: #fff; font-weight: 800; font-size: calc(var(--koko) * .5); line-height: 1; }
.paikka .nimi .avatar { margin-right: 5px; }
.paikka .nimi .avatar.logo img { width: 80%; height: 80%; }
.omanimi { display: flex; align-items: center; gap: 7px; }
.valilehdet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 4px; }
.valilehdet button { min-height: 44px; font-size: .95rem; }
.valilehdet button.valittu { background: var(--nappi); border-color: #2d8a5f; }
.takaisin { min-height: 40px; font-size: .9rem; margin: 8px 0; }
.lista { display: grid; gap: 6px; }
.listarivi { display: flex; align-items: center; gap: 10px; text-align: left; min-height: 64px; padding: 8px 12px; font-weight: 400; }
.listarivi .sija { font-weight: 800; width: 26px; }
.listateksti { display: grid; flex: 1; min-width: 0; }
.listateksti .otsikko { font-weight: 700; }
.listateksti .kuvaus { color: var(--himmea); font-size: .85rem; }
.profiilipaa { display: flex; align-items: center; gap: 14px; margin: 6px 0 12px; }
.profiilipaa h1 { margin: 0 0 6px; }
.tilastorivi { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid #22402f; font-size: .92rem; }
.tilastorivi:last-child { border-bottom: none; }
.tilastorivi .kortti { vertical-align: middle; margin-left: 2px; }
.rivinimi { display: flex; align-items: center; gap: 4px; }
.ehdokkaat { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.ehdokas { aspect-ratio: 1; padding: 0; overflow: hidden; border-radius: 12px; display: grid; place-items: center; color: var(--himmea); }
.ehdokas img { width: 100%; height: 100%; object-fit: cover; }
.ehdokas.tyhja { border: 1px dashed #2f4a3c; }
.hahmolomake { display: grid; gap: 8px; }
.hahmolomake textarea { font: inherit; color: inherit; background: var(--nappi-toinen); border: 1px solid #2f4a3c; border-radius: 12px; padding: 10px; }
.sijoitukset .kuvasolu { width: 36px; }
.sijanimi { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kortti-ruutu { background: #12271c; border: 1px solid #22402f; border-radius: 14px; padding: 12px; margin: 10px 0; }
.agentti-rivi { display: grid; gap: 6px; }
.agentti-rivi .otsikko { font-weight: 700; }
.agentti-rivi .kuvaus { color: var(--himmea); font-size: .85rem; }
.kaksi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ihmiset { display: flex; flex-wrap: wrap; gap: 6px; }
.merkki { background: #1b3326; border-radius: 999px; padding: 4px 10px; font-size: .9rem; }
.merkki.pois { opacity: .5; }
.toiminnot { display: grid; gap: 8px; margin-top: 14px; }

/* Pöytä */
.ylapalkki { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--himmea); padding: 8px 2px; gap: 8px; }
.ylapalkki .taso { color: var(--teksti); font-weight: 650; }
.poyta {
  position: relative; background: radial-gradient(ellipse at center, #17704a 0%, var(--poyta) 60%, var(--poyta-reuna) 100%);
  border: 6px solid #3b2a1a; border-radius: 120px / 90px; padding: 14px 8px 18px; display: grid;
  grid-template-columns: 1fr 1fr; grid-template-areas: "yv yo" "v o" "keski keski"; gap: 6px; min-height: 330px;
}
.paikka { position: relative; background: rgba(0,0,0,.28); border-radius: 12px; padding: 6px 8px; border: 2px solid transparent; min-width: 0; }
.paikka.vuorossa { border-color: var(--korostus); box-shadow: 0 0 12px rgba(240,193,75,.5); }
.paikka.luopunut, .paikka.pudonnut { opacity: .45; }
/* Kiinteät korkeudet: sisällön ilmestyminen tai katoaminen ei muuta ruudun kokoa. */
.paikka .ylaosa { display: flex; justify-content: space-between; gap: 6px; height: 56px; }
.paikka .tekstit { min-width: 0; flex: 1; }
.paikka .nimi { font-weight: 700; font-size: .92rem; line-height: 18px; height: 18px; white-space: nowrap; display: flex; align-items: center; }
/* Pitkä nimi katkeaa, jakajan merkki ei: ennen merkki katosi katkaisun mukana. */
.paikka .nimiteksti { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.paikka .tiedot { font-size: .82rem; line-height: 16px; height: 16px; color: var(--himmea); }
.paikka .rivi { font-size: .75rem; line-height: 22px; height: 22px; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.paikka .tila { color: var(--korostus); }
/* Panos pelimerkkinä: kultainen pilleri ja merkin kuva, pompahtaa summan muuttuessa. */
.merkit {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 3px; border-radius: 999px;
  background: linear-gradient(#ffdc6a, #e2a622); color: #2a1c00; font-weight: 800; font-size: .82rem; line-height: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.5); vertical-align: middle;
}
.merkit::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: radial-gradient(circle, #fff 0 22%, #c62828 24% 58%, #fff 60% 72%, #c62828 74%);
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.merkit.iso { font-size: 1.05rem; line-height: 22px; padding: 3px 14px 3px 5px; }
.merkit.iso::before { width: 20px; height: 20px; }
.pompahdus { animation-name: pompahdus; animation-timing-function: cubic-bezier(.3, 1.6, .5, 1); animation-fill-mode: both; }
@keyframes pompahdus { from { transform: scale(.3); opacity: 0; } 55% { transform: scale(1.22); opacity: 1; } to { transform: scale(1); } }
.siirto { font-size: .74rem; font-weight: 650; color: var(--himmea); }
.siirto.korota { color: #ffb74d; }
.siirto.maksa { color: #9fd8ff; }
.siirto.katso { color: #b6e3b6; }
.paikka .pienet { display: flex; gap: 3px; align-items: flex-start; flex: none; width: 55px; height: 36px; margin-top: 2px; }
.nappimerkki { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; margin-left: 5px; border-radius: 50%; background: #fff; color: #000; font-size: .62rem; font-weight: 800; vertical-align: 1px; }
/* Puhekuplalle on varattu kolmen rivin paikka. Pidempi teksti katkeaa tähän, ja koko viesti näkyy chatissa. */
.kuplapaikka { height: 50px; margin-top: 4px; }
.kupla {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
  background: rgba(255, 251, 232, .82); color: #222; border-radius: 9px; padding: 3px 7px;
  font-size: .74rem; line-height: 14.5px; max-height: 50px; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.keski { grid-area: keski; text-align: center; padding-top: 6px; }
.keski .potti { margin-top: 8px; }
.keski .tiedot { min-height: 1.3em; }
.keski .tulos { margin-top: 6px; color: #ffe9a8; font-size: .9rem; line-height: 1.25; min-height: 2.5em; }
.poytakortit { display: flex; justify-content: center; gap: 4px; min-height: 58px; }

.kortti {
  display: inline-grid; place-items: center; width: 40px; height: 56px; border-radius: 6px; background: var(--kortti);
  color: #111; font-weight: 800; font-size: 1.05rem; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,.5); text-align: center;
}
.kortti.punainen { color: var(--punainen); }
.kortti.selka { background: repeating-linear-gradient(45deg, #2c4f8f, #2c4f8f 4px, #24407a 4px, #24407a 8px); }
.kortti.pieni { width: 26px; height: 36px; font-size: .75rem; border-radius: 4px; }
.kortti.iso { width: 58px; height: 80px; font-size: 1.4rem; border-radius: 8px; }

/* Jakoanimaatiot: kortti lentää pakasta (--dx/--dy lasketaan selainkoodissa) ja kääntyy esiin. */
.pakka {
  width: 26px; height: 36px; margin: 0 auto 6px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, #2c4f8f, #2c4f8f 4px, #24407a 4px, #24407a 8px);
  box-shadow: 1px 1px 0 #1b2f5c, 2px 2px 0 #16264a, 3px 3px 0 #111d3a, 0 4px 8px rgba(0,0,0,.5);
}
.korttipino { display: inline-grid; }
.korttipino > * { grid-area: 1 / 1; }
.lento { animation-name: lento; animation-timing-function: cubic-bezier(.2, .7, .3, 1); animation-fill-mode: both; position: relative; z-index: 6; }
.kaanto-pois { animation-name: kaanto-pois; animation-timing-function: ease-in; animation-fill-mode: both; }
.kaanto-esiin { animation-name: kaanto-esiin; animation-timing-function: ease-out; animation-fill-mode: both; }
@keyframes lento {
  from { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(-28deg) scale(.55); opacity: 0; }
  12% { opacity: 1; }
  to { transform: none; opacity: 1; }
}
@keyframes kaanto-pois { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes kaanto-esiin { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.oma { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 2px; }
.oma .nimi { font-weight: 700; }
.oma .tiedot { color: var(--himmea); font-size: .9rem; }
.oma.vuorossa .nimi { color: var(--korostus); }
.omat-kortit { display: flex; gap: 6px; }

.napit { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.korotus { display: grid; gap: 8px; margin-top: 8px; }
.korotus input[type="range"] { width: 100%; height: 36px; }
.pika { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pika button { min-height: 44px; font-size: .9rem; }
.huomio { background: #2b2410; border: 1px solid #6b5a20; border-radius: 12px; padding: 10px; margin: 8px 0; display: grid; gap: 8px; }

/* Pöytäpuhe */
.chat { margin-top: 12px; }
.chat .viestit { max-height: 150px; overflow-y: auto; font-size: .9rem; display: flex; flex-direction: column; gap: 2px; }
.chat .viesti .kuka { font-weight: 700; }
.chat .viesti.hahmo .kuka { color: #9fd8ff; }
.chat form { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 6px; }
.chat form button { min-height: 48px; }

/* Loppu */
.sijoitukset { width: 100%; border-collapse: collapse; }
.sijoitukset td { padding: 8px 4px; border-bottom: 1px solid #22402f; vertical-align: top; }
.sijoitukset .sija { font-weight: 800; font-size: 1.2rem; width: 36px; }
.sijoitukset .lisa { color: var(--himmea); font-size: .85rem; }
.tarina { font-size: 1rem; line-height: 1.45; }
.kortti-ruutu .kuvaus { color: var(--himmea); font-size: .88rem; margin-top: 4px; }
.kortti-ruutu .kuvaus .kortti { vertical-align: middle; margin-right: 2px; }
.sijoitukset .muistio { color: #ffe9a8; font-style: italic; margin-top: 3px; }

/* Laitteet ja kutsut (29.11.2026) */
.pieni-nappi { min-height: 36px; padding: 0 12px; font-size: .85rem; flex: none; }
.tilastorivi:has(.pieni-nappi) { align-items: center; }
.kutsulinkki { display: grid; gap: 8px; margin-top: 10px; }
.kutsulinkki input { font-size: .85rem; }

/* Mielentilat (29.11.2026): merkki nimen alla, välähdys muutoksessa, järjestelmärivi chatissa */
.paikka .mielentila { font-size: .74rem; height: 17px; line-height: 17px; color: #cfe8d8; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-radius: 6px; padding: 0 3px; margin: 1px 0 0 -3px; }
.paikka .mielentila.valahdys { animation: mielentila-valahdys 1.6s ease-out 1 both; }
@keyframes mielentila-valahdys {
  0% { background: #f0c14b; color: #111; transform: scale(1.12); }
  50% { background: rgba(240, 193, 75, .45); color: #fff; transform: scale(1); }
  100% { background: transparent; }
}
.chat .viesti.jarjestelma { color: #a9c4b4; font-style: italic; font-size: .85rem; }
.mielikulku { line-height: 1.5; }
