:root {
  --bg: #0a0f14;
  --panel: #111923;
  --panel-strong: #172332;
  --text: #eaf7f2;
  --muted: #9fb3bd;
  --mint: #00f5a0;
  --cyan: #00d9ff;
  --pink: #f72585;
  --gold: #ffd166;
  --line: rgba(234, 247, 242, 0.15);
  --card: #fbfff9;
  --ink: #071014;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(40px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 8% 5%, rgba(0, 217, 255, 0.14), transparent 27rem),
    radial-gradient(circle at 92% 18%, rgba(247, 37, 133, 0.12), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tutorial-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.tutorial-hero,
.guide-section,
.tutorial-footer {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 25, 35, 0.92);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
}

.tutorial-hero {
  min-height: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: center;
  gap: 32px;
  padding: clamp(28px, 6vw, 70px);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(3rem, 8vw, 6.5rem);
  line-height: 0.88;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

h3 {
  margin-bottom: 8px;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

strong {
  color: var(--text);
}

.hero-copy {
  max-width: 620px;
  margin-bottom: 0;
  font-size: clamp(1rem, 2vw, 1.24rem);
}

.hero-cards {
  position: relative;
  min-height: 220px;
}

.hero-cards .table-card {
  position: absolute;
  top: 50%;
  left: 50%;
}

.hero-cards .table-card:nth-child(1) {
  transform: translate(-118%, -42%) rotate(-16deg);
}

.hero-cards .table-card:nth-child(2) {
  z-index: 2;
  transform: translate(-50%, -58%);
}

.hero-cards .table-card:nth-child(3) {
  transform: translate(18%, -42%) rotate(16deg);
}

.guide-nav {
  position: sticky;
  z-index: 10;
  top: 10px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(10, 15, 20, 0.9);
  backdrop-filter: blur(16px);
}

.guide-nav a {
  flex: 1 0 auto;
  border-radius: 7px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.guide-nav a:hover,
.guide-nav a:focus-visible {
  background: rgba(0, 217, 255, 0.12);
  color: var(--cyan);
}

.guide-section {
  padding: clamp(24px, 5vw, 52px);
  scroll-margin-top: 92px;
}

.objective-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  align-items: center;
  gap: 36px;
}

.section-copy p:last-child {
  margin-bottom: 0;
}

.goal-card {
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  gap: 8px;
  border: 1px solid rgba(0, 245, 160, 0.3);
  border-radius: 50%;
  padding: 25px;
  background: radial-gradient(circle, rgba(0, 245, 160, 0.16), transparent 68%);
  text-align: center;
}

.goal-number {
  color: var(--mint);
  font-size: 5rem;
  font-weight: 950;
  line-height: 0.8;
}

.goal-card span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
}

.turn-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
}

.flow-card,
.example-card,
.special-card {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  background: var(--panel-strong);
}

.flow-card {
  position: relative;
  display: grid;
  justify-items: center;
  text-align: center;
}

.flow-card p,
.example-card p,
.special-card p {
  margin-bottom: 0;
}

.step-number {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  color: var(--ink);
  font-weight: 950;
}

.flow-arrow {
  color: var(--cyan);
  font-size: 2rem;
  font-weight: 950;
}

.mini-pile,
.mini-discard {
  margin: 8px 0 18px;
}

.card-back,
.table-card {
  width: clamp(68px, 9vw, 88px);
  aspect-ratio: 0.7;
  border-radius: 8px;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32);
}

.card-back {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.56);
  background:
    radial-gradient(circle at 28% 24%, rgba(234, 247, 242, 0.35) 0 5px, transparent 6px),
    radial-gradient(circle at 70% 76%, rgba(234, 247, 242, 0.28) 0 5px, transparent 6px),
    linear-gradient(135deg, transparent 22%, rgba(255, 255, 255, 0.16) 22% 28%, transparent 28% 52%, rgba(255, 255, 255, 0.16) 52% 58%, transparent 58%),
    linear-gradient(135deg, var(--pink), #744bff, var(--cyan));
}

.card-back::after {
  content: "";
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(7, 16, 20, 0.72);
  border: 2px solid rgba(0, 245, 160, 0.72);
  box-shadow: inset 0 0 0 5px rgba(0, 217, 255, 0.22);
}

.table-card {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  justify-items: center;
  border: 1px solid rgba(7, 16, 20, 0.14);
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
  box-shadow: inset 0 -7px 0 var(--accent), 0 14px 28px rgba(0, 0, 0, 0.32);
}

.table-card::before,
.table-card::after {
  position: absolute;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
}

.table-card::before {
  content: attr(data-rank);
  top: 8px;
  left: 8px;
}

.table-card::after {
  content: attr(data-rank);
  right: 8px;
  bottom: 8px;
}

.card-main {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.card-rank {
  color: var(--accent);
  font-size: clamp(1.28rem, 3vw, 1.75rem);
  font-weight: 950;
}

.card-suit {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.suit-symbol {
  display: block;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", sans-serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.42);
}

.table-card.suit-a { --accent: #F72585; }
.table-card.suit-b { --accent: #00D9FF; }
.table-card.suit-c { --accent: #00B894; }
.table-card.suit-d { --accent: #4B5563; }
.table-card.suit-e { --accent: #B779FF; }
.table-card.wild,
.table-card.round-wild { --accent: var(--gold); }
.table-card.freeze { --accent: var(--cyan); }

.table-card.wild,
.table-card.round-wild {
  box-shadow:
    inset 0 -7px 0 var(--accent),
    0 0 0 3px rgba(255, 209, 102, 0.58),
    0 0 0 8px rgba(255, 209, 102, 0.24),
    0 0 26px rgba(255, 209, 102, 0.5),
    0 14px 28px rgba(0, 0, 0, 0.32);
}

.table-card.wild::before,
.table-card.wild::after,
.table-card.freeze::before,
.table-card.freeze::after {
  content: "";
}

.table-card.wild .card-main {
  gap: 0;
}

.table-card.wild .card-rank,
.table-card.freeze .card-rank {
  max-width: 92%;
  font-size: clamp(0.66rem, 1.35vw, 0.86rem);
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table-card.wild .card-suit {
  display: none;
}

.table-card.freeze {
  background: linear-gradient(150deg, #f8ffff, #dff8ff);
  box-shadow: inset 0 -7px 0 var(--cyan), 0 0 24px rgba(0, 217, 255, 0.34), 0 13px 25px rgba(0, 0, 0, 0.3);
}

.tip,
.example-label {
  margin-top: 20px;
  border-left: 3px solid var(--mint);
  padding: 10px 14px;
  background: rgba(0, 245, 160, 0.07);
}

.example-grid,
.special-grid {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.example-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.example-heading {
  display: flex;
  gap: 14px;
}

.example-heading p {
  margin-bottom: 16px;
}

.valid-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 245, 160, 0.13);
  color: var(--mint);
  font-weight: 950;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card-row.compact .table-card {
  width: 70px;
}

.special-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.freeze-info {
  grid-column: 1 / -1;
}

.special-visual {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.28);
}

.suit-fan {
  gap: 0;
}

.suit-fan .table-card {
  width: 66px;
  margin-inline: -9px;
}

.suit-fan .table-card:nth-child(1) { transform: rotate(-14deg) translateY(8px); }
.suit-fan .table-card:nth-child(2) { transform: rotate(-7deg); }
.suit-fan .table-card:nth-child(4) { transform: rotate(7deg); }
.suit-fan .table-card:nth-child(5) { transform: rotate(14deg) translateY(8px); }

.plus {
  color: var(--muted);
  font-size: 1.3rem;
  font-weight: 950;
}

.freeze-sequence {
  gap: clamp(18px, 5vw, 48px);
}

.frozen-player {
  border: 1px solid rgba(0, 217, 255, 0.36);
  border-radius: 50%;
  padding: 28px 24px;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.16), transparent);
  color: var(--cyan);
  font-weight: 900;
  text-align: center;
}

.frozen-player small {
  color: var(--muted);
}

.score-table {
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.score-row:last-child {
  border-bottom: 0;
}

.score-row strong {
  color: var(--gold);
  text-align: right;
}

.score-header {
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.score-example {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  margin-top: 22px;
  border-radius: 10px;
  padding: 22px;
  background: rgba(255, 209, 102, 0.07);
}

.score-example p {
  margin-bottom: 0;
}

.tutorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(24px, 5vw, 46px);
}

.tutorial-footer h2 {
  margin-bottom: 0;
}

.lobby-button {
  flex: 0 0 auto;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 8px;
  padding: 0 22px;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  color: var(--ink);
  font-weight: 950;
  text-decoration: none;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.lobby-button:hover,
.lobby-button:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

@media (max-width: 760px) {
  .tutorial-hero,
  .objective-section {
    grid-template-columns: 1fr;
  }

  .tutorial-hero {
    text-align: center;
  }

  .hero-cards {
    min-height: 190px;
  }

  .goal-card {
    width: min(220px, 72vw);
    margin: 0 auto;
  }

  .turn-flow {
    grid-template-columns: 1fr;
  }

  .turn-flow > .flow-arrow {
    transform: rotate(90deg);
    text-align: center;
  }

  .example-grid,
  .special-grid {
    grid-template-columns: 1fr;
  }

  .freeze-info {
    grid-column: auto;
  }

  .tutorial-footer {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .tutorial-hero {
    padding-inline: 18px;
  }

  .guide-section {
    padding-inline: 18px;
  }

  .flow-card,
  .example-card,
  .special-card {
    padding: 18px 14px;
  }

  .table-card {
    width: 72px;
  }

  .suit-fan .table-card {
    width: 56px;
    margin-inline: -10px;
  }

  .score-example {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
  }
}
