/* ==========================================================================
   หน้าเล่นหลัก (public/css/kukhi.css) — ใช้ร่วมกับ theme.css
   ========================================================================== */

:root {
  --outline: #17110B;   /* สีขอบตัวอักษรชื่อเกม (เหมือน "BOGDOG" ในภาพตัวอย่าง) */
}

.page {
  max-width: 1040px;
  margin-inline: auto;
  padding: 0 12px 45px;
}
@media (min-width: 768px) {
  .page { padding-inline: 20px; }
}

/* ---------- ชื่อเกม ---------- */
.hero {
  padding: calc(18px + env(safe-area-inset-top, 0px)) 0 10px;
  text-align: center;
}
.title {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 11.5vw, 4.9rem);
  line-height: 1.4;
  letter-spacing: .01em;
  /* ขอบดำแบบการ์ตูนด้วย text-shadow ใช้ได้ทุกเบราว์เซอร์ */
  text-shadow:
    -3px -3px 0 var(--outline), 3px -3px 0 var(--outline),
    -3px 3px 0 var(--outline), 3px 3px 0 var(--outline),
    0 -3px 0 var(--outline), 0 3px 0 var(--outline),
    -3px 0 0 var(--outline), 3px 0 0 var(--outline),
    0 6px 0 rgba(23, 17, 11, .28);
}
/* เบราว์เซอร์ที่รองรับ paint-order จะได้ขอบเรียบกว่า */
@supports (paint-order: stroke fill) {
  .title {
    -webkit-text-stroke: .15em var(--outline);
    paint-order: stroke fill;
    text-shadow: 0 .09em 0 rgba(23, 17, 11, .28);
  }
}
.round-chip {
  display: inline-block;
  margin: .1rem 0 0;
  padding: .3rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 2px 0 rgba(74, 52, 22, .18);
}

/* ---------- กระดานคะแนน ---------- */
.board {
  margin: 8px 0 18px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.board-head {
  padding: 1rem 1.25rem .8rem;
  border-bottom: 2px dashed var(--line);
  text-align: center;
}
.board-head h2 { margin: 0; font-size: clamp(1.1rem, 3.4vw, 1.4rem); }

.sides { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; }
.side { position: relative; padding: 1.25rem 1rem 1.1rem; text-align: center; }
.side.even { background: var(--even-soft); }
.side.odd { background: var(--odd-soft); }
.side .big {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.4rem, 13vw, 6.5rem);
  line-height: 1.35;
}
.side.even .big { color: var(--even); }
.side.odd .big { color: var(--odd); }
.side .digits { margin-top: .15rem; color: var(--muted); font-size: .85rem; letter-spacing: .12em; }
.side .count { margin-top: .35rem; font-weight: 600; }
.side.win::after {
  content: "ชนะ";
  position: absolute;
  top: .6rem;
  right: .6rem;
  padding: .1rem .7rem;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: .85rem;
  box-shadow: 0 2px 0 var(--amber-edge);
}
.side.lose { opacity: .5; }

.center {
  display: flex;
  min-width: 132px;
  padding: .75rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  background: var(--surface);
}
.center .clock { font-family: var(--font-display); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.center small { color: var(--muted); font-size: .78rem; line-height: 1.35; text-align: center; }
.center .result-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: .06em;
}

.gift { width: 48px; height: 48px; }
.gift .g-box { fill: var(--amber); }
.gift .g-ribbon { fill: var(--odd); }
.gift .g-bow { stroke: var(--odd); }
.gift .g-q { fill: #fff; font-family: var(--font-display); font-size: 13px; font-weight: 600; }

.tug { display: flex; height: 10px; background: var(--line); }
.tug .e { flex-grow: 1; background: var(--even); transition: flex-grow .5s ease; }
.tug .o { flex-grow: 1; background: var(--odd); transition: flex-grow .5s ease; }

@media (max-width: 575.98px) {
  .sides { grid-template-columns: 1fr 1fr; }
  .center {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    gap: .25rem .75rem;
    border-top: 1px solid var(--line);
  }
  .center small { text-align: left; }
}

/* ---------- แท็บ ---------- */
.tabs {
  --bs-nav-link-color: var(--ink);
  --bs-nav-link-hover-color: var(--ink);
  flex-wrap: nowrap;
  gap: .4rem;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs .nav-link {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  padding: .45rem 1.05rem;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(74, 52, 22, .18);
}
.tabs .nav-link:hover { background: #FFF8EC; }
.tabs .nav-link.active {
  border-color: var(--amber-edge);
  background: var(--amber);
  color: var(--ink);
}
.tabs .badge { margin-inline-start: .35rem; background: var(--paper); color: var(--ink); font-weight: 500; }
.tabs .nav-link.active .badge { background: var(--surface); }

.panel {
  margin-top: 8px;
  padding: 1.15rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
@media (min-width: 768px) { .panel { padding: 1.75rem; } }

/* ---------- ขั้นตอนเข้าร่วม ---------- */
.step { margin-bottom: 1.7rem; }
.step-title { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; font-size: 1.05rem; line-height: 1.4; }
.step-no {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--amber);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: .95rem;
  box-shadow: 0 2px 0 var(--amber-edge);
}

.seg {
  display: inline-flex;
  gap: 4px;
  margin-bottom: .9rem;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}
.seg-btn {
  min-height: 44px;
  padding: .4rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: .95rem;
}
.seg-btn[aria-pressed="true"] { background: var(--amber); box-shadow: 0 2px 0 var(--amber-edge); }

/* ช่องค้นหาในแท็บรายชื่อ/ประวัติ: สูงพอให้จิ้มง่ายบนมือถือ */
.panel .form-control[type="search"] { min-height: 44px; }

.chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
@media (min-width: 576px) { .chars { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px) { .chars { grid-template-columns: repeat(6, 1fr); } }
.char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .6rem .3rem .5rem;
  border: 3px solid transparent;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.char img { width: 64px; height: 64px; }
.char span { font-size: .82rem; line-height: 1.25; text-align: center; }
.char:hover { border-color: var(--line); }
.char[aria-pressed="true"] {
  border-color: var(--amber-edge);
  background: #FFF7E8;
  transform: translateY(-2px);
  box-shadow: 0 4px 0 rgba(168, 102, 30, .35);
}

.custom-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border: 2px dashed var(--field-border);
  border-radius: var(--radius);
  background: var(--paper);
}
.custom-box[hidden] { display: none; }
.custom-fields { min-width: 0; flex: 1 1 auto; }
.custom-preview {
  display: grid;
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.3;
  text-align: center;
}
.custom-preview img { width: 100%; height: 100%; object-fit: cover; }
.custom-preview img[hidden] { display: none; }
.custom-preview[data-state="ok"] { border-color: var(--even); }
.custom-preview[data-state="error"] { border-color: var(--odd); }
@media (max-width: 575.98px) {
  .custom-box { flex-direction: column; align-items: stretch; }
  .custom-preview { align-self: center; }
}

.pick-side { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.side-btn {
  padding: 1rem .75rem;
  border: 3px solid transparent;
  border-radius: 20px;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}
.side-btn .k { display: block; font-family: var(--font-display); font-weight: 600; font-size: 2.4rem; line-height: 1.4; }
.side-btn small { color: var(--muted); }
.side-btn.even { background: var(--even-soft); }
.side-btn.odd { background: var(--odd-soft); }
.side-btn.even .k { color: var(--even); }
.side-btn.odd .k { color: var(--odd); }
.side-btn.even[aria-pressed="true"] { border-color: var(--even); box-shadow: inset 0 0 0 2px var(--even); }
.side-btn.odd[aria-pressed="true"] { border-color: var(--odd); box-shadow: inset 0 0 0 2px var(--odd); }

/* ---------- ตั๋ว ---------- */
.ticket {
  position: relative;
  padding: 1.1rem 1.2rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.ticket::before, .ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  transform: translateY(-50%);
}
.ticket::before { left: -13px; }
.ticket::after { right: -13px; }
.ticket .t-top { display: flex; align-items: center; gap: .75rem; padding-bottom: .8rem; border-bottom: 2px dashed var(--line); }
.ticket .t-top .av { width: 56px; height: 56px; }
.ticket .t-name { font-family: var(--font-display); font-size: 1.1rem; line-height: 1.3; word-break: break-word; }
.ticket .t-bottom { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: .8rem; }
.ticket .t-side { font-family: var(--font-display); font-weight: 600; font-size: 2rem; line-height: 1.35; }
.ticket.even .t-side { color: var(--even); }
.ticket.odd .t-side { color: var(--odd); }
.ticket .t-round { color: var(--muted); font-size: .8rem; text-align: right; }
.ticket.empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.ticket.empty::before, .ticket.empty::after { display: none; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.stack[hidden] { display: none; }
.sticky-col { position: sticky; top: calc(1rem + env(safe-area-inset-top, 0px)); }
@media (max-width: 991.98px) { .sticky-col { position: static; } }

.joined { display: flex; min-height: 100%; flex-direction: column; justify-content: center; gap: .75rem; padding: 1rem 0; }
.joined[hidden] { display: none; }
.joined h2 { margin: 0; font-size: clamp(1.4rem, 3.5vw, 1.9rem); line-height: 1.4; }
.joined h2.even { color: var(--even); }
.joined h2.odd { color: var(--odd); }

.notice {
  margin-bottom: 1.25rem;
  padding: .75rem 1rem;
  border: 2px solid var(--amber-edge);
  border-radius: 14px;
  background: var(--gold-soft);
  color: var(--ink);
}
.rules li { margin-bottom: .35rem; }

/* ---------- รายชื่อผู้เล่น / ผู้ชนะ ---------- */
.team-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .6rem; }
.team-head h3 { margin: 0; font-size: 1.15rem; }
.team-head.even h3 { color: var(--even); }
.team-head.odd h3 { color: var(--odd); }

.plist { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.plist li { display: flex; align-items: center; gap: .65rem; padding: .5rem .25rem; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.plist li.me { padding-inline: .5rem; border-radius: 12px; background: var(--gold-soft); }
.plist .you { flex-shrink: 0; padding: 0 .55rem; border-radius: 999px; background: var(--ink); color: #fff; font-size: .75rem; line-height: 1.7; }
.plist .av { width: 38px; height: 38px; }
.plist .nm { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-note { padding: 1rem 0; color: var(--muted); font-size: .92rem; }

/* ---------- ประวัติผู้ชนะ ---------- */
.hist { margin-bottom: .75rem; overflow: hidden; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hist > summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  cursor: pointer;
  list-style: none;
}
.hist > summary::-webkit-details-marker { display: none; }
.hist-num { min-width: 2.6ch; font-family: var(--font-display); font-weight: 600; font-size: 1.9rem; line-height: 1; text-align: center; }
.hist-num.even { color: var(--even); }
.hist-num.odd { color: var(--odd); }
.hist-meta strong { display: block; font-family: var(--font-display); font-weight: 500; }
.hist-meta span { color: var(--muted); font-size: .85rem; }
.hist-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s ease; }
.hist[open] .hist-chev { transform: rotate(180deg); }
.hist-body { padding: .25rem 1rem 1rem; }

/* ---------- แถบอันดับด้านล่าง ---------- */
.dock {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 1030;
  width: min(760px, 100%);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-radius: 28px 28px 0 0;
  background: #fff;
  box-shadow: 0 -8px 28px rgba(74, 52, 22, .24);
  transform: translateX(-50%);
}
.dock-bar { display: flex; min-height: 66px; align-items: center; gap: .25rem; padding: .5rem .7rem; }
.dock-trophy, .dock-toggle {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}
.dock-trophy:hover, .dock-toggle:hover { background: var(--paper); }
.dock-trophy svg { width: 30px; height: 30px; }
.t-cup, .t-stem { fill: var(--orange); }
.t-base { fill: var(--amber-edge); }
.t-handle { stroke: var(--orange); }
.dock-toggle svg { width: 24px; height: 24px; transition: transform .2s ease; }
.dock-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.dock-sep { flex: 0 0 1px; align-self: stretch; margin: .35rem .2rem; background: #E9ECEF; }

.dock-rank { display: flex; min-width: 0; flex: 1 1 auto; justify-content: space-around; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.dock-rank li { display: flex; align-items: center; gap: .35rem; font-family: var(--font-display); font-size: 1.05rem; white-space: nowrap; }
.dock-rank .rk { font-weight: 600; }
.dock-rank .dot { width: .8rem; height: .8rem; border-radius: 50%; }
.dock-rank li.even .dot { background: var(--even); }
.dock-rank li.odd .dot { background: var(--odd); }
.dock-rank .num { font-variant-numeric: tabular-nums; }
.dock-clock { min-width: 5.4rem; flex: 0 0 auto; font-family: var(--font-display); font-size: .95rem; font-variant-numeric: tabular-nums; text-align: center; }

.dock-more { padding: .9rem 1.2rem .6rem; border-bottom: 1px solid #E9ECEF; }
.dock-more[hidden] { display: none; }
.dock-more-title { margin: 0 0 .35rem; color: var(--muted); font-size: .85rem; }
.dock-recent { display: grid; gap: .3rem; margin: 0; padding: 0; list-style: none; }
.dock-recent li { display: flex; align-items: center; gap: .75rem; }
.dock-recent .n { min-width: 2.2ch; font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; text-align: center; }
.dock-recent .n.even { color: var(--even); }
.dock-recent .n.odd { color: var(--odd); }
.dock-recent .d { color: var(--muted); font-size: .9rem; }

@media (max-width: 430px) {
  .dock-bar { gap: .1rem; padding-inline: .45rem; }
  .dock-trophy, .dock-toggle { width: 38px; height: 38px; }
  .dock-trophy svg { width: 26px; height: 26px; }
  .dock-rank li { gap: .25rem; font-size: .95rem; }
  .dock-clock { min-width: 4.7rem; font-size: .82rem; }
}
/* ซ่อนแถบตอนพิมพ์ในช่องกรอกบนมือถือ กันบังช่องและคีย์บอร์ด */
@media (max-width: 767.98px) {
  body:has(input:focus, textarea:focus) .dock { display: none; }
}

/* ---------- toast และท้ายหน้า ---------- */
.toast-container { margin-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
.toast { border: 0; background: var(--ink); color: #fff; }
/* ---------- หน้า error (resources/views/errors) ---------- */
.err { max-width: 560px; margin: 1.5rem auto 0; text-align: center; }
.err-code { margin: 0; color: var(--amber-edge); font-family: var(--font-display); font-weight: 600; font-size: clamp(3.8rem, 20vw, 6.5rem); line-height: 1.2; }
.err-head { margin: 0 0 .4rem; font-size: 1.5rem; }
.err .btn-go { margin-top: .75rem; }

.footer { padding: 1.5rem 0 .5rem; color: var(--ink-soft); font-size: .85rem; text-align: center; }
.footer a { color: var(--ink); }
