:root {
  --bg: #0a0805;
  --panel: rgba(14, 11, 6, .82);
  --field: #171209;
  --gold: #d9ae4f;
  --gold-hi: #f3d98b;
  --gold-lo: #8a6a24;
  --ink: #231a05;
  --text: #f4ecd8;
  --muted: #a8998a;
  --danger: #ff8a7a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: max(11px, min(calc(100vh / 55), calc(100vw / 28.5)));
  font-size: max(11px, min(calc(100svh / 55), calc(100vw / 28.5)));
  background-color: var(--bg);
}
html, body { margin: 0; min-height: 100%; }
body {
  position: relative;
  font-family: 'Prompt', 'Noto Sans Lao', 'Noto Sans Thai', system-ui, sans-serif;
  line-height: 1.4;
  color: var(--text);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button, input, select { font: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }

/* พื้นหลังรูป Photo_.webp ตรึงเต็มจอ */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(10,8,5,.10), rgba(10,8,5,.35)),
    url('Photo_.webp') center center / cover no-repeat,
    radial-gradient(ellipse at 50% 0%, #3a2d10 0%, #0a0805 65%);
  background-color: var(--bg);
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

.frame, .card {
  position: relative;
  width: 100%;
  max-width: 26rem;
  padding: 1.5rem 1.25rem 1.25rem;
  background: var(--panel);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--gold-lo);
  border-radius: 1.6rem;
  box-shadow: 0 0 0 .25rem rgba(217,174,79,.08), 0 1.5rem 4rem rgba(0,0,0,.65);
}
.frame::before, .card::before {
  content: "";
  position: absolute;
  inset: .4rem;
  border: 1px solid rgba(217,174,79,.35);
  border-radius: 1.25rem;
  pointer-events: none;
}

.topbar { display: flex; justify-content: flex-end; margin-bottom: .25rem; }
.lang-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border: 1px solid var(--gold-lo);
  border-radius: 50%;
  background: var(--field);
  color: var(--gold-hi);
  cursor: pointer;
}
.lang-btn svg { width: 1.4rem; height: 1.4rem; }

.brand { text-align: center; margin-bottom: 1.1rem; }
.wordmark {
  margin: 0;
  font-family: 'Cinzel', 'Prompt', serif;
  font-weight: 700;
  font-size: 3.2rem;
  line-height: 1.1;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff0b8 0%, var(--gold) 50%, var(--gold-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 .1rem .5rem rgba(217,174,79,.35));
}
.tagline {
  margin: .4rem 0 0;
  font-size: .95rem;
  color: var(--gold-hi);
  word-break: break-word;
}

.form-title { margin: 0; text-align: center; font-size: 1.25rem; font-weight: 600; color: var(--gold-hi); }
.rule {
  height: 1px;
  margin: .75rem 0 1.1rem;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.field {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: none;
  height: 3.5rem;
  margin-bottom: .85rem;
  padding: 0 .5rem;
  background: var(--field);
  border: 1px solid var(--gold-lo);
  border-radius: 999px;
}
.field:focus-within {
  border-color: var(--gold-hi);
  box-shadow: 0 0 0 2px rgba(243,217,139,.35);
}
.ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  color: var(--ink);
}
.ico svg { width: 1.4rem; height: 1.4rem; }
.field input, .field select {
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: max(16px, 1.05rem);
  outline: 0;
}
.field input { flex: 1; }
.field input::placeholder { color: var(--muted); }
.field select {
  flex: none;
  width: 4.2rem;
  padding-right: .4rem;
  -webkit-appearance: none;
  appearance: none;
  color: var(--gold-hi);
  font-weight: 500;
  border-right: 1px solid rgba(217,174,79,.35);
}
.field select option { color: #111; background: #fff; }

.eye {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}
.eye svg { width: 1.4rem; height: 1.4rem; }
.eye .slash { display: none; }
.eye.on .slash { display: block; }

.badge {
  flex: none;
  padding: .45rem .75rem;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  color: var(--ink);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}

.error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  margin: 0 0 .4rem;
  overflow: hidden;
  font-size: .875rem;
  line-height: 1.35;
  text-align: center;
  word-break: break-word;
  color: var(--danger);
}

.submit {
  display: block;
  flex: none;
  width: 100%;
  height: 3.6rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff0b8 0%, var(--gold) 50%, var(--gold-lo) 100%);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 .4rem 1.1rem rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.5);
}
.submit:active { filter: brightness(.92); }
.submit:disabled { opacity: .6; cursor: wait; }

.switch {
  display: block;
  flex: none;
  width: 100%;
  min-height: 3rem;
  margin-top: .85rem;
  padding: .5rem .9rem;
  border: 1px solid var(--gold-lo);
  border-radius: 999px;
  background: rgba(10,8,5,.6);
  color: var(--text);
  font-size: .95rem;
  line-height: 1.35;
  cursor: pointer;
}
.switch b { color: var(--gold-hi); font-weight: 600; }

button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

.lang-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0,0,0,.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.lang-sheet {
  width: min(100%, 21rem);
  padding: 1.25rem 1rem 1rem;
  background: #14110b;
  border: 1px solid var(--gold-lo);
  border-radius: 1.5rem;
  box-shadow: 0 0 0 .25rem rgba(217,174,79,.08), 0 1.7rem 4.4rem rgba(0,0,0,.7);
}
.lang-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-bottom: .4rem;
  color: var(--gold-hi);
  font-size: 1rem;
  font-weight: 600;
}
.lang-title svg { flex: none; width: 1.4rem; height: 1.4rem; }
.lang-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 3.4rem;
  margin-top: .65rem;
  padding: 0 1.25rem;
  border: 1px solid var(--gold-lo);
  border-radius: 999px;
  background: var(--field);
  color: var(--text);
  font-size: max(16px, 1.05rem);
  cursor: pointer;
}
.lang-opt.on {
  border-color: transparent;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  color: var(--ink);
  font-weight: 600;
}
.lang-opt .tick { width: 1.25rem; text-align: center; font-style: normal; }
.lang-opt.on .tick::before { content: '✓'; }

.lobby { text-align: center; }
.lobby h1 { margin: 0 0 .4rem; font-size: 1.4rem; font-weight: 600; color: var(--gold-hi); overflow-wrap: anywhere; }
.balance { margin: .5rem 0 1.25rem; font-size: 2.5rem; font-weight: 600; color: var(--gold-hi); }
.balance small { display: block; font-size: .9rem; font-weight: 400; color: var(--muted); }
.ghost {
  height: 2.8rem;
  padding: 0 1.4rem;
  border: 1px solid var(--gold-lo);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}