/* ============================================================
   Pixel Blackjack — FULL retro pixel theme
   ฟอนต์ Silver (pixel ไทย+อังกฤษ) · ขอบคม · felt หมากรุก · ปุ่มเด้ง · scanline CRT
   ============================================================ */
@font-face {
  font-family: 'Silver';
  src: url('./fonts/Silver.woff2') format('woff2');
  font-weight: normal; font-style: normal; font-display: swap;
}
:root {
  --felt: #0b6b34;
  --felt2: #0a5f2e;
  --felt-dark: #053b1c;
  --gold: #ffd23f;
  --gold-dk: #b8860b;
  --ink: #0d0b14;
  --line: #1b1730;
  --panel: #241d3a;
  --panel-lit: #3a2f5e;
  --panel-shd: #14102a;
  --text: #f3efe3;
  --red: #ff4d5e;
  --green: #4cd97a;
  --blue: #4a86ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Silver', sans-serif;
  background: var(--ink);
  color: var(--text);
  overflow-x: hidden;
  image-rendering: pixelated;
}
/* ฟอนต์ pixel สำหรับหัวข้อ/ตัวเลข/EN */
.px { font-family: 'Silver', monospace; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.screen { min-height: 100vh; width: 100%; }

/* ---------- CRT scanline overlay ---------- */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, rgba(0,0,0,.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply; opacity: .5;
}

/* ============================================================
   ปุ่ม pixel (ขอบคม + เงาเด้ง 3D)
   ============================================================ */
.gbtn {
  font-family: 'Silver', monospace;
  font-size: 18px; line-height: 1.4; letter-spacing: .5px;
  border: 3px solid var(--ink); border-radius: 0;
  padding: 12px 16px; cursor: pointer; color: #fff;
  background: var(--blue);
  box-shadow: inset -3px -3px 0 0 rgba(0,0,0,.35),
              inset 3px 3px 0 0 rgba(255,255,255,.25),
              0 5px 0 0 var(--ink);
  transition: none; text-shadow: 1px 1px 0 rgba(0,0,0,.4);
}
.gbtn:hover { filter: brightness(1.12); }
.gbtn:active { transform: translateY(5px);
  box-shadow: inset -3px -3px 0 0 rgba(0,0,0,.35),
              inset 3px 3px 0 0 rgba(255,255,255,.25),
              0 0 0 0 var(--ink); }
.gbtn.primary   { background: var(--gold); color: #2a1c00; text-shadow: 1px 1px 0 rgba(255,255,255,.35); }
.gbtn.secondary { background: var(--blue); }
.gbtn.warn      { background: var(--red); }
.gbtn.ghost     { background: #4a4368; }
.gbtn.big       { font-size: 24px; padding: 18px 22px; width: 100%; }
.gbtn.small     { font-size: 15px; padding: 9px 11px; }

/* ============================================================
   หน้าเริ่ม
   ============================================================ */
#start {
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    repeating-linear-gradient(45deg, var(--felt2) 0 12px, var(--felt) 12px 24px);
}
.start-card {
  background: var(--panel);
  border: 4px solid var(--ink);
  border-radius: 0;
  padding: 30px 26px; width: 100%; max-width: 440px; text-align: center;
  box-shadow:
    inset -5px -5px 0 0 var(--panel-shd),
    inset 5px 5px 0 0 var(--panel-lit),
    0 0 0 4px var(--gold), 0 0 0 8px var(--ink),
    0 12px 0 8px rgba(0,0,0,.4);
}
.logo { font-size: 34px; letter-spacing: 6px; margin-bottom: 16px;
  filter: drop-shadow(2px 2px 0 #000); }
.start-card h1 {
  font-family: 'Silver', monospace;
  font-size: 30px; line-height: 1.3; color: var(--gold);
  text-shadow: 3px 3px 0 var(--gold-dk), 5px 5px 0 #000; margin-bottom: 16px;
}
.sub { font-size: 17px; opacity: .85; margin-bottom: 18px; line-height: 1.5; }
.room-tag {
  background: var(--felt-dark); border: 3px solid var(--ink);
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.4), inset 2px 2px 0 rgba(255,255,255,.1);
  padding: 10px; margin-bottom: 14px;
  font-family: 'Silver', monospace; font-size: 19px; color: var(--gold);
}
#nameInput {
  width: 100%; padding: 12px 14px; font-size: 21px;
  font-family: 'Silver', monospace;
  border-radius: 0; border: 3px solid var(--ink); background: #0e1626;
  color: var(--text); margin-bottom: 16px; text-align: center;
  box-shadow: inset 3px 3px 0 rgba(0,0,0,.5);
}
#nameInput:focus { outline: none; border-color: var(--gold); }
#nameInput::placeholder { color: #6b6488; }
.note { font-size: 14px; opacity: .6; margin-top: 16px; line-height: 1.6; }

/* ============================================================
   โต๊ะเกม
   ============================================================ */
#table {
  display: flex; flex-direction: column;
  background:
    repeating-linear-gradient(45deg, var(--felt2) 0 12px, var(--felt) 12px 24px);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--ink);
  border-bottom: 4px solid var(--gold); flex-wrap: wrap; gap: 8px;
}
.brand { font-family: 'Silver', monospace; font-size: 19px; color: var(--gold);
  text-shadow: 2px 2px 0 #000; }
.invite { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.invite-label { font-size: 16px; opacity: .9; font-family: 'Silver', sans-serif; }
.invite-label b { color: var(--gold); font-family: 'Silver', monospace; font-size: 16px; }

.felt { flex: 1; padding: 18px; display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* dealer */
.dealer-zone {
  display: flex; gap: 18px; align-items: center;
  background: var(--felt-dark); border: 4px solid var(--ink);
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.4), inset 4px 4px 0 rgba(255,255,255,.08),
              0 5px 0 rgba(0,0,0,.35);
  padding: 14px 24px; margin-top: 4px;
}
.dealer-sprite { width: 64px; height: 80px; }
.dealer-label { font-family: 'Silver', monospace; font-size: 21px;
  margin-bottom: 10px; letter-spacing: 1px; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.val-badge {
  background: var(--ink); color: var(--gold); border: 2px solid var(--gold-dk);
  padding: 2px 8px; font-size: 17px; margin-left: 6px; font-family: 'Silver', monospace;
}
.hand { display: flex; gap: 6px; min-height: 126px; }
.card { width: 90px; height: 126px; image-rendering: pixelated;
  box-shadow: 3px 3px 0 rgba(0,0,0,.45); }

.phase-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.phase-tag {
  background: var(--gold); color: #2a1c00; font-family: 'Silver', monospace;
  padding: 5px 12px; font-size: 16px; letter-spacing: 1px;
  border: 3px solid var(--ink);
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.25), inset 2px 2px 0 rgba(255,255,255,.4);
}
.status { font-size: 18px; opacity: .95; background: rgba(0,0,0,.35);
  padding: 6px 12px; border: 2px solid var(--ink); }

/* players */
.players {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center;
  width: 100%; align-items: flex-start;
}
.player {
  background: var(--panel); border: 4px solid var(--ink); border-radius: 0;
  padding: 12px; width: 234px; min-height: 156px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: inset -4px -4px 0 var(--panel-shd), inset 4px 4px 0 var(--panel-lit),
              0 5px 0 rgba(0,0,0,.35);
}
.player.me { box-shadow: inset -4px -4px 0 var(--panel-shd), inset 4px 4px 0 var(--panel-lit),
              0 0 0 4px var(--gold), 0 5px 0 rgba(0,0,0,.35); }
.player.active { box-shadow: inset -4px -4px 0 var(--panel-shd), inset 4px 4px 0 var(--panel-lit),
              0 0 0 4px var(--green), 0 0 14px var(--green); transform: translateY(-4px); }
.player.res-win, .player.res-bj { box-shadow: inset -4px -4px 0 var(--panel-shd),
              inset 4px 4px 0 var(--panel-lit), 0 0 0 4px var(--green), 0 0 16px var(--green); }
.player.res-lose { opacity: .65; }
.p-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.p-name { font-weight: 700; font-size: 19px; }
.p-credit { color: var(--gold); font-family: 'Silver', monospace; font-size: 16px; }
.p-hand { display: flex; gap: 4px; flex-wrap: wrap; min-height: 84px; }
.p-hand .card { width: 60px; height: 84px; box-shadow: 2px 2px 0 rgba(0,0,0,.45); }
.p-info { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.p-val { opacity: .9; font-family: 'Silver', monospace; font-size: 16px; }
.p-status { font-size: 16px; font-weight: 700; }
.p-status.bust { color: var(--red); }
.p-status.blackjack { color: var(--gold); }
.p-status.ready { color: var(--green); }
.p-bet { display: flex; align-items: center; gap: 8px; font-size: 17px; min-height: 28px; }
.p-result { margin-left: auto; font-weight: 800; font-size: 17px; }

/* controls */
.controls {
  background: var(--ink); border-top: 4px solid var(--gold);
  padding: 16px; display: flex; gap: 14px; align-items: center;
  justify-content: center; flex-wrap: wrap; min-height: 78px;
}
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.chip-row { display: flex; gap: 14px; }
.chip-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.chip-wrap span { font-size: 16px; opacity: .9; font-family: 'Silver', monospace; }
.chip-btn { cursor: pointer; image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,.5)); }
.chip-btn:hover { transform: translateY(-3px); }
.chip-btn:active { transform: translateY(0); }
.chip-btn.disabled { opacity: .3; pointer-events: none; }
.hint { opacity: .85; font-size: 18px; background: rgba(255,255,255,.06);
  padding: 8px 14px; border: 2px solid #2c2745; }

@media (max-width: 640px) {
  .card { width: 64px; height: 90px; }
  .hand { min-height: 90px; }
  .player { width: 100%; max-width: 340px; }
  .brand { font-size: 15px; }
  .start-card h1 { font-size: 22px; }
  .gbtn { font-size: 16px; }
}
