:root {
  --sky: #2fa7f0;
  --sea: #07357f;
  --yellow: #ffe600;
  --red: #e5261f;
  --green: #39d353;
  --wood: #b5702c;
  --wood-dark: #5b3210;
  --plank: #f3d9a4;
  --ink: #2b1605;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sea);
  font-family: 'Mali', 'Sarabun', system-ui, sans-serif;
  font-weight: 500;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

[hidden] { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

/* A plank sign bobbing in the scene, not a card: thick edge, hard shadow, nailed corners. */
.sign {
  position: relative;
  width: min(560px, 100%);
  margin: auto;
  padding: 18px 20px 20px;
  text-align: center;
  background: repeating-linear-gradient(0deg, var(--plank) 0 46px, #e6c98e 46px 48px);
  border: 6px solid var(--wood-dark);
  border-radius: 6px 14px 8px 12px;
  box-shadow: 8px 8px 0 rgba(0, 20, 60, .55);
}
.sign::before, .sign::after {
  content: '';
  position: absolute;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--wood-dark);
}
.sign::before { left: 8px; }
.sign::after { right: 8px; }
.sign.small { width: min(320px, 100%); }
.sign.wide { width: min(620px, 100%); }

h2 {
  margin: 6px 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
}

.logo { margin: -6px 0 14px; line-height: 0; } /* room for the descending ู */
.logo svg { width: min(420px, 100%); height: auto; overflow: visible; }
.logo text {
  font: 700 118px 'Mali', sans-serif;
  fill: url(#wordart);
  stroke: #fff;
  stroke-width: 12px;
  paint-order: stroke;
  stroke-linejoin: round;
  filter: drop-shadow(5px 6px 0 var(--sea));
}

.intro { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.how { margin: 0; line-height: 1.5; text-align: left; }
.art { display: block; width: 96px; height: 96px; margin: 0 auto; flex: none; }
.intro .art.title-art { width: 132px; height: auto; }
.corner-art { position: absolute; top: 4px; left: 18px; width: 64px; height: 64px; }

.credit { margin: 10px 0 0; font-size: .8rem; }
.credit a { color: inherit; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn {
  min-height: 46px;
  padding: 6px 18px;
  border: 4px solid var(--wood-dark);
  border-radius: 8px;
  background: #fff6e0;
  box-shadow: 3px 3px 0 var(--wood-dark);
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  cursor: pointer;
}
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--yellow); font-size: 1.3rem; padding-inline: 26px; }

:focus-visible { outline: 4px solid var(--red); outline-offset: 2px; }

.final {
  margin: 0;
  font-size: clamp(2.6rem, 11vw, 3.8rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: .03em;
  color: var(--yellow);
  -webkit-text-stroke: 2px var(--wood-dark);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--wood-dark);
}

.facts {
  list-style: none;
  margin: 6px 0 12px;
  padding: 0;
  line-height: 1.5;
}

.nick { margin-bottom: 12px; }
.nick label { display: block; font-weight: 700; margin-bottom: 4px; }
.nick input {
  flex: 1 1 150px;
  min-width: 0;
  min-height: 46px;
  padding: 6px 10px;
  border: 4px solid var(--wood-dark);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
}
.note { min-height: 1.3em; margin: 6px 0 0; font-size: .9rem; }

/* Stacked by layout, so the two buttons cannot land on top of each other. */
.corners {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.corner {
  pointer-events: auto;
  color: var(--ink);
  width: 44px;
  height: 44px;
  border: 3px solid var(--wood-dark);
  border-radius: 8px;
  background: var(--plank);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Empty unless Cloudflare needs the player to confirm something, once a game has ended. */
.turnstile { display: flex; justify-content: center; }
.turnstile:not(:empty) { margin-bottom: 10px; }

.menu-btn {
  width: auto;
  min-width: 44px;
  padding: 0 8px;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
}

.wide-btn { display: block; width: 100%; }
/* ร้านปลาย่าง is a game of its own, so it wears fire colours wherever it is offered. */
.yaki-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding-block: 10px;
  background: linear-gradient(180deg, #ff8a2b, #e5261f);
  color: #fff;
  font-size: 1.25rem;
  text-shadow: 0 2px 0 #7a1408;
}
.yaki-btn small { margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: #ffe600; color: #7a1408; font-size: .8rem; text-shadow: none; vertical-align: middle; }
.tab.yaki-tab { background: linear-gradient(180deg, #ff8a2b, #e5261f); color: #fff; text-shadow: 0 1px 0 #7a1408; }
.tab.yaki-tab[aria-selected="true"] { background: #b3160f; color: #ffe600; }
/* Taller than a small phone: start at the top and scroll, so the first step is never cut off. */
#yakiHow, #yakiOver, #over, #settingsBox { align-items: flex-start; }
#yakiHow .sign, #yakiOver .sign, #over .sign, #settingsBox .sign { margin: auto; }
.rest-note { margin: 6px 0; padding: 6px 10px; background: #fff6e0; border: 3px solid var(--wood-dark); border-radius: 8px; font-weight: 700; line-height: 1.4; }
.rest-note[hidden] { display: none; }
.how-steps { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; text-align: left; font-size: .88rem; }
.how-steps li { display: flex; align-items: center; gap: 8px; padding: 3px 6px; background: #fff6e0; border: 2px solid var(--wood-dark); border-radius: 6px; line-height: 1.3; }
.how-steps img { flex: none; width: 34px; height: 34px; object-fit: contain; }
.how-steps b { display: block; color: var(--red); }
.how-score { margin: 4px 0 0; font-size: .85rem; line-height: 1.35; }

.settings { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.setting { text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; background: #fff6e0; border: 3px solid var(--wood-dark); border-radius: 8px; font-weight: 700; }
.setting input { order: 1; flex: 1 1 100%; min-width: 0; min-height: 42px; padding: 4px 8px; border: 3px solid var(--wood-dark); border-radius: 8px; background: #fff; font: inherit; font-size: 1rem; color: var(--ink); }
.setting-hint { font-size: .8rem; font-weight: 500; text-align: right; }
.setting:has(input) { flex-wrap: wrap; gap: 4px 12px; }
.match-btn { display: block; width: 100%; margin-top: 10px; padding-block: 10px; background: linear-gradient(180deg, #5cc6ff, #1778c9); color: #fff; font-size: 1.25rem; text-shadow: 0 2px 0 #0a2a66; }
.island-btn { display: block; width: 100%; margin-top: 10px; padding-block: 10px; text-align: center; text-decoration: none; background: linear-gradient(180deg, #8fd46b, #3f9a3a); color: #fff; font-size: 1.25rem; text-shadow: 0 2px 0 #1e4d1a; }
.match-btn small { margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: #ffe600; color: #0a2a66; font-size: .8rem; text-shadow: none; vertical-align: middle; }
#matchLobby, #matchRoom, #matchWait, #matchOver { align-items: flex-start; }
#matchLobby .sign, #matchRoom .sign, #matchWait .sign, #matchOver .sign { margin: auto; }
.online { margin: 0 0 6px; font-size: .9rem; font-weight: 700; color: #b3160f; }
.quick { display: block; width: 100%; }
.board-link { display: block; width: 100%; min-height: 38px; margin-top: 8px; font-size: .92rem; }
.tab.match-tab { background: linear-gradient(180deg, #5cc6ff, #1778c9); color: #fff; text-shadow: 0 1px 0 #0a2a66; }
.tab.match-tab[aria-selected="true"] { background: #0a4f94; color: #ffe600; }
.medals { white-space: nowrap; font-size: .9rem; font-variant-numeric: tabular-nums; }
.rooms { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.room { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center; padding: 5px 8px; background: #fff6e0; border: 3px solid var(--wood-dark); border-radius: 8px; line-height: 1.25; }
.room small { display: block; font-size: .78rem; }
.room .btn { min-height: 36px; padding: 2px 10px; font-size: .86rem; box-shadow: 2px 2px 0 var(--wood-dark); }
.room.live { opacity: .65; }
.room-empty { padding: 8px; font-size: .9rem; }
.dots { display: flex; gap: 3px; margin-top: 3px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--wood-dark); }
.dots i.on { background: var(--red); }
.final-small { margin: 4px 0; font-size: 1.3rem; font-weight: 700; color: #b3160f; }
.room-players, .result-board { list-style: none; margin: 8px 0 10px; padding: 0; text-align: left; background: #fff6e0; border: 3px solid var(--wood-dark); border-radius: 8px; }
.room-players li { padding: 3px 10px; border-bottom: 1px dotted var(--wood-dark); }
.room-players li:last-child, .result-board li:last-child { border-bottom: 0; }
.room-players li.me, .result-board li.me { background: #ffe9a8; font-weight: 700; }
.result-board li { display: grid; grid-template-columns: 1.7em minmax(0, 1fr) auto 2.4em; gap: 6px; padding: 3px 8px; border-bottom: 1px dotted var(--wood-dark); font-size: .95rem; }
.result-board .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-board .num { font-variant-numeric: tabular-nums; }
.result-board .coin { font-weight: 700; color: #b3160f; text-align: right; }
.earn { margin: 6px 0; font-weight: 700; font-size: 1.05rem; }
.match-hud { position: fixed; z-index: 4; left: 50%; top: max(50px, calc(env(safe-area-inset-top) + 50px)); transform: translateX(-50%); width: min(340px, calc(100% - 16px)); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 8px; background: rgba(255, 246, 224, .92); border: 2px solid var(--wood-dark); border-radius: 7px; font-size: .85rem; font-weight: 700; pointer-events: none; }
.match-hud b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.match-hud b.hot { color: var(--red); }
.match-toast { position: fixed; z-index: 6; left: 50%; top: 8px; transform: translateX(-50%); max-width: calc(100% - 16px); padding: 6px 12px; background: var(--yellow); border: 3px solid var(--wood-dark); border-radius: 8px; font-weight: 700; pointer-events: none; }
.game-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.game-row .yaki-btn, .game-row .sushi-btn { margin-top: 0; padding-inline: 2px; font-size: .95rem; white-space: nowrap; }
.sushi-btn { display: block; width: 100%; margin-top: 10px; padding-block: 10px; background: linear-gradient(180deg, #ff9db0, #d63a5e); color: #fff; font-size: 1.25rem; text-shadow: 0 2px 0 #7a1438; }
.sushi-btn small { margin-left: 4px; padding: 1px 7px; border-radius: 99px; background: #ffe600; color: #7a1438; font-size: .75rem; text-shadow: none; vertical-align: middle; }
.tab.sushi-tab { background: linear-gradient(180deg, #ff9db0, #d63a5e); color: #fff; text-shadow: 0 1px 0 #7a1438; }
.tab.sushi-tab[aria-selected="true"] { background: #a01e43; color: #ffe600; }
#sushiHow, #sushiOver { align-items: flex-start; }
#sushiHow .sign, #sushiOver .sign { margin: auto; }
.share-img { display: block; width: 100%; height: auto; border: 3px solid var(--wood-dark); border-radius: 8px; background: #fff6e0; }
a.btn { display: inline-flex; align-items: center; justify-content: center; color: inherit; text-decoration: none; }

.yaki-canvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; background: #3a2412; }

/* In-game items sit opposite the menu and sound buttons. */
.items {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.items[hidden] { display: none; }

.wallet { margin: 4px 0 8px; text-align: center; font-size: 1.05rem; }
.wallet b { font-size: 1.6rem; color: var(--red); font-variant-numeric: tabular-nums; }
.shop { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.shop-sell, .shop-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  text-align: left;
  background: #fff6e0;
  border: 3px solid var(--wood-dark);
  border-radius: 6px;
}
.shop-sell img { width: 56px; height: 56px; object-fit: contain; }
.shop-sell .row { margin: 0; flex: 1 1 auto; justify-content: flex-end; }
.shop-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.shop-actions .btn { padding-inline: 10px; font-size: .95rem; }
#yakiBar { flex-direction: row; }
.shop-head { margin-top: 6px; font-weight: 700; text-align: left; }
.btn.on { background: var(--yellow); }
.shop-icon { font-size: 2rem; line-height: 1; }
.shop-info { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }

.menu-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.rules { max-height: min(66vh, 480px); overflow-y: auto; padding: 8px 10px; text-align: left; background: #fff6e0; border: 3px solid var(--wood-dark); border-radius: 6px; line-height: 1.5; }
.rules h3 { margin: 10px 0 2px; font-size: 1.05rem; font-weight: 700; color: var(--red); }
.rules h3:first-child { margin-top: 0; }
.rules p { margin: 0 0 6px; }
.rules table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.rules th { padding: 3px 8px 3px 0; font-weight: 500; text-align: left; }
.rules td { padding: 3px 0; font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rules tr + tr > * { border-top: 2px dotted rgba(91, 50, 16, .35); }

.close {
  position: absolute;
  top: 8px;
  right: 22px;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.tabs { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.tab, .chip {
  min-height: 40px;
  padding: 4px 12px;
  border: 3px solid var(--wood-dark);
  border-radius: 8px;
  background: #fff6e0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tab[aria-selected='true'], .chip[aria-pressed='true'] { background: var(--yellow); font-weight: 700; }
.period { display: flex; gap: 4px; justify-content: center; margin: 6px 0; }
.chip { min-height: 34px; padding: 2px 10px; font-size: .9rem; }

.board-body {
  height: min(46vh, 340px);
  overflow-y: auto;
  padding: 6px;
  margin-top: 6px;
  background: #fff6e0;
  border: 3px solid var(--wood-dark);
  border-radius: 6px;
  text-align: left;
}
.board-body .empty { margin: 0; padding: 26px 8px; text-align: center; line-height: 1.5; }

.lb { list-style: none; margin: 0; padding: 0; }
.lb li {
  display: grid;
  grid-template-columns: 2em 34px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 3px 2px;
}
.lb li + li { border-top: 2px dotted rgba(91, 50, 16, .35); }
.lb.players li { grid-template-columns: 2em minmax(0, 1fr) auto; }
.lb .pos { font-weight: 700; text-align: right; }
.lb img { width: 34px; height: 34px; }
/* overflow clips Thai marks above the line, so the box needs room for them. */
.lb .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.8; }
.lb .num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* The player's own row stays at the bottom of the box, however long or short the list is. */
.lb-wrap { display: flex; flex-direction: column; min-height: 100%; }
.lb-mine {
  position: sticky;
  bottom: -6px; /* over the box's padding, so rows cannot show beneath it */
  display: grid;
  grid-template-columns: minmax(2em, auto) minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin-top: auto;
  padding: 3px 2px;
  background: #ffe39a;
  border-top: 3px solid var(--wood-dark);
}

.vs { display: flex; align-items: center; justify-content: center; gap: 14px; text-align: center; line-height: 1.2; }
.vs-side b { display: block; font-size: 1.6rem; color: var(--red); font-variant-numeric: tabular-nums; }
.vs-mid { font-weight: 700; }
.vs-trio { margin: 4px 0 8px; padding-bottom: 6px; text-align: center; font-weight: 700; border-bottom: 3px solid var(--wood-dark); }

.bar { height: 10px; margin-top: 2px; background: var(--red); border-radius: 0 5px 5px 0; min-width: 3px; }

.book {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  text-align: center;
  font-size: .85rem;
  line-height: 1.25;
}
.book img { display: block; width: 64px; height: 64px; margin: 0 auto 2px; }
.book .locked img { filter: brightness(.1) contrast(.6); opacity: .5; }
.book b { display: block; }
.mine-best { margin: 0 0 8px; text-align: center; font-weight: 700; }

@media (max-height: 560px) and (orientation: landscape) {
  .how, .sign > .art:not(.corner-art) { display: none; }
  .intro .art { width: 64px; height: 64px; }
  .logo svg { width: 220px; }
  .board-body { height: 38vh; }
}

html.calm .btn:active { transform: none; }

/* Static text is written in both languages; the script at the top of index.html sets which one shows. */
html[lang="en"] [lang="th"], html[lang="th"] [lang="en"] { display: none !important; }
