/* StraightUpSampo — tunturiyö: revontulet, lumi ja havu, karjalainen kirjonta, saamelaiset
   värinauhat (sininen, punainen, keltainen, vihreä). Ei ulkoisia fontteja eikä kuvia. */

:root {
  --night: #070d1c;
  --night-2: #0d1830;
  --glass: rgba(18, 30, 56, 0.62);
  --glass-2: rgba(28, 44, 78, 0.72);
  --line: rgba(160, 200, 255, 0.16);
  --ink: #e8eef8;
  --muted: #95a6c4;
  --snow: #e7eef3;
  --snow-2: #cfdde6;
  --pine: #2d5a5c;
  --pine-2: #234749;
  --aurora-g: #3ff2b0;
  --aurora-v: #8a5cff;
  --aurora-c: #36c5d8;
  --sun: #ffd36e;
  --red: #d7263d;
  --kalevala: #f6f1e7;
  --pohjola: #36c5d8;
  --gakti-blue: #1f4fbf;
  --gakti-red: #c8102e;
  --gakti-yellow: #f2b705;
  --gakti-green: #1b8a4a;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- taivas */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 120%, #10284a 0%, transparent 60%),
    linear-gradient(180deg, #050914 0%, #0a1428 55%, #0d1d36 100%);
  pointer-events: none;
}
.aurora {
  position: absolute;
  width: 90vmax;
  height: 40vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.32;
  mix-blend-mode: screen;
  animation: drift 28s ease-in-out infinite alternate;
}
.a1 { top: -18vmax; left: -20vmax; background: radial-gradient(closest-side, var(--aurora-g), transparent); }
.a2 { top: -10vmax; right: -30vmax; background: radial-gradient(closest-side, var(--aurora-v), transparent); animation-duration: 36s; }
.a3 { top: 6vmax; left: 10vmax; height: 18vmax; background: radial-gradient(closest-side, var(--aurora-c), transparent); opacity: 0.18; animation-duration: 44s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) rotate(-6deg) scaleX(1); }
  50% { transform: translate3d(6vmax, 2vmax, 0) rotate(4deg) scaleX(1.2); }
  100% { transform: translate3d(-4vmax, 4vmax, 0) rotate(-2deg) scaleX(0.9); }
}
.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 22%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 14%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 38% 8%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 36%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 48%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 56% 30%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 70%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 76%, #fff5 50%, transparent 51%);
}
@media (prefers-reduced-motion: reduce) {
  .aurora { animation: none; }
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- yläpalkki */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(5, 10, 22, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; color: var(--aurora-g); filter: drop-shadow(0 0 8px rgba(63, 242, 176, 0.5)); }
.brand-name { font-size: 19px; letter-spacing: 0.02em; color: var(--muted); }
.brand-name b {
  font-weight: 800;
  background: linear-gradient(90deg, var(--aurora-g), var(--aurora-c), var(--aurora-v));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.top-profile { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tp-level {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(var(--aurora-g), var(--aurora-v), var(--aurora-g));
  color: var(--night);
  font-weight: 800;
}
.conn-status { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.conn-status.ok { background: var(--aurora-g); box-shadow: 0 0 8px var(--aurora-g); }
.icon-btn {
  position: relative;
  border: 1px solid var(--line);
  background: var(--glass);
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
.chat-unread {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  font-size: 11px;
  line-height: 18px;
}

/* Karjalainen kirjonta: punainen geometrinen nauha valkoisella, ja saamelaiset raidat sen alla. */
.kirjonta {
  height: 14px;
  background:
    linear-gradient(90deg, var(--gakti-blue) 0 25%, var(--gakti-red) 25% 50%, var(--gakti-yellow) 50% 75%, var(--gakti-green) 75% 100%) bottom / 100% 3px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='11' viewBox='0 0 22 11'%3E%3Crect width='22' height='11' fill='%23f3ece0'/%3E%3Cpath d='M0 11 L5.5 2 L11 11 Z M11 11 L16.5 2 L22 11 Z' fill='%23c8102e'/%3E%3Cpath d='M5.5 6 L8 9 L3 9 Z M16.5 6 L19 9 L14 9 Z' fill='%23f3ece0'/%3E%3C/svg%3E") top / 22px 11px repeat-x;
  opacity: 0.9;
}

main#main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.loading { text-align: center; color: var(--muted); margin-top: 20vh; }

/* ---------------------------------------------------------------- napit ja paneelit */

.btn, .big-btn {
  border: 1px solid var(--line);
  background: var(--glass-2);
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s, box-shadow 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover:not(:disabled), .big-btn:hover:not(:disabled) { transform: translateY(-1px); background: rgba(50, 74, 120, 0.8); }
.btn:disabled, .big-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { border-color: rgba(215, 38, 61, 0.5); }
.btn.danger:hover:not(:disabled) { background: rgba(215, 38, 61, 0.35); }
.big-btn {
  padding: 11px 20px;
  font-weight: 700;
  color: #04121a;
  border: none;
  background: linear-gradient(120deg, var(--aurora-g), var(--aurora-c));
  box-shadow: 0 8px 26px rgba(63, 242, 176, 0.25);
}
.big-btn:hover:not(:disabled) { background: linear-gradient(120deg, #6ff7c6, #5ad7e8); box-shadow: 0 10px 30px rgba(63, 242, 176, 0.35); }

.panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.panel.embroidered::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--gakti-blue) 0 25%, var(--gakti-red) 25% 50%, var(--gakti-yellow) 50% 75%, var(--gakti-green) 75%);
}
.panel h2 { margin: 2px 0 14px; font-size: 17px; letter-spacing: 0.01em; }
.empty-note, .muted { color: var(--muted); }
input[type='text'] {
  background: rgba(5, 12, 26, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
input[type='text']:focus { outline: 2px solid var(--aurora-c); outline-offset: 1px; }

/* ---------------------------------------------------------------- aula */

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  align-items: center;
  gap: 20px;
  padding: 18px 4px 26px;
}
.eyebrow, .stage-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--aurora-g);
  margin: 0 0 6px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(56px, 11vw, 112px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, #fff 10%, var(--aurora-g) 45%, var(--aurora-v) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 30px rgba(63, 242, 176, 0.18));
}
.lead { color: #c6d3ea; font-size: 16px; max-width: 46ch; }
.hero-art { position: relative; height: 210px; }
.hero-piece {
  position: absolute;
  width: 170px;
  height: 170px;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.6));
  animation: float 6s ease-in-out infinite;
}
.hero-piece.a { left: 6%; top: 10px; }
.hero-piece.b { right: 6%; top: 34px; animation-delay: -3s; }
@keyframes float { 50% { transform: translateY(-10px); } }

.lobby-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
.lobby-form { display: flex; gap: 10px; }
.lobby-form input { flex: 1; }
.room-list { list-style: none; margin: 0; padding: 0; }
.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.room-row:first-child { border-top: none; }
.room-name { font-weight: 700; }
.room-seats { color: var(--muted); font-size: 13px; }
.live-tag {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(63, 242, 176, 0.15);
  color: var(--aurora-g);
  font-size: 12px;
}

.profile-head { display: flex; align-items: center; gap: 14px; }
.level-ring {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--aurora-g), var(--aurora-c), var(--aurora-v), var(--aurora-g));
  box-shadow: 0 0 24px rgba(63, 242, 176, 0.3);
}
.level-num {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--night-2);
  font-size: 22px;
  font-weight: 900;
}
.profile-who { flex: 1; min-width: 0; }
.profile-name { font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-title { color: var(--sun); font-size: 13px; }
.elo-big { text-align: right; }
.elo-num { display: block; font-size: 26px; font-weight: 900; }
.elo-lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.15em; }
.xp-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); margin: 16px 0 6px; overflow: hidden; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--aurora-g), var(--aurora-v)); border-radius: 4px; transition: width 0.6s ease; }
.xp-text { color: var(--muted); font-size: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.stat { text-align: center; padding: 8px 2px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.stat b { display: block; font-size: 18px; }
.stat span { color: var(--muted); font-size: 11px; }

.leaderboard { list-style: none; margin: 0; padding: 0; }
.leaderboard li {
  display: grid;
  grid-template-columns: 26px 1fr auto 52px;
  gap: 8px;
  align-items: center;
  padding: 7px 4px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.leaderboard li:first-child { border-top: none; }
.leaderboard li.me { background: rgba(63, 242, 176, 0.08); border-radius: 8px; }
.lb-rank { color: var(--muted); text-align: center; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-title { color: var(--sun); font-size: 12px; }
.lb-elo { text-align: right; font-weight: 800; }

.rules summary { cursor: pointer; font-weight: 700; font-size: 16px; }
.rules-sec h3 { margin: 14px 0 4px; font-size: 14px; color: var(--aurora-g); }
.rules-sec ul { margin: 0; padding-left: 18px; color: #c6d3ea; }
.rules-sec li { margin: 3px 0; }

/* ---------------------------------------------------------------- pöytä */

.room-title { display: flex; align-items: baseline; gap: 12px; }
.room-code { color: var(--muted); font-size: 13px; font-weight: 400; }
.seat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.seat-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.seat-box.side-0 { background: linear-gradient(180deg, rgba(246, 241, 231, 0.09), transparent); }
.seat-box.side-1 { background: linear-gradient(180deg, rgba(54, 197, 216, 0.12), transparent); }
.seat-box.you { border-color: var(--aurora-g); box-shadow: 0 0 0 1px var(--aurora-g) inset; }
.seat-side { text-transform: uppercase; letter-spacing: 0.2em; font-size: 12px; color: var(--muted); }
.seat-art { width: 86px; height: 86px; }
.seat-name { font-weight: 800; }
.seat-sub { color: var(--muted); font-size: 13px; }
.seat-actions { display: flex; gap: 8px; }
.level-badge { font-size: 12px; color: var(--sun); }
.bonus-tag {
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 10px;
  background: rgba(255, 211, 110, 0.15);
  color: var(--sun);
  font-size: 12px;
}
.room-hint { color: var(--muted); font-size: 13px; }
.room-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }

/* ---------------------------------------------------------------- peli */

.game { display: flex; flex-direction: column; gap: 14px; }
.game-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.tide-track { display: flex; gap: 6px; }
.tide {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  opacity: 0.6;
}
.tide.now {
  opacity: 1;
  color: var(--ink);
  border-color: var(--aurora-g);
  box-shadow: 0 0 18px rgba(63, 242, 176, 0.3);
}
.head-info { display: flex; flex-direction: column; font-size: 13px; }
.round { font-weight: 700; }
.tide-hint { color: var(--muted); }
.head-actions { display: flex; gap: 8px; }

.game-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 10px; max-width: 640px; width: 100%; margin: 0 auto; }

.player-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  transition: box-shadow 0.3s, border-color 0.3s;
}
.player-strip.active { border-color: var(--aurora-g); box-shadow: 0 0 22px rgba(63, 242, 176, 0.25); }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-weight: 800;
  flex: none;
}
.avatar.side-0 { background: var(--kalevala); color: var(--gakti-red); }
.avatar.side-1 { background: #1b2233; color: var(--pohjola); border: 1px solid var(--pohjola); }
.ps-who { flex: 1; min-width: 0; }
.ps-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-side { color: var(--muted); font-size: 12px; }
.ps-res { display: flex; gap: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.silver { color: #dfe7f2; font-weight: 700; }
.kantele { color: var(--sun); }
.seita-count { color: var(--aurora-g); }
.offline { color: var(--red); font-size: 12px; }

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
  user-select: none;
}
.sq { position: relative; display: grid; place-items: center; cursor: default; min-width: 0; min-height: 0; }
.sq.snow { background: linear-gradient(145deg, var(--snow), var(--snow-2)); }
.sq.pine { background: linear-gradient(145deg, var(--pine), var(--pine-2)); }
.sq.seita::before {
  content: 'ᛟ';
  position: absolute;
  inset: 12%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: clamp(12px, 3vw, 24px);
  color: rgba(63, 242, 176, 0.75);
  background: radial-gradient(closest-side, rgba(63, 242, 176, 0.32), rgba(63, 242, 176, 0.06) 70%, transparent);
  box-shadow: 0 0 18px rgba(63, 242, 176, 0.35);
  animation: pulse 3.5s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.55; } }
.sq.last { box-shadow: inset 0 0 0 3px rgba(255, 211, 110, 0.65); }
.sq.movable { cursor: pointer; }
.sq.movable:hover { filter: brightness(1.08); }
.sq.selected { box-shadow: inset 0 0 0 4px var(--aurora-g); }
.sq.target { cursor: pointer; }
.sq.target::after {
  content: '';
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(63, 242, 176, 0.75);
  box-shadow: 0 0 10px var(--aurora-g);
  position: absolute;
}
.sq.attack { cursor: pointer; }
.sq.attack::after {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid var(--red);
  box-shadow: 0 0 14px rgba(215, 38, 61, 0.8);
  animation: pulse 1.4s ease-in-out infinite;
}
.coord { position: absolute; font-size: 10px; font-weight: 700; opacity: 0.55; pointer-events: none; }
.coord.rank { top: 3px; left: 4px; }
.coord.file { bottom: 2px; right: 4px; }
.sq.snow .coord { color: var(--pine); }
.sq.pine .coord { color: var(--snow); }

.piece { position: relative; width: 88%; height: 88%; z-index: 1; transition: transform 0.18s; pointer-events: none; }
.piece-svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.45)); }
.sq.movable:hover .piece { transform: translateY(-3px); }
.piece.arrive { animation: arrive 0.9s ease-out; }
@keyframes arrive {
  0% { transform: scale(0.2); opacity: 0; filter: drop-shadow(0 0 20px var(--aurora-g)); }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
.hp { position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; }
.pip { width: 6px; height: 6px; border-radius: 50%; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.4); }
.pip.on { background: var(--aurora-g); border-color: var(--aurora-g); box-shadow: 0 0 4px var(--aurora-g); }

.status-line {
  text-align: center;
  color: #c6d3ea;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(5, 12, 26, 0.45);
}

.side-panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; padding: 11px 6px; cursor: pointer; color: var(--muted); font-weight: 700; }
.tab.on { color: var(--ink); box-shadow: inset 0 -3px 0 var(--aurora-g); }
.tab-body { padding: 14px; max-height: 70vh; overflow: auto; }
.tab-note { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.tab-note.small { font-size: 12px; }
.market-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.market-item { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.price { font-weight: 800; font-size: 13px; }
.price.poor { color: var(--muted); }
.power-name { font-size: 10.5px; color: var(--sun); line-height: 1.2; }
.power-legend { margin-top: 12px; display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.deck-sec { margin-bottom: 16px; }
.deck-title { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.deck-sec .btn { margin-bottom: 8px; }
.deck-cards { display: flex; flex-wrap: wrap; gap: 4px; }
.log { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.log-line { padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); color: #c6d3ea; }

/* ---------------------------------------------------------------- kortit */

.card {
  position: relative;
  width: 58px;
  height: 82px;
  border-radius: 9px;
  background: linear-gradient(160deg, #fbf8f1, #e9e2d4);
  color: #1b2233;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  flex: none;
}
.card.small { width: 36px; height: 50px; border-radius: 6px; }
.card.red { color: var(--gakti-red); }
.card-rank { font-size: 24px; font-weight: 900; line-height: 1; }
.card-suit { font-size: 20px; line-height: 1.1; }
.card.small .card-rank { font-size: 15px; }
.card.small .card-suit { font-size: 12px; }
.card-name { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; }
.card.small .card-name { display: none; }
.card.clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.card.clickable:hover { transform: translateY(-4px); box-shadow: 0 10px 22px rgba(63, 242, 176, 0.35); }
.card.back {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 L15 8 L8 15 L1 8 Z' fill='none' stroke='%233ff2b0' stroke-opacity='.35' stroke-width='1.2'/%3E%3Ccircle cx='8' cy='8' r='1.6' fill='%23ffd36e' fill-opacity='.6'/%3E%3C/svg%3E") center / 16px 16px,
    linear-gradient(160deg, #1d3a6b, #10203d);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.1);
}
.card.slot { background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px dashed var(--line); border: 1px dashed var(--line); }
.card.wild {
  background: radial-gradient(circle at 50% 35%, #fff4c4, var(--sun) 45%, #c98a12);
  color: #3b2400;
  box-shadow: 0 0 18px rgba(255, 211, 110, 0.6);
}
.card.vary.kuu { background: linear-gradient(160deg, #2b3f73, #141f3d); color: #dfe7ff; }
.card.vary.paiva { background: linear-gradient(160deg, #fff2c8, #ffc66e); color: #7a3b00; }
.card.powered { box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(138, 92, 255, 0.75); }
.card-power {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--aurora-v);
  font-size: 12px;
  box-shadow: 0 0 10px rgba(138, 92, 255, 0.7);
}
.card.small .card-power { width: 15px; height: 15px; font-size: 9px; top: -5px; right: -5px; }
.card.trimmable { cursor: pointer; outline: 2px dashed var(--red); outline-offset: 2px; }
.card.hidden-own { transform: translateY(-4px) rotate(-2deg); box-shadow: 0 0 0 2px var(--aurora-c), 0 8px 16px rgba(0, 0, 0, 0.4); }
.card.deal { animation: deal 0.45s ease-out backwards; }
.card.d1 { animation-delay: 0.08s; }
.card.d2 { animation-delay: 0.16s; }
.card.d3 { animation-delay: 0.24s; }
.card.d4 { animation-delay: 0.32s; }
@keyframes deal { from { transform: translateY(-30px) rotate(-8deg); opacity: 0; } }

/* ---------------------------------------------------------------- näyttämöt (sökö, laulukilpa, loppu) */

.stage {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(10, 30, 60, 0.55), rgba(3, 6, 14, 0.82));
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade 0.25s ease-out;
  overflow: auto;
}
@keyframes fade { from { opacity: 0; } }
.stage-card {
  width: min(640px, 100%);
  background: linear-gradient(180deg, rgba(22, 38, 70, 0.95), rgba(10, 18, 36, 0.96));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(63, 242, 176, 0.08);
  position: relative;
  overflow: hidden;
  text-align: center;
}
.stage-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--gakti-blue) 0 25%, var(--gakti-red) 25% 50%, var(--gakti-yellow) 50% 75%, var(--gakti-green) 75%);
}
.stage-card h2 { margin: 4px 0 14px; font-size: 24px; }
.hand {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  margin: 8px 0;
  border: 1px solid transparent;
}
.hand.speaking { border-color: var(--aurora-g); box-shadow: 0 0 20px rgba(63, 242, 176, 0.2); }
.hand.won { border-color: var(--sun); box-shadow: 0 0 22px rgba(255, 211, 110, 0.25); }
.hand-label { display: flex; justify-content: center; gap: 10px; align-items: center; margin-bottom: 8px; font-weight: 700; font-size: 14px; }
.committed { color: var(--sun); font-weight: 400; }
.speaks { color: var(--aurora-g); font-size: 12px; text-transform: uppercase; letter-spacing: 0.15em; }
.hand-name { color: var(--sun); }
.hand-cards { display: flex; justify-content: center; gap: 8px; }
.pot-row { display: flex; justify-content: center; gap: 22px; align-items: center; margin: 4px 0; }
.pot {
  font-size: 20px;
  font-weight: 900;
  padding: 6px 18px;
  border-radius: 20px;
  background: radial-gradient(circle, rgba(255, 211, 110, 0.25), transparent 70%);
  color: var(--sun);
}
.silver-me { color: var(--muted); font-size: 14px; }
.bet-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.bet-actions .btn { min-width: 108px; font-weight: 700; }
.bet-bet, .bet-raise { border-color: var(--sun); }
.bet-call { border-color: var(--aurora-c); }
.bet-fold { border-color: rgba(215, 38, 61, 0.6); }
.waiting { color: var(--muted); animation: pulse 1.6s ease-in-out infinite; }
.ladder { text-align: left; margin-top: 10px; font-size: 13px; }
.ladder summary { cursor: pointer; color: var(--muted); text-align: center; }
.ladder-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin-top: 8px; }
.lh { color: var(--sun); }
.summons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.summon-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px 2px 2px;
  border-radius: 20px;
  background: rgba(63, 242, 176, 0.1);
  font-size: 13px;
  animation: arrive 0.8s ease-out backwards;
}
.summon-chip svg { width: 30px; height: 30px; }
.power-chip { padding: 3px 10px; border-radius: 20px; background: rgba(138, 92, 255, 0.2); font-size: 13px; }

.duel-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.vs { font-size: 26px; font-weight: 900; color: var(--muted); font-style: italic; }
.fighter { padding: 8px; border-radius: 14px; border: 1px solid transparent; }
.fighter.singing { border-color: var(--aurora-g); box-shadow: 0 0 20px rgba(63, 242, 176, 0.2); }
.fighter-art { width: 76px; height: 76px; margin: 0 auto; }
.fighter-name { font-weight: 800; }
.fighter-role { color: var(--muted); font-size: 12px; }
.songs { margin-top: 4px; min-height: 22px; }
.song { color: var(--sun); font-size: 18px; margin: 0 2px; text-shadow: 0 0 8px rgba(255, 211, 110, 0.7); }
.song-notes { color: var(--muted); font-size: 11px; }
.field {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(340px, 84vw);
  margin: 16px auto 8px;
}
.field.small { width: 200px; gap: 5px; }
.stone {
  aspect-ratio: 1;
  border-radius: 38% 42% 36% 44%;
  background: radial-gradient(circle at 35% 30%, #6b7a8f, #3b4658 60%, #262e3c);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.45), 0 6px 14px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  transition: transform 0.15s, box-shadow 0.2s;
}
.stone .rune { font-size: clamp(22px, 7vw, 40px); font-weight: 900; line-height: 1; animation: carve 0.35s ease-out; }
.field.small .stone .rune { font-size: 20px; }
@keyframes carve { from { transform: scale(1.8); opacity: 0; } }
.stone.rune-0 .rune { color: var(--kalevala); text-shadow: 0 0 12px rgba(255, 90, 90, 0.9); }
.stone.rune-1 .rune { color: var(--pohjola); text-shadow: 0 0 12px rgba(54, 197, 216, 0.9); }
.stone.swamp {
  background: radial-gradient(circle at 50% 60%, #3e4b2a, #232b17 70%);
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.7);
  border-radius: 46%;
}
.stone.swamp::after { content: '≈'; color: #7b8d55; font-size: 30px; }
.stone.singable { cursor: pointer; }
.stone.singable:hover { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--aurora-g), 0 10px 22px rgba(63, 242, 176, 0.35); }
.stone.counterable { cursor: pointer; box-shadow: 0 0 0 2px var(--sun), 0 0 18px rgba(255, 211, 110, 0.5); }
.stone.line { box-shadow: 0 0 0 3px var(--sun), 0 0 26px rgba(255, 211, 110, 0.8); }
.duel-hint { color: #c6d3ea; font-size: 14px; }
.stage.flash { cursor: pointer; background: rgba(3, 6, 14, 0.55); }
.stage-card.small { width: min(380px, 100%); }

.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.award { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.award-name { font-weight: 800; }
.award-xp { color: var(--aurora-g); font-size: 20px; font-weight: 900; }
.award-elo.up { color: var(--aurora-g); }
.award-elo.down { color: #ff8b97; }
.level-up { color: var(--sun); font-weight: 800; animation: pulse 1.2s ease-in-out infinite; }

/* ---------------------------------------------------------------- yleiset kerrokset */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 6, 14, 0.75);
  backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: min(460px, 100%);
  background: var(--night-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.whats-new { padding-left: 18px; }
.version-line { color: var(--muted); font-size: 12px; }
.update-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(63, 242, 176, 0.12);
  border-bottom: 1px solid rgba(63, 242, 176, 0.3);
}
.update-banner[hidden] { display: none; }

.chat-drawer {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  width: min(360px, calc(100vw - 24px));
  height: min(460px, 70vh);
  display: flex;
  flex-direction: column;
  background: rgba(10, 18, 36, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.chat-drawer[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.chat-lines { flex: 1; overflow: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.chat-line.system { color: var(--muted); font-size: 13px; }
.chat-line .from { font-weight: 700; color: var(--aurora-g); }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; background: rgba(5, 12, 26, 0.6); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.chat-form button { border: none; border-radius: 10px; padding: 0 12px; background: var(--aurora-c); color: var(--night); cursor: pointer; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 80;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(10, 18, 36, 0.95);
  border: 1px solid var(--aurora-g);
  box-shadow: var(--shadow);
  transition: opacity 0.25s, transform 0.25s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer.version { text-align: center; color: rgba(149, 166, 196, 0.55); font-size: 11px; padding: 10px; }

/* ---------------------------------------------------------------- kapeat näytöt */

@media (max-width: 960px) {
  .game-body { grid-template-columns: 1fr; }
  .lobby-grid { grid-template-columns: 1fr; }
  .tab-body { max-height: none; }
}
@media (max-width: 640px) {
  main#main { padding: 14px 12px 32px; }
  .topbar { padding: 10px 14px; }
  .brand-name { font-size: 16px; }
  .top-profile .tp-elo { display: none; }
  .hero { grid-template-columns: 1fr; padding-bottom: 8px; }
  .hero-art { height: 120px; }
  .hero-piece { width: 110px; height: 110px; }
  .lobby-form { flex-direction: column; }
  .seat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .seat-box { padding: 10px 6px; }
  .tide .tide-name { display: none; }
  .tide.now .tide-name { display: inline; }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .ps-res { gap: 6px; font-size: 13px; }
  .card { width: 46px; height: 66px; }
  .card-rank { font-size: 19px; }
  .hand-cards { gap: 5px; }
  .market-row { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .market-row .card { width: 100%; max-width: 46px; }
  .stage-card { padding: 16px 12px; }
  .bet-actions .btn { min-width: 0; flex: 1 1 40%; }
  .fighter-art { width: 56px; height: 56px; }
  .awards { grid-template-columns: 1fr; }
}

.stage-card .lead { margin: 0 auto 10px; }
@media (max-width: 640px) {
  .hero-art { height: 140px; }
  .hero-piece.a, .hero-piece.b { top: 10px; }
}

/* Laulukilvan ennuste hyökkäysruudussa: ♪ omat–puolustajan vastalaulut. */
.duel-odds {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  padding: 0 5px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(10, 18, 36, 0.85);
  color: var(--ink);
  pointer-events: none;
}
.duel-odds.good { color: var(--aurora-g); }
.duel-odds.bad { color: #ff8b97; }
.rules-card { text-align: left; max-height: calc(100vh - 32px); overflow: auto; }
.rules-card .panel { background: none; border: none; box-shadow: none; padding: 0; backdrop-filter: none; }
.rules-card .big-btn { display: flex; margin: 16px auto 0; }
.rules-sub { margin: 14px 0 4px; font-size: 14px; color: var(--aurora-g); }

/* Laulukilvan kivien vaikutukset (4×4) */
.stone { position: relative; }
.stone .fx { font-size: clamp(16px, 4.5vw, 24px); opacity: 0.9; }
.stone.fx-routa { background: radial-gradient(circle at 35% 30%, #cfe9f7, #7fb3d1 55%, #45708c); }
.stone.fx-routa .fx { color: #f4fbff; text-shadow: 0 0 8px #bfe8ff; }
.stone.fx-revontuli { background: radial-gradient(circle at 35% 30%, #6a5ab8, #2c3f72 60%, #1c2848); box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.45), 0 0 16px rgba(63, 242, 176, 0.45); }
.stone.fx-revontuli .fx { color: var(--aurora-g); text-shadow: 0 0 10px var(--aurora-g); animation: pulse 2s ease-in-out infinite; }
.stone.fx-kaiku .fx { color: var(--sun); text-shadow: 0 0 8px rgba(255, 211, 110, 0.8); }
.stone.frozen::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(220, 245, 255, 0.55), rgba(150, 210, 240, 0.15));
  box-shadow: inset 0 0 0 2px rgba(220, 245, 255, 0.8);
  pointer-events: none;
}
.buy-song { margin: 4px auto 6px; border-color: var(--sun); }
.stone-legend { display: grid; gap: 2px; margin-top: 8px; font-size: 12px; color: var(--muted); text-align: left; }

/* Markkinat laudan alla */
.market-strip {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
}
.market-strip.live { border-color: var(--sun); box-shadow: 0 0 22px rgba(255, 211, 110, 0.18); }
.ms-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ms-title { font-weight: 800; }
.ms-sub { flex: 1; color: var(--muted); font-size: 13px; min-width: 180px; }
.market-strip.live .ms-sub { color: var(--sun); }
.ms-silver { font-weight: 800; }
.ms-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; justify-items: center; }
.card.buyable { animation: beckon 2.4s ease-in-out infinite; }
@keyframes beckon {
  50% { box-shadow: 0 0 0 2px var(--sun), 0 8px 22px rgba(255, 211, 110, 0.4); }
}

/* Sökön tarkoitus ja kutsuennuste */
.soko-why { color: #c6d3ea; font-size: 13.5px; margin: 0 auto 8px; max-width: 52ch; }
.soko-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  margin: 0 auto 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(63, 242, 176, 0.08);
  border: 1px solid rgba(63, 242, 176, 0.3);
  font-size: 14px;
}
.pv-hand { font-weight: 800; color: var(--sun); }
.pv-summon { font-weight: 700; color: var(--aurora-g); }
.pv-win { color: var(--muted); }
.next-soko { color: var(--aurora-g); font-size: 12.5px; }
@media (max-width: 640px) {
  .ms-row { gap: 4px; }
  .ms-row .card { width: 100%; max-width: 46px; }
}

.side-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side-col .market-strip { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.ms-row .market-item { width: 100%; }
@media (max-width: 640px) {
  .ms-row .card { width: 100%; max-width: 54px; height: auto; aspect-ratio: 5 / 7; }
  .ms-row .card-rank { font-size: 18px; }
}

/* Markkinavaihe: vuoro alkaa markkinoilta */
.ms-row.big { margin: 6px 0 4px; }
.ms-row.big .card { width: 62px; height: 88px; }
.ms-pref { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 8px; cursor: pointer; }
.market-strip .ms-pref { justify-content: flex-start; margin: 0 0 8px; }
@media (max-width: 640px) {
  .ms-row.big .card { width: 100%; max-width: 56px; height: auto; aspect-ratio: 5 / 7; }
}
