/* ==========================================================================
   SAMPLE — three games from the tea house
   ==========================================================================
   Domino, Okey and Konkan: the games actually played over tea in Erbil, as
   opposed to the games a portfolio usually reaches for. They are folk games,
   which means the rules vary by house — so the page states the variant it
   implements rather than pretending there is one canonical rulebook.

   Warm and wooden on purpose. The arcade page is neon; this one should feel
   like a table.

   Scoped under .th.
   ========================================================================== */

.th {
  --bg:      #1a1410;
  --bg-2:    #221a14;
  --felt:    #1f3d31;
  --felt-2:  #26493b;
  --wood:    #6b4a2f;
  --wood-2:  #4a331f;
  --panel:   #2a201a;
  --line:    #3d2f24;
  --line-2:  #574335;
  --ink:     #f6efe6;
  --ink-2:   #cbb9a6;
  --ink-3:   #a89482;

  --gold:    #d9a441;
  --red:     #d1483f;
  --blue:    #3f7fd1;
  --green:   #4a9e63;
  --black:   #2b2b2b;

  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.th *, .th *::before, .th *::after { box-sizing: border-box; }
.th svg { display: block; }
.th a { color: var(--gold); }
.th :focus-visible { outline-color: var(--gold); }

.th-wrap { width: 100%; max-width: 76rem; margin-inline: auto; padding: 0 clamp(1rem, 3vw, 2rem) 5rem; }

/* ------------------------------------------------------------------ head --- */

.th-hero { padding-block: clamp(2.5rem, 6vw, 4rem) 1.5rem; text-align: center; }
.th-hero h1 {
  margin: 0; font-weight: 800;
  font-size: clamp(2.2rem, 6.5vw, 4rem); letter-spacing: -0.035em; line-height: 1;
  color: var(--gold);
}
.th-hero p { margin: 1rem auto 0; max-width: 42rem; color: var(--ink-2); line-height: 1.7; }
.th-hero .native { font-size: 1.05rem; color: var(--ink-3); margin-top: .5rem; }

.th-tabs { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 1.5rem; }
.th-tab {
  font: inherit; font-size: .88rem; font-weight: 600;
  padding: .55rem 1.2rem; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink-2);
  cursor: pointer; transition: background .18s, color .18s, border-color .18s, transform .1s;
}
.th-tab:hover { color: var(--ink); border-color: var(--ink-3); }
.th-tab:active { transform: scale(.97); }
.th-tab[aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: #2a1c05; }
/* Removed a tick after load. Without it, opening the page at #konkan crossfades
   the default tab out, and part-way through that fade its dark label is sitting
   on a nearly-dark pill. There is no previous state to animate from on a first
   paint, so it should not animate at all. */
.th-tabs--noanim .th-tab { transition: none; }
.th-tab small { display: block; font-size: .68rem; font-weight: 500; opacity: .8; }

.th-panel[hidden] { display: none; }

/* ----------------------------------------------------------------- table --- */

.table {
  background:
    radial-gradient(120% 90% at 50% 0%, var(--felt-2), var(--felt) 70%);
  border: 10px solid var(--wood-2);
  border-radius: 18px;
  box-shadow: inset 0 0 60px rgba(0,0,0,.35), 0 20px 50px -28px #000;
  padding: clamp(.9rem, 3vw, 1.5rem);
  display: grid; gap: 1rem; justify-items: center;
}

.th-bar { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; justify-content: center; width: 100%; }
.th-stat {
  display: flex; flex-direction: column; align-items: center; min-width: 4.4rem;
  padding: .35rem .7rem; border-radius: 9px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.08);
}
.th-stat dt { font-size: .58rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.th-stat dd { margin: .1rem 0 0; font-family: var(--mono); font-size: 1.05rem; font-weight: 700; }

.tbtn {
  font: inherit; font-size: .8rem; font-weight: 600;
  padding: .45rem .9rem; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.tbtn:hover { background: #362a22; border-color: var(--ink-3); }
.tbtn:active { transform: scale(.97); }
.tbtn[disabled] { opacity: .4; cursor: not-allowed; }
.tbtn--go { background: var(--gold); border-color: var(--gold); color: #2a1c05; }
.tbtn--go:hover { background: #e8b757; border-color: #e8b757; }

.th-msg { min-height: 1.5rem; font-size: .88rem; font-weight: 600; text-align: center; color: var(--ink-2); }
.th-msg[data-k="win"]  { color: #7fd99a; }
.th-msg[data-k="lose"] { color: #f08a82; }
.th-msg[data-k="turn"] { color: var(--gold); }

.th-hint { font-size: .76rem; color: var(--ink-3); text-align: center; margin: 0; max-width: 32rem; line-height: 1.6; }

/* ================================================================ DOMINO === */

.dm-board {
  width: 100%; max-width: 44rem; margin-inline: auto;
  min-height: 5.5rem;
  display: flex; flex-wrap: nowrap; gap: 4px;
  align-items: center;
  /* `safe` matters: plain `center` on an overflowing flex row pushes the start
     of the chain out of reach on the left, where no scrollbar can get to it. */
  justify-content: safe center;
  padding: .8rem; border-radius: 14px;
  scroll-behavior: smooth;
  /* A faint centre line, so an almost-empty table still reads as a surface
     rather than as a hole in the layout. */
  background:
    linear-gradient(rgba(255,255,255,.05), rgba(255,255,255,.05)) center / 100% 1px no-repeat,
    rgba(0,0,0,.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), inset 0 0 22px rgba(0,0,0,.25);
  overflow-x: auto;
}
.dm-hand {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  max-width: 44rem; margin-inline: auto;
  padding: .7rem .6rem .8rem;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--wood), var(--wood-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 6px 16px rgba(0,0,0,.32);
}

/* The opponent's tiles, with a count — a bare row of backs does not say
   what it is, and the number is information you play against. */
.dm-them { display: flex; gap: 5px; justify-content: center; align-items: center; flex-wrap: wrap; }
.dm-them b {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin-inline-end: .3rem;
}

.domino {
  --w: 34px;
  width: var(--w); height: calc(var(--w) * 2);
  background: linear-gradient(180deg, #f6f1e7, #e6ded0);
  border-radius: 5px;
  border: 0; padding: 2px;
  display: grid; grid-template-rows: 1fr 1fr; gap: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.7);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  position: relative;
}
.domino::after {
  content: ""; position: absolute; inset-inline: 3px; top: 50%;
  height: 1px; background: rgba(0,0,0,.35); transform: translateY(-.5px);
}
.domino--lay { --w: 30px; cursor: default; flex: none; }
/* A double sits across the chain, so it keeps the upright 1:2 proportion
   while every other laid tile is turned on its side. */
.domino--dbl { align-self: center; }
.dm-empty { color: var(--ink-3); font-size: .8rem; margin: auto; }

/* Shown only while a tile that fits both ends is selected. */
.dm-choice {
  display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; justify-content: center;
}
.dm-choice[hidden] { display: none; }
.dm-choice > span { font-size: .78rem; color: var(--gold); font-weight: 600; }
.domino--h { width: calc(var(--w) * 2); height: var(--w); grid-template-rows: none; grid-template-columns: 1fr 1fr; }
.domino--h::after { inset-block: 3px; inset-inline: auto; left: 50%; width: 1px; height: auto; transform: translateX(-.5px); }
.domino:hover:not(:disabled):not(.domino--lay) { transform: translateY(-4px); box-shadow: 0 8px 14px rgba(0,0,0,.5); }
/* Playable tiles get a ring; unplayable ones are dulled but stay legible.
   Marking the ones you CAN use is the useful half — a screenshot of this
   board with only fading to go on gave no clue which tiles were live. */
.domino:not([disabled]):not(.domino--lay) {
  box-shadow: 0 0 0 2px rgba(230,178,90,.85), 0 2px 5px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.7);
}
.domino[disabled] { opacity: .82; filter: grayscale(.55) brightness(.92); cursor: not-allowed; }
.domino[data-sel] { transform: translateY(-6px); box-shadow: 0 0 0 2px var(--gold), 0 8px 14px rgba(0,0,0,.5); }

.dm-face { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; padding: 1px; }
.dm-face i {
  width: calc(var(--w) * .155); height: calc(var(--w) * .155);
  border-radius: 50%; display: block;
  background: radial-gradient(circle at 35% 30%, #4a4a4a, #1d1d1d 70%);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.28);
}

/* The backs of the opponent's tiles, so the table reads as a real game. */
.dm-back {
  --w: 26px;
  width: var(--w); height: calc(var(--w) * 2);
  border-radius: 5px;
  background: repeating-linear-gradient(45deg, var(--wood) 0 4px, var(--wood-2) 4px 8px);
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
}

/* The running tally in front of the meld row. It is the thing that makes the
   search visible on every move rather than only at the moment of a win. */
/* Each seat shows the tile it last threw, because what a seat discards is the
   only thing you get to know about a hand you cannot see. */
.ok-seat__pile { display: flex; justify-content: center; margin-top: .35rem; }
.ok-seat[data-won] { border-color: #f08a82; box-shadow: 0 0 0 2px rgba(240,138,130,.35); }

.ok-tally {
  display: inline-flex; align-items: center;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: .3rem .6rem; border-radius: 999px;
  background: rgba(255,255,255,.07); color: var(--ink-2);
  border: 1px solid rgba(255,255,255,.1);
}
.ok-tally.is-win {
  background: rgba(127,217,154,.16); color: #8fe0a8; border-color: rgba(127,217,154,.4);
}

/* ================================================================== OKEY === */

.ok-rack {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: .7rem .6rem;
  background: linear-gradient(180deg, var(--wood), var(--wood-2));
  border-radius: 10px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.45);
  justify-content: center;
}
.tile {
  width: 30px; height: 44px;
  border: 0; border-radius: 5px;
  background: linear-gradient(180deg, #faf4e8, #eae0cd);
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.8);
  font-family: var(--mono); font-size: 1rem; font-weight: 800;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  position: relative;
}
.tile:hover:not(:disabled) { transform: translateY(-4px); }
.tile[data-sel] { transform: translateY(-7px); box-shadow: 0 0 0 2px var(--gold), 0 8px 14px rgba(0,0,0,.5); }
.tile[data-c="r"] { color: var(--red); }
.tile[data-c="b"] { color: var(--blue); }
.tile[data-c="k"] { color: var(--black); }
.tile[data-c="g"] { color: var(--green); }
.tile[data-joker] { background: linear-gradient(180deg, #f3e2b6, #e2cc93); }
.tile[data-joker]::after { content: "★"; position: absolute; top: 1px; right: 3px; font-size: .5rem; color: var(--gold); }
.tile--sm { width: 24px; height: 35px; font-size: .82rem; }
.tile--ghost {
  background: none; box-shadow: none; cursor: default;
  border: 1px dashed rgba(255,255,255,.16);
}

.ok-melds { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; align-items: center; }
.ok-meld {
  display: flex; gap: 3px; padding: .3rem;
  border-radius: 7px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}
.ok-meld[data-bad] { border-color: var(--red); background: rgba(209,72,63,.12); }
.ok-meldlab { font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); align-self: center; padding-inline: .3rem; }

.ok-seats { display: flex; gap: .8rem; flex-wrap: wrap; justify-content: center; }
.ok-seat {
  padding: .5rem .7rem .55rem; border-radius: 9px; min-width: 6rem;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.08);
  font-size: .76rem; text-align: center;
}
.ok-seat[data-turn] { border-color: var(--gold); background: rgba(217,164,65,.12); }
.ok-seat b { display: block; }
.ok-seat span { color: var(--ink-3); font-family: var(--mono); font-size: .68rem; }

/* ================================================================ KONKAN === */

.kn-hand {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  max-width: 49rem; margin-inline: auto;
  padding: .7rem .6rem .8rem;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--wood), var(--wood-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 6px 16px rgba(0,0,0,.32);
}
.card {
  width: 48px; height: 68px;
  border: 0; border-radius: 7px;
  background: linear-gradient(180deg, #fdfbf6, #efe9dc);
  box-shadow: 0 2px 5px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.9);
  cursor: pointer;
  display: grid; align-content: space-between;
  padding: 4px 5px;
  font-family: var(--mono); font-size: .86rem; font-weight: 800; line-height: 1;
  transition: transform .12s, box-shadow .12s;
}
.card:hover:not(:disabled) { transform: translateY(-5px); }
.card[data-sel] { transform: translateY(-8px); box-shadow: 0 0 0 2px var(--gold), 0 8px 14px rgba(0,0,0,.5); }
.card[data-s="h"], .card[data-s="d"] { color: var(--red); }
.card[data-s="s"], .card[data-s="c"] { color: var(--black); }
.card[data-joker] { background: linear-gradient(180deg, #f6e6bd, #e6d09a); color: #7a5510; }
.card .pip { justify-self: end; transform: rotate(180deg); }
.card--sm { width: 34px; height: 48px; font-size: .66rem; }

.kn-melds { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; align-items: center; min-height: 3.5rem; }
.kn-meld { display: flex; gap: 3px; padding: .3rem; border-radius: 7px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); }

.pile {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .7rem; border-radius: 10px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.08);
}
.pile b { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }

/* --------------------------------------------------------------- notes --- */

.th-note {
  margin-top: 1.5rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: clamp(1.1rem, 3vw, 2rem);
}
.th-note h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.th-note h2 span {
  display: inline-block; font-family: var(--mono); font-size: .6rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-right: .5rem;
}
.th-note h3 { margin: 1.5rem 0 .4rem; font-size: .92rem; }
.th-note p  { margin: 0 0 .7rem; color: var(--ink-2); line-height: 1.75; max-width: 46rem; }
.th-note code { font-family: var(--mono); font-size: .86em; background: #191310; border-radius: 4px; padding: .1em .35em; color: var(--gold); }
.th-note .rules {
  margin: .9rem 0; padding: .8rem 1rem;
  background: rgba(217,164,65,.08); border: 1px solid rgba(217,164,65,.3);
  border-radius: 10px; font-size: .82rem; color: var(--ink-2); line-height: 1.7;
}
.th-note .rules b { color: var(--gold); }

.th-outro { margin-top: 2rem; text-align: center; color: var(--ink-2); font-size: .9rem; }
.th-outro a { text-decoration: underline; text-underline-offset: 2px; }

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