/* Jute: page-specific styles on top of style.css (same colours, buttons and dark theme). */

/* One calm colour per character, used for the card's icon and edge. */
.ch-0 { --ch: #c58a00; } /* King */
.ch-1 { --ch: #b0306a; } /* Queen */
.ch-2 { --ch: #2f6feb; } /* Jack */
.ch-3 { --ch: #7a4fd6; } /* Minister */
.ch-4 { --ch: #1e7e8c; } /* Police */
.ch-5 { --ch: #b5502a; } /* Soldier */
.ch-6 { --ch: #2f8f4e; } /* Farmer */
.ch-7 { --ch: #4b5563; } /* Thief */
:root[data-theme="dark"] .ch-7 { --ch: #9aa3ae; }

.jcard {
  font: inherit;
  width: 96px;
  height: 134px;
  border-radius: 12px;
  border: 1px solid var(--card-edge);
  border-top: 5px solid var(--ch);
  background: var(--card-face);
  color: #1f2937;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 4px;
  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.12s;
}
.jcard .icon { width: 40px; height: 40px; color: var(--ch); stroke-width: 1.6; }
.jcard span { font-weight: 700; font-size: 0.9rem; }
.jcard:disabled { cursor: default; }
.jcard.chosen { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--accent), var(--shadow-md); }
.jcard.set { box-shadow: 0 0 0 3px var(--success), var(--shadow-sm); }

/* Home: three matching cards above the title */
.jute-hero-cards { display: flex; margin-bottom: 6px; }
.jute-hero-cards .jcard { width: 64px; height: 90px; cursor: default; }
.jute-hero-cards .jcard .icon { width: 28px; height: 28px; }
.jute-hero-cards .jcard span { font-size: 0.7rem; }
.jute-hero-cards .jcard + .jcard { margin-left: -18px; }
.jute-hero-cards .jcard:nth-child(1) { transform: rotate(-10deg); }
.jute-hero-cards .jcard:nth-child(3) { transform: rotate(10deg); }

/* Lobby */
.jute-lobby { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 16px 40px; }
.jute-players { list-style: none; margin: 8px 0 0; padding: 0; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 8px; }
.jute-players li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-weight: 600;
}
.jute-players li .icon { width: 20px; height: 20px; color: var(--muted); }
.jute-players li span:first-of-type { flex: 1; }
.jute-players li.away { opacity: 0.55; }
.jute-players .host { font-size: 0.75rem; color: var(--accent); }

/* Game */
.jute-game { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 16px 12px 28px; max-width: 760px; margin: 0 auto; }
.jute-top { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.jute-match { font-size: 0.85rem; font-weight: 700; color: var(--muted); letter-spacing: 0.4px; }
.jute-scores { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.jute-score {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.85rem;
}
.jute-score.me { border-color: var(--accent); }
.jute-score.away { opacity: 0.55; }
.jute-score .pts { font-weight: 700; color: var(--accent); }
.jute-score .st { font-size: 0.75rem; color: var(--success); font-weight: 600; }
.jute-score .st:empty { display: none; }

.jute-center { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 52px; }
.jute-phase { font-weight: 600; text-align: center; padding: 8px 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.jute-phase:empty { visibility: hidden; }
.jute-phase.good { background: var(--success-soft); color: var(--success); }
.jute-phase.urgent { background: var(--danger-soft); color: var(--danger); }
.jute-timer { width: 100%; height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.jute-timer span {
  display: block; height: 100%;
  background: var(--accent);
  transform-origin: left center;
  animation: turn-bar var(--total, 20s) linear var(--elapsed, 0s) forwards;
}

.jute-hand-area { display: flex; flex-direction: column; align-items: center; gap: 22px; margin-top: 8px; }
.jute-hand { display: flex; gap: 12px; justify-content: center; padding-top: 14px; }
.jute-btn {
  font: inherit;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 3px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--faint);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s, background 0.15s, color 0.15s;
}
.jute-btn:disabled { cursor: default; }
.jute-btn.hot { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: var(--shadow-md); }
.jute-btn.hot:active { transform: scale(0.95); }

/* Results */
.jute-ranking li.win { background: var(--success-soft); }
.jute-ranking .mini-cards { display: flex; gap: 2px; color: var(--muted); }
.jute-ranking .mini-cards .icon { width: 16px; height: 16px; }

/* Phones held sideways: cards and button side by side */
@media (orientation: landscape) and (max-height: 540px) {
  .jute-game { gap: 10px; padding-top: 8px; }
  .jute-hand-area { flex-direction: row; gap: 28px; margin-top: 0; }
  .jcard { width: 84px; height: 116px; }
  .jute-btn { width: 108px; height: 108px; font-size: 1.15rem; }
}
@media (max-width: 380px) {
  .jcard { width: 86px; height: 120px; }
  .jute-hand { gap: 8px; }
}

/* ---------- Friendlier game screen ---------- */

/* Players in passing order: You → next → … → back to you */
.pass-ring { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.ring-player {
  display: flex; flex-direction: column; align-items: center;
  min-width: 64px; padding: 6px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.82rem; line-height: 1.25;
}
.ring-player.me { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ring-player.gets { border-style: dashed; border-color: var(--accent); }
.ring-player.away { opacity: 0.55; }
.ring-top { display: flex; gap: 6px; align-items: baseline; }
.ring-top .pts { font-weight: 700; color: var(--accent); }
.ring-player .st { font-size: 0.72rem; color: var(--success); font-weight: 600; min-height: 1em; }
.ring-player .st.rank { color: var(--accent); }
.ring-arrow { color: var(--faint); display: flex; }
.ring-arrow .icon { width: 14px; height: 14px; }

/* First-match tips */
.jute-tips {
  width: 100%; max-width: 520px; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 14px; background: var(--accent-soft);
}
.jute-tips ol { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; }
.jute-tips li { display: flex; align-items: center; gap: 6px; }
.tip-n {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--surface); font-size: 0.72rem; font-weight: 700;
}

/* Hand: progress line and the card that just arrived */
.jute-hand-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hand-info { margin: 0; font-size: 0.88rem; color: var(--muted); text-align: center; min-height: 1.2em; }
.jcard { position: relative; }
.jcard.new { border-color: var(--accent); }
.new-tag {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 0.66rem !important; font-weight: 700;
}
:root[data-theme="dark"] .new-tag { color: #0d1420; }
.jcard.chosen::after {
  content: "Passing"; position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  font-size: 0.7rem; font-weight: 700; color: var(--accent);
}
@media (prefers-reduced-motion: no-preference) {
  .jcard.new { animation: jute-arrive 0.35s ease-out; }
}
@keyframes jute-arrive { from { transform: translateX(-24px); opacity: 0.3; } to { transform: none; opacity: 1; } }

/* JUTE button with a caption that says when it can be pressed */
.jute-btn-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.jute-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.jute-btn .icon { width: 22px; height: 22px; }
.jute-btn span { font-size: 1rem; letter-spacing: 2px; }
.jute-caption { margin: 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
.jute-btn.hot + .jute-caption { color: var(--danger); font-weight: 600; }

/* Results rows: place · name · cards · points (+ total) */
.jute-ranking .rank-pos { width: 2.2em; font-weight: 700; color: var(--muted); }
.jute-ranking .rank-score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.jute-ranking .rank-score b { color: var(--success); }
.jute-ranking .rank-score small { color: var(--muted); font-size: 0.72rem; }

/* Lobby avatars: the player's initial */
.lobby-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.jute-players li span.lobby-avatar + span { flex: 1; }
.jute-players li span:first-of-type { flex: none; }

/* ---------- One instruction at a time ---------- */
.step-box {
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 18px 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  text-align: center;
}
.step-title { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.step-sub { margin: 0; font-size: 0.9rem; color: var(--muted); line-height: 1.4; }
.step-box .jute-timer { margin-top: 4px; }
.step-box.good { background: var(--success-soft); border-color: transparent; }
.step-box.good .step-title { color: var(--success); }
.step-box.urgent { background: var(--danger-soft); border-color: transparent; }
.step-box.urgent .step-title { color: var(--danger); }

.jute-game > .jute-hand { padding-top: 22px; }
.ring-player.gets::after { content: "gets your card"; font-size: 0.62rem; color: var(--accent); font-weight: 600; }
.ring-player.gets .st:empty, .ring-player.gets .st { min-height: 0; }

/* JUTE: appears only when you may press it */
.jute-game > .jute-btn {
  width: auto; height: auto; border-radius: 999px;
  padding: 18px 56px; font-size: 1.5rem;
  background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: var(--shadow-md);
}
.jute-game > .jute-btn { transition: transform 0.08s; } /* colour changes at once, never mid-fade */
.jute-game > .jute-btn:active { transform: scale(0.96); }
.step-box.good ~ .jute-btn { background: var(--success); border-color: var(--success); }
:root[data-theme="dark"] .jute-game > .jute-btn { color: #0d1420; }

@media (orientation: landscape) and (max-height: 540px) {
  .step-box { padding: 8px 14px; }
  .step-title { font-size: 1rem; }
  .jute-game > .jute-hand { padding-top: 14px; }
}

/* ================= High-quality table layout ================= */
.jute-game.jt {
  max-width: 980px;
  min-height: calc(100dvh - var(--header-h));
  padding: 12px 12px 20px;
  gap: 14px;
  justify-content: space-between;
}

/* The table */
.jt-table-wrap { width: 100%; display: flex; justify-content: center; }
.jt-table {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 5 / 4;
  max-height: 46dvh;
}
.jt-table::before { /* the felt */
  content: "";
  position: absolute;
  inset: 13% 11%;
  border-radius: 999px;
  background: radial-gradient(ellipse at 50% 40%, var(--surface) 0%, var(--table) 75%);
  border: 1px solid var(--table-line);
  box-shadow: inset 0 2px 12px rgba(16, 24, 40, 0.06);
}
.jt-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.jt-center-info { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.jt-match { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.jt-dir { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--muted); }
.jt-dir .icon { width: 14px; height: 14px; transform: scaleX(-1); }

/* Seats */
.jt-seat {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  z-index: 3; width: 92px; text-align: center;
}
.jt-avatar {
  position: relative;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
  background: hsl(var(--hue, 210) 70% 92%);
  color: hsl(var(--hue, 210) 45% 32%);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] .jt-avatar { background: hsl(var(--hue, 210) 30% 26%); color: hsl(var(--hue, 210) 70% 82%); border-color: var(--bg); }
.jt-seat.me .jt-avatar { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }
.jt-seat.away { opacity: 0.5; }
.jt-seat.caller .jt-avatar { box-shadow: 0 0 0 3px var(--danger), var(--shadow-sm); }
.jt-name { display: flex; gap: 5px; align-items: baseline; font-size: 0.8rem; white-space: nowrap; }
.jt-name span { font-weight: 600; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.jt-name b { color: var(--accent); }
.jt-gets {
  font-size: 0.64rem; font-weight: 600; color: var(--accent);
  padding: 1px 7px; border-radius: 999px; background: var(--accent-soft);
}
.jt-badge {
  position: absolute; right: -8px; top: -6px;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.64rem; font-weight: 700;
  background: var(--success); color: #fff; border: 2px solid var(--surface);
}
.jt-badge .icon { width: 12px; height: 12px; stroke-width: 3; }
.jt-badge.rank { background: var(--accent); }
.jt-badge.away { background: var(--faint); }
:root[data-theme="dark"] .jt-badge { color: #0d1420; border-color: var(--bg); }

/* JUTE button in the middle of the table */
.jt-jute {
  font: inherit; font-weight: 800; font-size: 1.35rem; letter-spacing: 3px;
  width: 116px; height: 116px; border-radius: 50%;
  border: 4px solid var(--surface);
  background: var(--danger); color: #fff;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.08s;
}
.jt-jute:active { transform: scale(0.94); }
.step-box.good ~ * .jt-jute, .jt.good .jt-jute { background: var(--success); }
:root[data-theme="dark"] .jt-jute { color: #0d1420; border-color: var(--bg); }

/* Cards flying to the next seat on a pass */
.jt-fly-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.jt-fly {
  position: absolute; width: 22px; height: 30px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, var(--accent) 0 3px, var(--accent-soft) 3px 6px);
  border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}

/* Bottom: instruction + hand */
.jt-bottom { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.jt .jute-hand { padding-top: 18px; gap: 14px; }

/* Cards: tinted face, big icon, corner icons like a real playing card */
.jt .jcard, .jute-hero-cards .jcard {
  position: relative;
  width: 104px; height: 146px;
  border: 1px solid color-mix(in srgb, var(--ch) 35%, var(--card-edge));
  border-top: 1px solid color-mix(in srgb, var(--ch) 35%, var(--card-edge));
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--ch) 14%, var(--card-face)) 0 34%, transparent 35%),
    var(--card-face);
  gap: 6px;
}
.jc-art .icon { width: 46px; height: 46px; color: var(--ch); stroke-width: 1.5; }
.jc-name { font-weight: 700; font-size: 0.92rem; color: #1f2937; letter-spacing: 0.2px; }
.jc-corner { position: absolute; color: var(--ch); display: flex; }
.jc-corner .icon { width: 14px; height: 14px; stroke-width: 2; }
.jc-corner.tl { left: 7px; top: 7px; }
.jc-corner.br { right: 7px; bottom: 7px; transform: rotate(180deg); }
.jt .jcard.chosen { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--accent), var(--shadow-md); }
.jt .jcard.set { box-shadow: 0 0 0 3px var(--success), var(--shadow-sm); }
.jt .jcard:not(:disabled):hover { transform: translateY(-4px); }
.jt .jcard.chosen:not(:disabled):hover { transform: translateY(-16px); }
.jute-hero-cards .jcard { width: 70px; height: 98px; border-radius: 10px; }
.jute-hero-cards .jc-art .icon { width: 30px; height: 30px; }
.jute-hero-cards .jc-name { font-size: 0.7rem; }
.jute-hero-cards .jc-corner .icon { width: 10px; height: 10px; }

/* Small phones */
@media (max-width: 380px) {
  .jt .jcard { width: 92px; height: 130px; }
  .jt-seat { width: 80px; }
  .jt-avatar { width: 42px; height: 42px; }
}
/* Phones held sideways / short screens: table left, instruction and hand right */
@media (orientation: landscape) and (max-height: 540px) {
  .jute-game.jt { display: grid; grid-template-columns: 1fr 1fr; align-items: center; min-height: calc(100dvh - var(--header-h)); padding: 6px 12px; }
  .jt-table { max-height: calc(100dvh - var(--header-h) - 16px); width: 100%; }
  .jt .jcard { width: 86px; height: 120px; }
  .jt-avatar { width: 40px; height: 40px; font-size: 0.95rem; }
}
/* Refinements: a clean oval, and a bigger table on tall phones (no empty gap) */
.jt-table::before { border-radius: 50%; inset: 12% 10%; }
@media (max-width: 640px) and (orientation: portrait) {
  .jt-table { aspect-ratio: 1 / 1.02; max-height: 56dvh; width: min(100%, 460px); }
}
