/* =========================================================
   BMW CORPORATE DESIGN SYSTEM — TYPEMASTER
   Strictly aligned with DESIGN.md specifications
   ========================================================= */

:root {
  /* Brand & Accent */
  --primary: #1c69d4;
  /* BMW Corporate Blue */
  --primary-active: #0653b6;
  --m-blue-light: #0066b1;
  /* M Tricolor Light Blue */
  --m-blue-dark: #1c69d4;
  /* M Tricolor Dark Blue */
  --m-red: #e22718;
  /* M Tricolor Red */

  /* Surface Hierarchy */
  --canvas: #ffffff;
  /* Default page surface */
  --surface-soft: #f7f7f7;
  /* Footer & sub-nav */
  --surface-card: #fafafa;
  /* Soft grey plate behind photos */
  --surface-strong: #ebebeb;
  /* Heavier grey divider */
  --surface-dark: #1a2129;
  /* Dark navy for hero bands */
  --surface-dark-elevated: #262e38;
  /* Nested cards on dark hero */

  /* Hairlines */
  --hairline: #e6e6e6;
  /* 1px divider */
  --hairline-strong: #cccccc;
  /* More visible 1px outline */

  /* Text & Ink */
  --ink: #262626;
  /* Primary headline text */
  --body: #3c3c3c;
  /* Default running body text */
  --body-strong: #1a1a1a;
  /* Emphasized body */
  --muted: #6b6b6b;
  /* Captions, subtext, breadcrumbs */
  --muted-soft: #9a9a9a;
  /* Disabled, legal fine-print */
  --on-primary: #ffffff;
  /* White text on BMW blue */
  --on-dark: #ffffff;
  /* White text on dark hero */
  --on-dark-soft: #bbbbbb;
  /* Secondary text on dark bands */

  /* Semantic */
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #dc2626;

  /* Finger Guides (Calibrated for clean light UI) */
  --pl: #e63946;
  --rl: #f77f00;
  --ml: #fcbf49;
  --il: #2a9d8f;
  --ir: #0077b6;
  --mr: #4361ee;
  --rr: #7209b7;
  --pr: #d90429;
  --th: #6c757d;

  /* Typography Sizes & Heights */
  --fs: 26px;

  /* Shapes: Rectangular for everything, strictly 0px per DESIGN.md */
  --radius: 0px;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--canvas);
  color: var(--body);
  font-family: 'Inter', 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  /* Light 300 signature per DESIGN.md */
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
b,
strong,
th {
  font-family: 'Inter', 'IBM Plex Sans Thai', system-ui, sans-serif;
  font-weight: 700;
  /* Heavy 700 display signature per DESIGN.md */
  color: var(--ink);
}

button {
  font-family: 'Inter', 'IBM Plex Sans Thai', system-ui, sans-serif;
  cursor: pointer;
  border-radius: 0px;
  /* Rectangular, 0px radius */
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================================================
   BRAND SIGNATURE: M TRICOLOR STRIPE (4px height)
   ========================================================= */
.m-stripe-divider {
  height: 4px;
  width: 100%;
  display: flex;
  overflow: hidden;
}

.m-stripe-divider .s1 {
  flex: 1;
  background: var(--m-blue-light);
}

.m-stripe-divider .s2 {
  flex: 1;
  background: var(--m-blue-dark);
}

.m-stripe-divider .s3 {
  flex: 1;
  background: var(--m-red);
}

/* =========================================================
   TOP NAVIGATION (64px tall, canvas white, 1px hairline)
   ========================================================= */
header.top-nav {
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
}

.hwrap {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--ink);
  text-transform: uppercase;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--surface-dark);
  color: var(--on-dark);
  font-size: 16px;
  border-radius: 50%;
  /* Only circular exception for icon logo */
}

.logo span {
  color: var(--primary);
  font-weight: 700;
}

.logo small {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
  display: block;
  font-weight: 400;
  line-height: 1;
}

/* Category Navigation / Menu */
nav {
  display: flex;
  height: 100%;
  margin-left: auto;
  gap: 4px;
}

nav button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0 16px;
  height: 100%;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s;
  border-radius: 0px;
}

nav button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

nav button.on {
  color: var(--ink);
  border-bottom: 2px solid var(--primary);
  /* Blue indicator line */
  background: transparent;
}

/* Language Switcher */
.langsw {
  display: flex;
  border: 1px solid var(--hairline-strong);
  border-radius: 0px;
}

.langsw button {
  background: var(--canvas);
  border: 0;
  color: var(--muted);
  padding: 7px 14px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  border-radius: 0px;
}

.langsw button:hover {
  color: var(--ink);
}

.langsw button.on {
  background: var(--surface-dark);
  color: var(--on-dark);
}

/* =========================================================
   HERO BAND (Dark Navy #1a2129 — BMW Corporate Pattern)
   ========================================================= */
.hero-band-dark {
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: 56px 24px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-wrap {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 40px;
  align-items: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 12px;
}

.hero-tag::before {
  content: '';
  width: 12px;
  height: 2px;
  background: var(--primary);
}

.hero-title {
  font-size: 46px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--on-dark);
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}

.hero-title span {
  color: var(--primary);
}

.hero-desc {
  font-size: 16px;
  font-weight: 300;
  /* Light 300 body signature */
  color: var(--on-dark-soft);
  line-height: 1.6;
  max-width: 580px;
  margin-bottom: 24px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* Telemetry Spec Cells (Right side of hero) */
.hero-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  background: var(--surface-dark-elevated);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0px;
}

.spec-cell {
  padding: 8px 12px;
  border-left: 2px solid var(--primary);
}

.spec-val {
  font-size: 28px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--on-dark);
  line-height: 1.1;
}

.spec-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--on-dark-soft);
  margin-top: 4px;
}

/* =========================================================
   MAIN CONTENT AREA & SECTION RHYTHM
   ========================================================= */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 24px 60px;
}

.view {
  display: none;
  scroll-margin-top: 72px;
}

.view.on {
  display: block;
}

.section-head {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 16px;
}

.section-tag {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary);
  margin-bottom: 4px;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.section-desc {
  font-size: 15px;
  font-weight: 300;
  color: var(--muted);
  max-width: 720px;
  margin-top: 6px;
}

/* =========================================================
   CATEGORY FILTER TABS (category-tab / category-tab-active)
   ========================================================= */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 24px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--hairline);
}

.category-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  border-radius: 0px;
}

.category-tab:hover {
  color: var(--ink);
}

.category-tab.active {
  color: var(--ink);
  border-bottom-color: var(--primary);
}

/* =========================================================
   MODEL CARDS GRID (4-up on desktop, 2-up tablet, 1-up mobile)
   User requested: "เมนูตรงนี้ทำเป็นรูปภาพสวยๆได้ไหม"
   ========================================================= */
.lgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 1200px) {
  .lgrid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 860px) {
  .lgrid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .lgrid {
    grid-template-columns: 1fr;
  }
}

/* The Signature Model Card */
.model-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 0px;
  /* 0px corner radius per DESIGN.md */
  display: flex;
  flex-direction: column;
  text-align: left;
  position: relative;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
  cursor: pointer;
  height: 100%;
}

.model-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.06);
}

.model-card.done {
  border-left: 3px solid var(--success);
}

/* Model Card Photo Plate (Aspect Ratio ~ 16:10, Edge-to-Edge) */
.model-card-photo {
  background: var(--surface-card);
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
}

.model-card-photo svg,
.model-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.model-card:hover .model-card-photo svg,
.model-card:hover .model-card-photo img {
  transform: scale(1.04);
}

/* Module Badge Watermark on Photo */
.photo-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(26, 33, 41, 0.88);
  color: var(--on-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 0px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  font-family: 'JetBrains Mono', monospace;
}

.photo-status {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--success);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 0px;
}

/* Model Card Body Content */
.model-card-body {
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.model-card-category {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary);
  margin-bottom: 4px;
}

.model-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 6px;
}

.model-card-sub {
  font-size: 13px;
  font-weight: 300;
  /* Light 300 */
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
  flex: 1;
}

/* Keychips on Card */
.keychips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}

.keychips i {
  font-style: normal;
  background: var(--surface-soft);
  border: 1px solid var(--hairline-strong);
  border-radius: 0px;
  padding: 2px 7px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink);
  font-weight: 600;
}

/* Button Text Link ("LEARN MORE ›" per DESIGN.md) */
.button-text-link {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--hairline);
  transition: gap 0.15s, color 0.15s;
}

.model-card:hover .button-text-link {
  color: var(--primary-active);
  gap: 8px;
}

/* =========================================================
   STANDARD BMW BUTTONS (Rectangular 0px Corners)
   ========================================================= */
.btn {
  background: var(--primary);
  color: var(--on-primary);
  border: 0;
  padding: 14px 28px;
  height: 48px;
  border-radius: 0px;
  /* 0px corner radius */
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, filter 0.15s;
}

.btn:hover {
  background: var(--primary-active);
}

.btn.g {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
}

.btn.g:hover {
  background: var(--surface-strong);
}

.btn.o {
  background: transparent;
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
}

.btn.o:hover {
  background: var(--surface-soft);
}

.btn.secondary-on-dark {
  background: transparent;
  border: 1px solid var(--on-dark);
  color: var(--on-dark);
}

.btn.secondary-on-dark:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Form Controls */
select,
input[type=number],
textarea {
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  border-radius: 0px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  height: 44px;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--ink);
}

textarea {
  height: auto;
}

label.sw {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--body);
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  padding: 10px 14px;
  border-radius: 0px;
  cursor: pointer;
}

label.sw input {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  border-radius: 0px;
}

/* =========================================================
   CARDS & SHEETS
   ========================================================= */
.card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 0px;
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sub {
  color: var(--muted);
  font-size: 14px;
  font-weight: 300;
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* =========================================================
   TYPING ENGINE & WORKSPACE (COMPACT COCKPIT DESIGN)
   ========================================================= */
.practice-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}

.practice-title-group {
  display: flex;
  flex-direction: column;
}

.practice-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.typing-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.typing-main {
  flex: 1;
  min-width: 0;
}

.typing-sidebar {
  width: 220px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .typing-layout {
    flex-direction: column;
  }

  .typing-layout>.typing-sidebar {
    order: -1;
    width: 100%;
  }

  .stats.vertical {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stats.vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
}

.st {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--primary);
  border-radius: 0px;
  padding: 8px 14px;
  min-width: 95px;
  flex: 1;
}

.st b {
  display: block;
  font-size: 20px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink);
  line-height: 1.1;
}

.st small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 2px;
  display: block;
}

#textbox {
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: 0px;
  padding: 14px 18px;
  font-size: var(--fs);
  line-height: 1.7;
  max-height: 140px;
  min-height: 100px;
  overflow-y: auto;
  letter-spacing: 0.5px;
  font-family: 'Inter', 'IBM Plex Sans Thai', 'JetBrains Mono', monospace;
  word-break: break-word;
  color: var(--muted);
  text-align: center;
  position: relative;
  scroll-behavior: smooth;
}

#textbox::-webkit-scrollbar {
  width: 6px;
}

#textbox::-webkit-scrollbar-track {
  background: transparent;
}

#textbox::-webkit-scrollbar-thumb {
  background: #cfd6df;
  border-radius: 0px;
}

#textbox::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

#textbox.en {
  font-family: 'JetBrains Mono', monospace;
}

.cl {
  border-radius: 0px;
  padding: 1px 0;
  transition: 0.08s;
  color: #8a96a3;
}

.cl.ok {
  color: var(--ink);
  font-weight: 600;
}

.cl.bad {
  color: var(--error);
  background: #fee2e2;
  text-decoration: underline wavy var(--error);
}

.cl.cur {
  background: var(--primary);
  color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(28, 105, 212, 0.3);
}

.cl.sp {
  display: inline-block;
  min-width: 0.6em;
}

.cl.sp.cur {
  background: rgba(28, 105, 212, 0.15);
  box-shadow: none;
  border-bottom: 3px solid var(--primary);
}

.hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 4px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  border-radius: 0px;
}

.nextkey {
  background: var(--canvas);
  border: 2px solid var(--primary);
  border-radius: 0px;
  min-width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.fingertag {
  font-size: 13px;
  color: var(--body);
  line-height: 1.3;
}

.bar {
  height: 5px;
  background: var(--hairline);
  border-radius: 0px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.2s;
}

/* =========================================================
   VIRTUAL KEYBOARD (Precision German Engineering Style)
   ========================================================= */
.kb {
  margin-top: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--hairline-strong);
  border-radius: 0px;
  padding: 6px;
  user-select: none;
}

.krow {
  display: flex;
  gap: 3px;
  margin-bottom: 3px;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  height: 35px;
  background: var(--canvas);
  border: 1px solid #d4d8de;
  border-bottom: 2px solid #b8c0cc;
  border-radius: 0px;
  /* 0px corners */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: 'IBM Plex Sans Thai', monospace;
  position: relative;
  transition: all 0.07s;
  color: var(--ink);
  overflow: hidden;
}

.key u {
  font-style: normal;
  text-decoration: none;
  font-size: 8px;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
}

.key s {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

.key.w15 {
  flex-grow: 1.5;
}

.key.w175 {
  flex-grow: 1.75;
}

.key.w2 {
  flex-grow: 2;
}

.key.w225 {
  flex-grow: 2.25;
}

.key.w275 {
  flex-grow: 2.75;
}

.key.w6 {
  flex-grow: 6.5;
}

.key.hi {
  background: var(--primary);
  color: #ffffff;
  border-color: #0b4ca8;
  border-bottom-width: 1px;
  transform: translateY(1px);
}

.key.hi u {
  color: #e0edff;
}

.key.press {
  background: #d6e4f8;
  border-color: var(--primary);
}

.key.err {
  background: var(--error);
  color: #ffffff;
}

.key .fg {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  height: 3px;
  border-radius: 0px;
  opacity: 0.9;
}

.hm {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

/* =========================================================
   WORD DROP GAME (High-Precision Cockpit Cyber Arena)
   ========================================================= */
.game-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}

.game-title-group {
  display: flex;
  flex-direction: column;
}

.game-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.game-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.game-stats .st {
  padding: 6px 12px;
  min-width: 85px;
}

.game-stats .st b {
  font-size: 18px;
}

.game-stats .st small {
  font-size: 9px;
  margin-top: 1px;
}

#gamearea {
  position: relative;
  height: 450px;
  background: radial-gradient(ellipse at 50% 25%, #182232 0%, #0a0e17 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0px;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
  user-select: none;
}

/* Background Cyber Grid */
#ggrid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(28, 105, 212, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(28, 105, 212, 0.05) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.8;
}

/* Screen Shake Disabled (ตามคำขอของผู้ใช้: ไม่ต้องสั่นจอ) */
#gamearea.arena-shake {
  animation: none !important;
  transform: none !important;
}

/* Screen Red Damage Flash Vignette */
#gflash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.4) 0%, rgba(220, 38, 38, 0.85) 100%);
  opacity: 0;
  z-index: 15;
  transition: opacity 0.04s;
}

#gflash.flash-red {
  animation: flashFade 0.4s ease-out forwards;
}

@keyframes flashFade {
  0% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
  }
}

/* Hazardous Zone below Laser Line */
#gdangerzone {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: linear-gradient(to bottom, rgba(239, 68, 68, 0.28) 0%, rgba(239, 68, 68, 0.05) 100%);
  pointer-events: none;
  border-top: 1px dashed rgba(239, 68, 68, 0.4);
}

/* Falling Words */
.word {
  position: absolute;
  padding: 8px 18px;
  background: #172130;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0px;
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  color: #f1f5f9;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font-family: 'JetBrains Mono', 'IBM Plex Sans Thai', monospace;
  letter-spacing: 0.5px;
  will-change: transform;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
  z-index: 5;
}

/* Target Locked Word */
.word.lock {
  border-color: #38bdf8;
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.75), inset 0 0 8px rgba(56, 189, 248, 0.25);
  background: #10263f;
  color: #ffffff;
}

.word .hit {
  color: #38bdf8;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

/* DANGER EFFECT: Approaching or crossing the line (สั่นแรงและเป็นสีแดง) */
.word.danger {
  background: rgba(220, 38, 38, 0.92) !important;
  border-color: #ff3344 !important;
  color: #ffffff !important;
  box-shadow: 0 0 28px rgba(255, 51, 68, 0.95), inset 0 0 12px rgba(255, 255, 255, 0.4) !important;
  animation: dangerShake 0.12s infinite alternate ease-in-out !important;
}

.word.danger .hit {
  color: #fef08a !important;
  text-shadow: 0 0 10px #fef08a;
}

@keyframes dangerShake {
  0% {
    transform: translate(var(--wx), var(--wy)) rotate(-1.5deg);
  }

  50% {
    transform: translate(calc(var(--wx) + 4px), calc(var(--wy) - 2px)) rotate(1.5deg);
  }

  100% {
    transform: translate(calc(var(--wx) - 4px), calc(var(--wy) + 1px)) rotate(-1.5deg);
  }
}

/* Typo Error Wiggle */
.word.typo-wiggle {
  animation: typoWiggle 0.18s ease-in-out !important;
}

@keyframes typoWiggle {

  0%,
  100% {
    transform: translate(var(--wx), var(--wy));
  }

  25% {
    transform: translate(calc(var(--wx) - 8px), var(--wy));
    border-color: #ef4444;
  }

  75% {
    transform: translate(calc(var(--wx) + 8px), var(--wy));
    border-color: #ef4444;
  }
}

/* Word Destroy Explosion */
.word.boom {
  animation: wordBoom 0.28s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes wordBoom {
  0% {
    transform: translate(var(--wx), var(--wy)) scale(1);
    opacity: 1;
    filter: brightness(1.8);
  }

  100% {
    transform: translate(var(--wx), var(--wy)) scale(1.65);
    opacity: 0;
    filter: brightness(3);
  }
}

/* Laser Defense Line */
#gline {
  position: absolute;
  bottom: 56px;
  left: 0;
  right: 0;
  height: 3px;
  background: #ff2a3b;
  box-shadow: 0 0 14px #ff2a3b, 0 0 28px rgba(255, 42, 59, 0.8), 0 0 45px rgba(255, 42, 59, 0.4);
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 16px;
}

.gline-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #ffa3aa;
  text-shadow: 0 0 8px rgba(255, 42, 59, 0.8);
  transform: translateY(-13px);
  user-select: none;
}

#gline.danger-active {
  background: #ff001e;
  box-shadow: 0 0 24px #ff001e, 0 0 50px rgba(255, 0, 30, 0.95), 0 0 80px rgba(255, 0, 30, 0.6);
  animation: laserPulse 0.14s infinite alternate;
}

@keyframes laserPulse {
  from {
    filter: brightness(1);
  }

  to {
    filter: brightness(1.7);
  }
}

/* Floating Scores & Impacts */
.float-score {
  position: absolute;
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: #38bdf8;
  text-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
  z-index: 12;
  animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0;
  }

  25% {
    transform: translateY(-12px) scale(1.15);
    opacity: 1;
  }

  100% {
    transform: translateY(-44px) scale(1);
    opacity: 0;
  }
}

.float-damage {
  position: absolute;
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: #ff3344;
  text-shadow: 0 0 16px rgba(255, 51, 68, 0.95);
  z-index: 12;
  animation: floatDamage 0.85s ease-out forwards;
}

@keyframes floatDamage {
  0% {
    transform: translateY(0) scale(0.7);
    opacity: 0;
  }

  20% {
    transform: translateY(-10px) scale(1.3);
    opacity: 1;
  }

  100% {
    transform: translateY(-38px) scale(0.9);
    opacity: 0;
  }
}

/* Combo Announcement Banner */
.combo-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: rgba(14, 21, 33, 0.95);
  border: 1px solid var(--primary);
  box-shadow: 0 0 25px rgba(28, 105, 212, 0.6);
  padding: 8px 24px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', sans-serif;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-banner.show {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

/* Active Cyber Input Terminal */
#gbuf {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #111a26;
  border: 1px solid var(--primary);
  box-shadow: 0 0 16px rgba(28, 105, 212, 0.4);
  border-radius: 0px;
  padding: 7px 20px;
  font-size: 18px;
  font-weight: 600;
  min-width: 220px;
  text-align: center;
  color: #38bdf8;
  font-family: 'JetBrains Mono', 'IBM Plex Sans Thai', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 9;
}

#gbuf .buf-icon {
  font-size: 14px;
  opacity: 0.6;
}

#gbuf .buf-cursor {
  animation: cursorBlink 0.8s infinite;
  color: var(--primary);
}

@keyframes cursorBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* OVERLAY SCREEN: Start Cockpit & Game Over */
#gover {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 23, 0.94);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 25;
  padding: 24px;
}

#gover.show-start,
#gover.show-end {
  display: flex;
}

.go-panel {
  max-width: 520px;
  width: 100%;
  background: #141c28;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(28, 105, 212, 0.2);
  padding: 18px 24px;
  text-align: center;
  position: relative;
}

.go-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 10px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.go-panel h2 {
  color: #ffffff;
  font-size: 20px;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.go-panel .sub {
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.go-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  text-align: left;
}

@media (max-width: 600px) {
  .go-features {
    grid-template-columns: 1fr;
  }
}

.go-feat {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #0f1621;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.35;
}

.go-feat b {
  color: #ffffff;
  display: block;
  font-size: 11px;
  margin-bottom: 1px;
}

.go-feat-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.btn-huge-start {
  background: var(--primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 0 24px;
  height: 42px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(28, 105, 212, 0.5);
  transition: all 0.2s;
  border: none;
}

.btn-huge-start:hover {
  background: #2579ea;
  box-shadow: 0 6px 32px rgba(28, 105, 212, 0.8);
  transform: translateY(-2px);
}

.go-hint {
  margin-top: 14px;
  font-size: 12px;
  color: #64748b;
  font-family: 'JetBrains Mono', 'IBM Plex Sans Thai', monospace;
}

/* Header Start Button */
.btn-start-primary {
  background: #16a34a;
  color: #ffffff;
  height: 40px;
  padding: 0 20px;
  font-size: 13px;
  letter-spacing: 1px;
  box-shadow: 0 2px 12px rgba(22, 163, 74, 0.35);
}

.btn-start-primary:hover {
  background: #15803d;
}

/* Game Status Badge */
.game-status-badge {
  font-family: 'JetBrains Mono', 'IBM Plex Sans Thai', monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--hairline-strong);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.game-status-badge.running {
  background: rgba(22, 163, 74, 0.1);
  border-color: #22c55e;
  color: #15803d;
}

.game-status-badge.paused {
  background: rgba(245, 158, 11, 0.1);
  border-color: #f59e0b;
  color: #b45309;
}

/* Lives shaking */
.lives-shake {
  animation: livesShake 0.35s ease-in-out;
  color: #ef4444 !important;
}

@keyframes livesShake {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.35);
    filter: drop-shadow(0 0 10px #ef4444);
  }
}

.lives i {
  font-style: normal;
  color: var(--error);
  font-size: 20px;
}

/* =========================================================
   STATS & TELEMETRY
   ========================================================= */
.hbars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 130px;
  padding-top: 14px;
  background: var(--surface-card);
  padding: 16px;
  border: 1px solid var(--hairline);
}

.hbars div {
  flex: 1;
  background: var(--primary);
  border-radius: 0px;
  min-height: 4px;
  position: relative;
  transition: background 0.15s;
}

.hbars div:hover {
  background: var(--primary-active);
}

.hbars div span {
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
}

.errlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.errlist .e {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 6px 10px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
}

.errlist .e b {
  width: 48px;
  text-align: center;
  background: var(--canvas);
  border: 1px solid var(--hairline-strong);
  border-radius: 0px;
  padding: 3px 6px;
  font-family: 'JetBrains Mono', monospace;
}

.errlist .e i {
  height: 8px;
  background: var(--error);
  border-radius: 0px;
  display: block;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
}

th {
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--surface-soft);
}

.tip {
  background: var(--surface-card);
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0px;
  font-size: 13px;
  color: var(--body);
  line-height: 1.7;
}

/* =========================================================
   FOOTER (Soft Grey #f7f7f7 — DESIGN.md Specification)
   ========================================================= */
footer.corporate-footer {
  background: var(--surface-soft);
  border-top: 1px solid var(--hairline);
  color: var(--body);
  padding: 64px 24px 40px;
  margin-top: 60px;
}

.footer-wrap {
  max-width: 1440px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 40px;
  margin-bottom: 48px;
}

@media (max-width: 860px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

.footer-col h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink);
  margin-bottom: 16px;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-col a {
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
  transition: color 0.15s;
}

.footer-col a:hover {
  color: var(--primary);
}

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  font-weight: 300;
  color: var(--muted-soft);
}

/* =========================================================
   RESPONSIVE BREAKPOINTS
   ========================================================= */
@media (max-width: 900px) {
  .hero-wrap {
    grid-template-columns: 1fr;
  }

  .hero-title {
    font-size: 34px;
  }
}

@media (max-width: 700px) {
  :root {
    --fs: 20px;
  }

  .key {
    height: 32px;
    font-size: 10px;
  }

  .key s {
    font-size: 11px;
  }

  nav button {
    padding: 0 10px;
    font-size: 12px;
  }
}