/* ============ Mindle – vihreä, goottinen, kukkainen ============ */
:root {
  --ink: #0b1610;
  --bg: #0d1a13;
  --bg-2: #12241a;
  --panel: #152a1f;
  --panel-2: #1b3427;
  --line: #2f4d3b;
  --moss: #7fb069;
  --moss-deep: #4f7a43;
  --sage: #a9c79a;
  --cream: #efe6cf;
  --muted: #a8b8a4;
  --gold: #d9c48a;
  --gold-deep: #b08f43;
  --rose: #d98aa0;
  --plum: #6e4a6b;
  --absent: #26372d;
  --radius: 14px;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --gothic: 'UnifrakturMaguntia', 'Cormorant Garamond', serif;
  --sc: 'IM Fell English SC', 'Cormorant Garamond', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%237fb069' stroke-opacity='.07' stroke-width='1.2'%3E%3Cpath d='M10 60c20-20 40 20 60 0s40-20 50 0'/%3E%3Cpath d='M30 50q6-10 14-6q-6 8-14 6zM80 66q8 8 14 2q-8-6-14-2z'/%3E%3C/g%3E%3Cg fill='%23d98aa0' fill-opacity='.07'%3E%3Ccircle cx='60' cy='20' r='3'/%3E%3Ccircle cx='20' cy='100' r='2'/%3E%3C/g%3E%3Cg fill='%23d9c48a' fill-opacity='.08'%3E%3Ccircle cx='100' cy='96' r='1.4'/%3E%3Ccircle cx='96' cy='24' r='1'/%3E%3C/g%3E%3C/svg%3E");
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.45;
  font-variant-numeric: lining-nums;
  overflow-x: hidden;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60vmax 40vmax at 10% -10%, rgba(127,176,105,.16), transparent 60%),
    radial-gradient(50vmax 40vmax at 110% 10%, rgba(110,74,107,.20), transparent 60%),
    radial-gradient(70vmax 50vmax at 50% 120%, rgba(217,138,160,.08), transparent 60%);
}
main, header, footer { position: relative; z-index: 1; }

a { color: var(--gold); }
button { font: inherit; color: inherit; }

/* ---------- Ylätunniste ---------- */
.site-head { display: flex; justify-content: center; padding: 14px 16px 0; }
.brand { text-decoration: none; color: var(--cream); }
.brand-name {
  font-family: var(--gothic);
  font-size: 30px;
  letter-spacing: .02em;
  text-shadow: 0 0 18px rgba(127,176,105,.35);
}
body.is-hub .site-head { display: none; }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 40px; }
.site-foot { text-align: center; color: var(--muted); font-size: 14px; padding: 0 16px 28px; opacity: .7; }

/* ---------- Koristeet ---------- */
.vine { width: 100%; max-width: 360px; height: auto; color: var(--moss-deep); display: block; margin: 0 auto; }
.vine .leaf { fill: var(--moss); opacity: .85; }
.vine .bloom { fill: var(--rose); }
.vine .moon { fill: var(--gold); }
.vine .star { fill: var(--gold); }
.vine.flip { transform: scaleY(-1); }

/* ---------- Etusivu ---------- */
.hero { text-align: center; padding: 26px 0 8px; }
.hero h1 {
  font-family: var(--gothic);
  font-weight: 400;
  font-size: clamp(64px, 18vw, 104px);
  line-height: 1;
  margin: 8px 0 2px;
  background: linear-gradient(180deg, #f3ecd6 0%, #cfe3c1 55%, #7fb069 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 14px rgba(127,176,105,.35));
}
.hero .tagline { font-style: italic; color: var(--sage); margin: 0 0 6px; font-size: 19px; }
.hero .meta { font-family: var(--sc); color: var(--gold); letter-spacing: .06em; font-size: 16px; }
.day-emoji { font-size: 56px; line-height: 1; margin: 14px 0 0; filter: drop-shadow(0 4px 14px rgba(127,176,105,.35)); }
.greeting { margin: 14px 0 4px; font-size: 22px; font-weight: 600; }

.cards { display: grid; gap: 12px; margin: 20px 0; }
.card {
  position: relative;
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  text-decoration: none; color: var(--cream);
  box-shadow: 0 6px 24px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.03);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--moss-deep); }
.card .sigil {
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; font-size: 28px;
  background: radial-gradient(circle at 35% 30%, #284a37, #10201a 70%);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(217,196,138,.08), inset 0 0 12px rgba(0,0,0,.5);
}
.card h3 { margin: 0; font-family: var(--sc); font-weight: 400; font-size: 22px; letter-spacing: .02em; }
.card p { margin: 0; color: var(--muted); font-size: 16px; font-style: italic; }
.card .status { font-family: var(--sc); font-size: 15px; color: var(--muted); text-align: right; white-space: nowrap; }
.card.done { border-color: rgba(127,176,105,.55); }
.card.done .status { color: var(--moss); }
.card.lost .status { color: var(--rose); }

.note {
  margin: 8px 0 0; padding: 18px 18px; text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--gold-deep);
  background: rgba(217,196,138,.06);
  font-size: 21px; font-style: italic;
}
.note.locked { color: var(--muted); font-size: 17px; border-color: var(--line); background: transparent; }
.countdown { text-align: center; color: var(--muted); font-size: 15px; margin-top: 14px; font-family: var(--sc); letter-spacing: .04em; }

/* ---------- Pelien yhteiset osat ---------- */
.game-head { text-align: center; margin: 4px 0 12px; }
.game-head h2 { font-family: var(--gothic); font-weight: 400; font-size: 42px; margin: 0; line-height: 1.1; color: var(--cream); }
.game-head .sub { margin: 2px 0 0; color: var(--sage); font-style: italic; font-size: 17px; }
.back { display: inline-block; margin: 2px 0 6px; color: var(--muted); text-decoration: none; font-family: var(--sc); font-size: 16px; }
.back:hover { color: var(--gold); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 44px;
  border-radius: 999px; border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #2a4a36, #1a3125);
  color: var(--cream); cursor: pointer; font-family: var(--sc); font-size: 17px; letter-spacing: .03em;
  text-decoration: none;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, var(--moss), var(--moss-deep)); color: var(--ink); border-color: #a9d394; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }

.result {
  margin-top: 16px; padding: 18px; border-radius: var(--radius); text-align: center;
  background: linear-gradient(160deg, rgba(127,176,105,.14), rgba(110,74,107,.14));
  border: 1px solid var(--line);
}
.result h3 { margin: 0 0 4px; font-family: var(--gothic); font-weight: 400; font-size: 34px; }
.result p { margin: 4px 0; }
.result .sci { font-style: italic; color: var(--sage); }
.stats-row { display: flex; justify-content: center; gap: 18px; margin-top: 10px; font-family: var(--sc); color: var(--muted); font-size: 15px; }
.stats-row b { display: block; font-size: 24px; color: var(--cream); font-family: var(--serif); }

.practice-badge {
  display: inline-block; margin-top: 6px; padding: 2px 12px; border-radius: 999px;
  border: 1px solid var(--plum); color: var(--rose); font-family: var(--sc); font-size: 14px;
}

/* ---------- Sanapeli ---------- */
.board { display: grid; gap: 6px; justify-content: center; margin: 8px auto 14px; }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.row.shake { animation: shake .4s; }
.tile {
  width: min(15vw, 60px); height: min(15vw, 60px);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: min(8vw, 32px); text-transform: uppercase;
  border: 2px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.15);
  user-select: none;
}
.tile.filled { border-color: var(--sage); animation: pop .1s; }
.tile.correct, .tile.present, .tile.absent { border-color: transparent; animation: flip .5s ease both; }
.tile.correct { background: var(--moss-deep); box-shadow: inset 0 0 0 1px #8fc27a; }
.tile.present { background: var(--gold-deep); }
.tile.absent { background: var(--absent); color: #93a493; }
.tile.win { animation: bounce .5s ease both; }

.keyboard { display: grid; gap: 6px; user-select: none; touch-action: manipulation; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1 1 0; max-width: 44px; height: 54px; padding: 0;
  border: 0; border-radius: 6px; cursor: pointer;
  background: #2b4636; color: var(--cream);
  font-family: var(--serif); font-weight: 700; font-size: 18px;
}
.key.wide { max-width: 68px; flex: 1.6 1 0; font-size: 14px; font-family: var(--sc); font-weight: 400; }
.key.correct { background: var(--moss-deep); }
.key.present { background: var(--gold-deep); }
.key.absent { background: #18241d; color: #6e806f; }

/* ---------- Lajipelit ---------- */
.frame {
  position: relative;
  margin: 0 auto; width: 100%; max-width: 440px; aspect-ratio: 1;
  border-radius: 50% 50% var(--radius) var(--radius) / 34% 34% var(--radius) var(--radius);
  padding: 8px;
  background: linear-gradient(180deg, var(--gold-deep), #5c4a23);
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
}
.frame::before {
  content: ''; position: absolute; inset: -12px -6px auto; height: 44px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 40'%3E%3Cg fill='%237fb069'%3E%3Cpath d='M30 26q12-18 26-6q-12 12-26 6z'/%3E%3Cpath d='M170 26q-12-18-26-6q12 12 26 6z'/%3E%3C/g%3E%3Cg fill='%23d98aa0'%3E%3Ccircle cx='86' cy='14' r='6'/%3E%3Ccircle cx='114' cy='14' r='6'/%3E%3C/g%3E%3Ccircle cx='100' cy='14' r='8' fill='%23e8b3c2'/%3E%3Ccircle cx='100' cy='14' r='3' fill='%23d9c48a'/%3E%3C/svg%3E") center/contain no-repeat;
  z-index: 2;
}
.imgwrap {
  width: 100%; height: 100%; overflow: hidden; background: #0a140f;
  border-radius: inherit;
  display: grid; place-items: center;
}
.imgwrap img { width: 100%; height: 100%; object-fit: cover; transition: filter .8s ease, transform .8s ease; }
.imgwrap .loading { color: var(--muted); font-style: italic; padding: 20px; text-align: center; }

.hints { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.hints li {
  padding: 8px 12px; border-radius: 10px; font-size: 17px;
  background: rgba(217,196,138,.07); border-left: 3px solid var(--gold-deep);
  animation: fadeIn .4s ease;
}
.hints li.empty { background: transparent; border-left-color: var(--line); color: var(--muted); font-style: italic; }

.guessbox { position: relative; margin-top: 14px; }
.guessbox input {
  width: 100%; height: 50px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line);
  background: #0f1d16; color: var(--cream);
  font-family: var(--serif); font-size: 19px;
}
.guessbox input:focus { outline: none; border-color: var(--moss); box-shadow: 0 0 0 3px rgba(127,176,105,.2); }
.sugg {
  position: absolute; left: 0; right: 0; top: 54px; z-index: 5;
  list-style: none; margin: 0; padding: 6px; max-height: 260px; overflow-y: auto;
  background: #12231a; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 30px rgba(0,0,0,.5);
}
.sugg:empty { display: none; }
.sugg li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.sugg li:hover, .sugg li.active { background: var(--panel-2); }
.sugg li small { color: var(--muted); font-style: italic; margin-left: 6px; }

.guesses { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.guess {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding: 8px 12px; border-radius: 10px; background: var(--absent);
  animation: fadeIn .35s ease;
}
.guess .name { font-weight: 700; margin-right: auto; }
.guess.correct { background: var(--moss-deep); }
.chip { font-family: var(--sc); font-size: 13px; padding: 2px 9px; border-radius: 999px; background: rgba(0,0,0,.25); color: var(--muted); }
.chip.yes { background: var(--gold-deep); color: var(--ink); }
.chip.ok { background: #8fc27a; color: var(--ink); }
.counter { text-align: center; color: var(--muted); font-family: var(--sc); font-size: 15px; margin-top: 8px; }

/* ---------- Palapeli ---------- */
.diff { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.diff button { min-width: 64px; }
.diff button.on { border-color: var(--gold); background: linear-gradient(180deg, var(--moss), var(--moss-deep)); color: var(--ink); }
.puzzle-wrap { position: relative; margin: 0 auto; width: 100%; max-width: 480px; }
.puzzle {
  position: relative; width: 100%; aspect-ratio: 1;
  display: grid; gap: 2px; padding: 2px;
  background: var(--gold-deep);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
  touch-action: none; user-select: none;
}
.piece {
  background-color: #0a140f; background-repeat: no-repeat;
  border-radius: 3px; cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
  transition: filter .15s, box-shadow .15s, opacity .15s;
}
.piece.placed { cursor: default; }
.piece.sel { box-shadow: inset 0 0 0 3px var(--rose); filter: brightness(1.15); }
.piece.drag-src { opacity: .35; }
.piece.over { box-shadow: inset 0 0 0 3px var(--gold); }
.puzzle.solved { gap: 0; padding: 0; transition: gap .4s, padding .4s; }
.puzzle.solved .piece { border-radius: 0; box-shadow: none; }
.drag-ghost {
  position: fixed; pointer-events: none; z-index: 50; border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0,0,0,.6), 0 0 0 2px var(--gold);
  background-repeat: no-repeat;
}
.puzzle-info { text-align: center; color: var(--muted); font-family: var(--sc); margin-top: 10px; }

/* ---------- Tietoa ---------- */
.info-link { display: block; width: fit-content; margin: 18px auto 0; color: var(--muted); font-family: var(--sc); font-size: 15px; text-decoration: none; }
.info-link:hover { color: var(--gold); }
.info h3 { font-family: var(--sc); font-weight: 400; color: var(--gold); font-size: 22px; margin: 22px 0 4px; }
.info p { margin: 6px 0; }
.credits details {
  margin: 8px 0; padding: 8px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
}
.credits summary { cursor: pointer; font-family: var(--sc); font-size: 18px; }
.credits ul { margin: 8px 0 4px; padding-left: 18px; font-size: 15px; }
.credits li { margin: 4px 0; overflow-wrap: anywhere; }
.loading-credits { color: var(--muted); font-style: italic; }

/* ---------- Jakoikkuna ---------- */
.share-box {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 16px;
  background: rgba(5, 12, 8, .7);
}
.share-inner {
  width: 100%; max-width: 360px; padding: 18px; text-align: center;
  border-radius: var(--radius); border: 1px solid var(--gold-deep); background: var(--panel);
}
.share-inner p { margin: 0 0 8px; }
.share-inner textarea {
  width: 100%; margin-bottom: 12px; padding: 10px; resize: none;
  border-radius: 10px; border: 1px solid var(--line); background: #0f1d16; color: var(--cream);
  font-family: var(--serif); font-size: 17px;
}

/* ---------- Ilmoitukset & animaatiot ---------- */
#toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -30px); opacity: 0;
  padding: 10px 18px; border-radius: 999px; z-index: 100;
  background: var(--cream); color: var(--ink); font-weight: 600;
  transition: all .25s ease; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.petals { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.petals span { position: absolute; top: -40px; animation: fall linear forwards; }

@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(540deg); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes bounce { 40% { transform: translateY(-10px); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 420px) {
  body { font-size: 17px; }
  .card { grid-template-columns: 48px 1fr; }
  .card .sigil { width: 48px; height: 48px; font-size: 24px; }
  .card .status { grid-column: 2; text-align: left; }
  .key { height: 50px; font-size: 16px; }
  .krow { gap: 4px; }
}
