@font-face { font-family: 'Kanit'; font-weight: 400; font-display: swap; src: url(../fonts/kanit-thai-400-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Kanit'; font-weight: 400; font-display: swap; src: url(../fonts/kanit-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-21FF; }
@font-face { font-family: 'Kanit'; font-weight: 600; font-display: swap; src: url(../fonts/kanit-thai-600-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Kanit'; font-weight: 600; font-display: swap; src: url(../fonts/kanit-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-21FF; }

:root {
  --bg: rgba(14, 15, 20, 0.82);
  --line: rgba(255, 255, 255, 0.09);
  --txt: #e9ecf2;
  --mute: #8b93a3;
  --acc: #4cc3ff;
  --acc2: #ff4f6d;
  --r: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a0b0e; color: var(--txt);
  font-family: 'Kanit', 'Noto Sans Thai', 'Sarabun', Tahoma, sans-serif; -webkit-tap-highlight-color: transparent; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 9px; padding: 7px 12px; cursor: pointer; transition: .15s; }
button:hover { background: rgba(255,255,255,0.12); }
button.on { background: var(--acc); color: #04121c; border-color: var(--acc); font-weight: 600; }

#topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: linear-gradient(#0a0b0ee6, #0a0b0e00); z-index: 5; flex-wrap: wrap; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.brand { font-weight: 600; letter-spacing: 3px; font-size: 18px; }
.brand .logo { color: var(--acc); }
.brand .logo2 { color: #fff; margin-left: 6px; opacity: .85; }
.seg { display: inline-flex; background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; }
.seg button.on { background: var(--acc); }
.seg.small button { padding: 5px 9px; font-size: 13px; }
.tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

#panel { position: fixed; top: 64px; left: 14px; bottom: 14px; width: 360px; background: var(--bg); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; z-index: 4; overflow: hidden; }
#panelToggle { display: none; }
#tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
#tabs button { padding: 6px 2px; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 9px; }
#tabs button b { font-size: 17px; font-weight: 400; }
#tabBody { overflow-y: auto; padding: 12px 14px 24px; flex: 1; }
#tabBody::-webkit-scrollbar { width: 6px; } #tabBody::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
h3 { margin: 14px 0 8px; font-size: 14px; font-weight: 600; color: var(--acc); letter-spacing: .5px; }
h3:first-child { margin-top: 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; font-size: 14px; }
.row label { color: #c9ceda; }
.row .val { color: var(--acc); font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
input[type=range] { width: 100%; accent-color: var(--acc); }
.rangewrap { margin: 4px 0 10px; }
.rangewrap .row { margin: 0; }
select, input[type=text] { width: 100%; background: rgba(0,0,0,0.4); color: var(--txt); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; }
input[type=color] { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: none; padding: 2px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 6px 0 10px; }
.swatches button { aspect-ratio: 1; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); }
.swatches button.on { outline: 2px solid var(--acc); outline-offset: 2px; }
.cards { display: grid; grid-template-columns: 1fr; gap: 8px; }
.cards.two { grid-template-columns: 1fr 1fr; }
.card { text-align: left; padding: 10px 12px; border-radius: 12px; }
.card .t { font-weight: 600; font-size: 14px; }
.card .s { font-size: 12px; color: var(--mute); }
.card.on .s { color: #0b2a3a; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.chips button { font-size: 13px; padding: 6px 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; font-size: 14px; }
.switch { width: 44px; height: 24px; border-radius: 12px; background: #333; position: relative; border: 0; padding: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; }
.switch.on { background: var(--acc); }
.switch.on::after { left: 23px; }
.fit { background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.6; margin-top: 8px; }
.warn { color: #ffb347; }
.bad { color: var(--acc2); }
.ok { color: #61e294; }
.note { font-size: 12px; color: var(--mute); line-height: 1.5; }
.saves { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.saves .item { display: flex; gap: 6px; align-items: center; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.saves .item span { flex: 1; font-size: 13px; }
.saves .item i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

#hud { position: fixed; right: 18px; bottom: 18px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.speedo { font-size: 64px; font-weight: 600; line-height: 1; text-shadow: 0 2px 12px #000a; }
.speedo small { font-size: 14px; margin-left: 6px; color: var(--mute); }
.gear { display: flex; align-items: center; gap: 10px; }
.gear span { font-size: 26px; font-weight: 600; color: var(--acc); width: 30px; text-align: center; }
.rpm { width: 200px; height: 8px; background: #0008; border-radius: 4px; overflow: hidden; }
.rpm i { display: block; height: 100%; width: 10%; background: linear-gradient(90deg, var(--acc), #ffd84c 70%, var(--acc2)); }
.drivebtns { display: flex; gap: 6px; }
.help { font-size: 12px; color: #cfd5e0; background: #0008; padding: 6px 10px; border-radius: 8px; max-width: 520px; text-align: right; }
#touch { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; pointer-events: none; display: flex; justify-content: space-between; padding: 16px; }
#touch > div { display: flex; gap: 12px; pointer-events: auto; align-items: flex-end; }
#touch button { width: 74px; height: 74px; border-radius: 50%; font-size: 24px; background: rgba(255,255,255,0.12); backdrop-filter: blur(6px); user-select: none; -webkit-user-select: none; touch-action: none; }
#touch button.gas { width: 86px; height: 86px; background: rgba(76,195,255,0.35); }
#touch button.small { width: 56px; height: 56px; font-size: 18px; }
#touch button.press { background: var(--acc); color: #000; }

#toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: #000c; border: 1px solid var(--line); padding: 8px 16px; border-radius: 10px; font-size: 14px; z-index: 9; opacity: 0; transition: .25s; pointer-events: none; }
#toast.show { opacity: 1; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #0a0b0e; z-index: 20; font-size: 18px; color: var(--acc); letter-spacing: 1px; }
#loading.hide { opacity: 0; pointer-events: none; transition: .5s; }

body.driving #panel { display: none; }

@media (max-width: 820px) {
  #topbar { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 15px; }
  .tools { margin-left: 0; width: 100%; }
  #camSeg { order: 3; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 48vh; border-radius: 16px 16px 0 0; transition: transform .25s; }
  #panel.collapsed { transform: translateY(calc(100% - 44px)); }
  #panelToggle { display: block; border: 0; border-radius: 0; background: transparent; padding: 10px; color: var(--acc); }
  #tabs { grid-template-columns: repeat(9, 1fr); overflow-x: auto; }
  #tabs button span { display: none; }
  .help { display: none; }
  .speedo { font-size: 44px; }
  #hud { top: 104px; bottom: auto; }
}
#credit { position: fixed; right: 12px; bottom: 8px; z-index: 3; font-size: 11px; color: #9aa3b2; text-decoration: none; background: #0007; padding: 3px 8px; border-radius: 6px; }
body.driving #credit { bottom: auto; top: 58px; }
@media (max-width: 820px) { #credit { bottom: auto; top: 100px; right: 8px; } }

#cityHud { position: fixed; left: 14px; bottom: 14px; z-index: 4; display: flex; flex-direction: column; gap: 8px; width: 190px; }
#minimap { width: 190px; height: 190px; border-radius: 50%; box-shadow: 0 4px 18px #0009; }
.cityctl { background: var(--bg); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.cityctl .row2 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.cityctl button { padding: 4px 8px; font-size: 12px; }
.cityctl select { padding: 5px 8px; font-size: 13px; }
body.city #panel { display: none; }

@font-face { font-family: 'VG JP'; font-weight: 700; font-display: swap; src: url(../fonts/jp-signs.woff2) format('woff2'); }

.mobileonly { display: none; }
#rotateHint { display: none; }
@media (max-width: 820px), (pointer: coarse) {
  .mobileonly { display: block; }
  #cityHud { top: 64px; bottom: auto; left: 8px; width: 150px; }
  #minimap { width: 120px; height: 120px; }
  #cityHud .cityctl { display: none; width: 190px; }
  #cityHud.open .cityctl { display: flex; }
  #btnCityMenu { font-size: 12px; padding: 5px 8px; width: max-content; }
  body.driving #camSeg, body.driving #btnRotate, body.driving #btnShot { display: none; }
  body.driving #topbar { padding: 6px 8px; }
  body.driving .brand { display: none; }
  body.driving .help { display: none; }
  body.driving #hud { top: auto; bottom: 120px; right: 12px; }
  body.driving .speedo { font-size: 40px; }
  body.driving .rpm { width: 120px; }
  body.driving .drivebtns button { padding: 5px 8px; font-size: 12px; }
  #credit { font-size: 10px; }
}
@media (pointer: coarse) and (orientation: portrait) {
  body.driving #rotateHint { display: block; position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); background: #000c; color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 6; font-size: 14px; pointer-events: none; animation: fadeHint 4s forwards; }
}
@keyframes fadeHint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@media (pointer: coarse) and (orientation: landscape) {
  #touch button { width: 64px; height: 64px; }
  #touch button.gas { width: 76px; height: 76px; }
}
@media (max-width: 900px), (pointer: coarse) { body.driving #modeSeg button { padding: 4px 8px; font-size: 12px; } }
