:root {
  --orange: #FF5A1F;
  --orange-d: #D9430E;
  --night: #0E1A2B;
  --night-2: #16233A;
  --night-3: #22324D;
  --ice: #9FE3FF;
  --ice-d: #5BB6E0;
  --snow: #F4F7FA;
  --mute: #8DA2BD;
  --gold: #FFC93C;
  --head: "Bungee", Impact, sans-serif;
  --body: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--night);
  color: var(--snow);
  font: 500 18px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
body::before {
  /* hienovarainen lumihiutalekuvio taustalla */
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1.5px), radial-gradient(rgba(159,227,255,.05) 1px, transparent 1.5px);
  background-size: 46px 46px, 73px 73px;
  background-position: 0 0, 20px 30px;
  pointer-events: none;
  z-index: 0;
}
[hidden] { display: none !important; }
#view-menu, #view-game { position: relative; z-index: 1; }
a { color: var(--ice); }
h1, h2, h3 { font-family: var(--head); font-weight: 400; margin: 0; line-height: 1.02; letter-spacing: .01em; }
kbd {
  display: inline-block;
  font: 600 .78em/1 var(--body);
  padding: .3em .5em;
  border: 1px solid rgba(159,227,255,.35);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: rgba(159,227,255,.08);
  color: var(--ice);
  white-space: nowrap;
}

/* ---------- napit ---------- */
.btn {
  font: 400 16px/1 var(--head);
  letter-spacing: .02em;
  border: 0;
  border-radius: 10px;
  padding: 15px 22px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 5px 0 var(--orange-d); }
.btn-primary:hover { background: #ff6c35; }
.btn-primary:active { box-shadow: 0 2px 0 var(--orange-d); }
.btn-primary kbd { background: rgba(0,0,0,.18); border-color: rgba(255,255,255,.35); color: #fff; }
.btn-ghost { background: transparent; color: var(--ice); box-shadow: inset 0 0 0 2px rgba(159,227,255,.4); }
.btn-ghost:hover { box-shadow: inset 0 0 0 2px var(--ice); }
.btn-big { font-size: 20px; padding: 18px 28px; }
.btn-small { font-size: 13px; padding: 10px 14px; }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: rgba(159,227,255,.1);
  color: var(--ice);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: rgba(159,227,255,.2); }
.mute .snd-off { display: none; }
.mute.is-muted .snd-off { display: block; }
.mute.is-muted .snd-on { display: none; }

/* ---------- ylätunniste ---------- */
.top {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--snow); }
.brand .word { font: 400 24px/1 var(--head); text-transform: uppercase; }
.brand .sticker {
  font: 700 14px/1 var(--body);
  text-transform: uppercase;
  letter-spacing: .14em;
  background: var(--orange);
  color: #fff;
  padding: 5px 8px 4px;
  border-radius: 4px;
  transform: rotate(-8deg) translateY(-8px);
}

/* ---------- hero ---------- */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 28px 0;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 20px;
  align-items: center;
}
.kicker { color: var(--orange); font-weight: 700; text-transform: uppercase; letter-spacing: .16em; font-size: 14px; margin: 0 0 18px; }
.hero h1 { font-size: clamp(44px, 6.6vw, 86px); }
.hero h1 em { font-style: normal; color: var(--orange); display: inline-block; transform: rotate(-2deg); }
.lead { font-size: 20px; color: #C9D6E6; max-width: 34em; margin: 26px 0 30px; }
.cta-row { display: flex; gap: 14px; flex-wrap: wrap; }
.daily-info { color: var(--mute); font-size: 16px; margin-top: 18px; }
.daily-info strong { color: var(--gold); }
.hero-art { margin-right: -60px; margin-bottom: -90px; position: relative; z-index: 2; }
.hero-art svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 30px 40px rgba(0,0,0,.35)); }

/* ---------- lajit ---------- */
.events {
  background: var(--snow);
  color: var(--night);
  padding: 120px 28px 90px;
  clip-path: polygon(0 50px, 100% 0, 100% calc(100% - 40px), 0 100%);
}
.events > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.section-title { font-size: clamp(32px, 4vw, 48px); margin-bottom: 30px; text-transform: uppercase; }
.events .section-title { color: var(--night); }
.event-list { list-style: none; padding: 0; display: grid; gap: 22px; }
.event {
  display: grid;
  grid-template-columns: 70px 64px 1fr 180px;
  gap: 22px;
  align-items: start;
  background: #fff;
  border-radius: 16px;
  padding: 26px 26px 24px 18px;
  box-shadow: 0 1px 0 #D6E6F2, 0 18px 40px -26px rgba(14,26,43,.35);
  position: relative;
}
.event:nth-child(even) { margin-left: 7%; margin-right: -2%; }
.event:nth-child(3) { margin-left: 14%; }
.event .num {
  font: 400 54px/1 var(--head);
  color: transparent;
  -webkit-text-stroke: 2px var(--orange);
  margin-top: -4px;
}
.ev-icon {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--night);
  color: var(--ice);
  display: grid; place-items: center;
}
.ev-icon .ico { width: 36px; height: 36px; }
.ev-body h3 { font-size: 26px; margin-bottom: 8px; }
.ev-body h3 a { color: inherit; text-decoration: none; }
.ev-body h3 a:hover { color: var(--orange); }
.ev-body h3 small { font: 600 14px var(--body); color: var(--ice-d); text-transform: uppercase; letter-spacing: .12em; margin-left: 8px; vertical-align: middle; }
.ev-body p { margin: 0 0 12px; color: #3A4A61; }
.keys { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; color: #4B5D77; }
.event .keys kbd { color: var(--night); background: #EAF3FA; border-color: #BFD5E6; }
.ev-side { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; text-align: right; }
.best span { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: #6B7D95; }
.best strong { display: block; font: 400 28px/1.1 var(--head); color: var(--night); }
.best em { font-style: normal; font-size: 14px; color: #6B7D95; }

/* ---------- turnaus & ohjeet ---------- */
.tourney {
  max-width: 1150px;
  margin: 0 auto;
  padding: 90px 28px 60px;
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 60px;
  align-items: start;
}
.card {
  background: var(--night-2);
  border-radius: 18px;
  padding: 34px;
  box-shadow: inset 0 0 0 1px rgba(159,227,255,.12);
  transform: rotate(-1deg);
}
.card p { color: #C9D6E6; }
.players { display: grid; gap: 10px; margin: 22px 0; }
.player-row { display: flex; align-items: center; gap: 10px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--pc, var(--orange)); display: inline-block; flex: none; }
.player-row input {
  flex: 1;
  font: 600 18px var(--body);
  background: var(--night);
  border: 2px solid var(--night-3);
  color: var(--snow);
  padding: 10px 12px;
  border-radius: 8px;
}
.player-row input:focus { outline: none; border-color: var(--pc); }
.tourney-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.howto ol { padding-left: 1.2em; color: #C9D6E6; }
.howto li { margin-bottom: 10px; }
.howto li strong { color: var(--snow); }
.yeti-note {
  margin-top: 26px;
  border-left: 4px solid var(--orange);
  padding: 4px 0 4px 18px;
  color: #C9D6E6;
}
.yeti-note strong { color: var(--orange); display: block; font: 400 18px var(--head); margin-bottom: 4px; }
.foot { text-align: center; color: var(--mute); font-size: 14px; padding: 30px 20px 50px; }

/* ---------- pelinäkymä ---------- */
body.playing { overflow: hidden; }
#view-game {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #060D17;
}
.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.stage canvas { width: 100%; height: 100%; display: block; background: var(--night); }
.hud-buttons { position: absolute; top: 2.4%; right: 1.4%; display: flex; gap: 8px; z-index: 3; left: auto; }
.hud-buttons .icon-btn { background: rgba(14,26,43,.6); width: 38px; height: 38px; }
/* HUD-laatikot ovat oikeassa yläkulmassa joissain lajeissa → napit alakulmaan */
.hud-buttons { top: auto; bottom: 2.4%; }

.overlay {
  /* koko näytön peitto: mahtuu myös matalissa vaakanäkymissä, joissa pelialue on pieni */
  position: fixed;
  inset: 0;
  background: rgba(6,13,23,.66);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 5;
  padding: 14px;
}
.panel {
  background: var(--night-2);
  border-radius: 18px;
  padding: 28px 32px;
  max-width: 620px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 0 0 1px rgba(159,227,255,.14);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translateY(14px) scale(.98); opacity: 0; } }
.panel h2 { font-size: 34px; }
.ov-prog { color: var(--orange); text-transform: uppercase; letter-spacing: .14em; font-size: 13px; font-weight: 700; margin: 0 0 10px; }
.ov-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.ico-big { width: 54px; height: 54px; color: var(--ice); background: var(--night); border-radius: 12px; padding: 8px; flex: none; }
.ov-tag { margin: 4px 0 0; color: var(--ice-d); text-transform: uppercase; letter-spacing: .12em; font-size: 13px; font-weight: 700; }
.ov-player { margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; color: #C9D6E6; }
.ov-desc { color: #C9D6E6; margin: 0 0 14px; }
.panel .keys { color: #C9D6E6; margin-bottom: 6px; }
.ov-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.score-big { font: 400 72px/1 var(--head); color: var(--gold); margin: 10px 0 6px; }
.score-big span { font: 600 18px var(--body); color: var(--mute); margin-left: 10px; text-transform: uppercase; letter-spacing: .1em; }
.quip { font-size: 19px; font-style: italic; color: var(--ice); margin: 4px 0 14px; }
.badge { display: inline-block; background: var(--night-3); color: var(--ice); padding: 5px 10px; border-radius: 6px; font-weight: 700; margin: 0 0 6px; }
.badge-gold { background: var(--gold); color: var(--night); }
.res-lines { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; font-size: 17px; }
.res-lines dt { color: var(--mute); }
.res-lines dd { margin: 0; font-weight: 600; }
.mini-top { margin: 16px 0 0; padding: 12px 0 0 1.4em; border-top: 1px solid var(--night-3); color: var(--mute); font-size: 15px; }
.mini-top li span { color: var(--snow); }
.mini-top li strong { float: right; color: var(--gold); }
.standings { width: 100%; border-collapse: collapse; margin: 18px 0 4px; font-size: 17px; }
.standings th, .standings td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--night-3); }
.standings th:nth-child(2), .standings td:nth-child(2) { text-align: left; }
.standings td:nth-child(2) { display: flex; align-items: center; gap: 8px; }
.standings th .ico { width: 20px; height: 20px; color: var(--ice); }
.medal { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--night-3); font-weight: 700; }
.medal.gold { background: var(--gold); color: var(--night); }
.medal.silver { background: #C8D3E0; color: var(--night); }
.medal.bronze { background: #D08A4E; color: var(--night); }
.share { background: var(--night); border-radius: 10px; padding: 14px; white-space: pre-wrap; font: 500 16px/1.5 var(--body); color: var(--ice); margin-top: 14px; }

/* ---------- kosketusohjaimet ---------- */
.touch { display: none; }
.rotate-hint {
  display: none;
  align-items: center;
  gap: 10px;
  color: var(--mute);
  font-size: 15px;
  margin: 18px 18px 0;
}
.rotate-hint svg { width: 26px; height: 26px; color: var(--ice); flex: none; }
.kbd-space { width: 18px; height: 12px; vertical-align: -1px; }
@media (pointer: coarse) {
  #view-game { justify-content: flex-start; }
  .touch {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    gap: 20px;
    flex: 1;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  .touch button {
    touch-action: none;
    border: 0;
    border-radius: 14px;
    background: var(--night-2);
    color: var(--ice);
    box-shadow: inset 0 0 0 2px rgba(159,227,255,.25);
  }
  .touch button.on { background: var(--night-3); color: #fff; }
  .touch svg { width: 30px; height: 30px; }
  .pad { display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(2, 56px); gap: 8px; }
  .pad [data-key="up"] { grid-column: 2; grid-row: 1; }
  .pad [data-key="left"] { grid-column: 1; grid-row: 2; }
  .pad [data-key="down"] { grid-column: 2; grid-row: 2; }
  .pad [data-key="right"] { grid-column: 3; grid-row: 2; }
  .touch .act { width: 120px; height: 120px; border-radius: 50%; background: var(--orange); color: #fff; font: 400 18px var(--head); box-shadow: 0 6px 0 var(--orange-d); }
  .touch .act.on { background: var(--orange-d); }
  .stage { width: 100vw; }
}
@media (pointer: coarse) and (orientation: landscape) {
  /* kolme palstaa: nuolet | peli | hyppy — ohjaimet eivät peitä pelialuetta */
  #view-game { flex-direction: row; justify-content: center; align-items: center; gap: 0; }
  .stage { width: min(calc(100vw - 300px), calc(100dvh * 16 / 9)); order: 2; }
  .touch { display: contents; }
  .pad { order: 1; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 48px); gap: 6px; margin: 0 6px; touch-action: none; }
  .touch .act { order: 3; width: 104px; height: 104px; margin: 0 20px; flex: none; touch-action: none; }
  .rotate-hint { display: none; }
}
@media (pointer: coarse) and (orientation: portrait) {
  .rotate-hint { display: flex; }
}

@media (max-height: 520px) {
  .panel { padding: 16px 20px; border-radius: 14px; }
  .panel h2 { font-size: 24px; }
  .ico-big { width: 40px; height: 40px; padding: 6px; }
  .ov-head { margin-bottom: 6px; }
  .ov-desc, .quip { font-size: 15px; margin-bottom: 8px; }
  .score-big { font-size: 44px; }
  .ov-actions { margin-top: 12px; }
  .res-lines { font-size: 15px; }
  .mini-top { display: none; }
}
@media (pointer: coarse) {
  .hud-buttons .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
  .hud-buttons .icon-btn svg { width: 16px; height: 16px; }
}

/* ---------- responsiivisuus ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { margin: 0 -20px -70px; max-width: 520px; justify-self: center; }
  .event { grid-template-columns: 54px 1fr; gap: 14px; padding: 20px; }
  .event .num { font-size: 40px; }
  .ev-icon { grid-row: 1; grid-column: 2; justify-self: end; width: 52px; height: 52px; }
  .ev-icon .ico { width: 30px; height: 30px; }
  .ev-body, .ev-side { grid-column: 1 / -1; }
  .ev-side { flex-direction: row; justify-content: space-between; align-items: center; text-align: left; }
  .event:nth-child(n) { margin: 0; }
  .tourney { grid-template-columns: 1fr; gap: 40px; }
  .card { transform: none; }
}
@media (max-width: 560px) {
  body { font-size: 17px; }
  .top { padding: 16px 18px; }
  .brand .word { font-size: 19px; }
  .hero { padding: 14px 18px 0; }
  .events { padding: 90px 16px 70px; }
  .panel { padding: 20px; }
  .score-big { font-size: 54px; }
  .standings { font-size: 14px; }
  .standings th .ico { width: 16px; height: 16px; }
}
