/* Shared shell & UI primitives for Farland web/classic games */
:root {
  --fa-bg: #12101a;
  --fa-surface: #1e1a2b;
  --fa-surface-2: #2a243d;
  --fa-line: rgba(255, 255, 255, 0.12);
  --fa-ink: #f5f3fa;
  --fa-muted: #aba3be;
  --fa-accent: #e2445c;
  --fa-accent-2: #6d5ce8;
  --fa-gold: #f6c445;
  --fa-ok: #3cd070;
  --fa-bar-h: 50px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden;
  background: var(--fa-bg);
  color: var(--fa-ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.fa-app {
  display: flex; flex-direction: column;
  width: 100%; height: 100dvh; height: 100vh;
  height: 100dvh;
  background: var(--fa-bg);
  position: relative;
}

/* Top bar */
.fa-bar {
  flex: none;
  height: var(--fa-bar-h);
  padding: 0 10px 0 12px;
  padding-top: env(safe-area-inset-top, 0px);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(20, 17, 30, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fa-line);
  z-index: 30;
}
.fa-home {
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none; font-weight: 800; font-size: 14px;
  padding: 5px 10px 5px 6px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  flex: none;
}
.fa-home:hover { background: rgba(255, 255, 255, 0.16); }
.fa-home img { width: 22px; height: 22px; border-radius: 6px; display: block; }
.fa-title {
  font-weight: 800; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.fa-hud {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; margin-right: 4px;
  flex-wrap: nowrap; overflow: hidden;
}
.fa-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--fa-line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.fa-pill b { color: var(--fa-gold); font-variant-numeric: tabular-nums; }
.fa-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.fa-icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--fa-line);
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.fa-icon-btn:hover { background: rgba(255, 255, 255, 0.17); }
.fa-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Main stage */
.fa-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fa-stage.scroll { overflow-y: auto; justify-content: flex-start; padding: 14px 12px 24px; }
.fa-canvas-wrap {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
canvas.fa-canvas {
  display: block;
  touch-action: none;
  max-width: 100%; max-height: 100%;
}

/* Buttons & toolbar */
.fa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--fa-line);
  background: var(--fa-surface-2);
  color: var(--fa-ink);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease;
}
.fa-btn:hover { background: #37304f; }
.fa-btn:active { transform: scale(0.97); }
.fa-btn.primary { background: var(--fa-accent); border-color: transparent; color: #fff; }
.fa-btn.primary:hover { background: #f0536b; }
.fa-btn.secondary { background: var(--fa-accent-2); border-color: transparent; color: #fff; }
.fa-btn.small { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.fa-btn.active { background: var(--fa-accent-2); border-color: transparent; color: #fff; }

.fa-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px; padding: 8px 10px; width: 100%; max-width: 720px;
}

/* Modal / Overlay */
.fa-overlay {
  position: absolute; inset: 0;
  background: rgba(10, 8, 18, 0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 40;
}
.fa-overlay[hidden] { display: none !important; }
.fa-card {
  width: min(390px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  background: var(--fa-surface);
  border: 1px solid var(--fa-line);
  border-radius: 22px;
  padding: 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.fa-card h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.fa-card p { margin: 6px 0; color: var(--fa-muted); font-size: 14px; }
.fa-card .fa-big { font-size: 38px; font-weight: 900; color: var(--fa-gold); margin: 8px 0; font-variant-numeric: tabular-nums; }
.fa-card .fa-btn-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.fa-card .fa-btn-col { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fa-card .fa-btn-col .fa-btn { width: 100%; }

/* Menu drawer */
.fa-menu {
  position: fixed; inset: 0;
  background: rgba(8, 6, 15, 0.65);
  backdrop-filter: blur(4px);
  display: flex; justify-content: flex-end;
  z-index: 60;
}
.fa-menu[hidden] { display: none !important; }
.fa-drawer {
  width: min(340px, 88vw);
  height: 100%;
  background: var(--fa-surface);
  border-left: 1px solid var(--fa-line);
  padding: 18px 18px 28px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.fa-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--fa-line);
}
.fa-drawer-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.fa-drawer h3 { margin: 8px 0 4px; font-size: 14px; color: var(--fa-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fa-drawer ol { margin: 0; padding-left: 18px; color: #ddd6ec; font-size: 14px; display: flex; flex-direction: column; gap: 5px; }
.fa-drawer .fa-btn { width: 100%; }

/* Touch D-pad / arcade controls */
.fa-touch-pad {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 12px 10px;
  width: 100%; flex: none;
  background: rgba(18, 15, 28, 0.88);
  border-top: 1px solid var(--fa-line);
  z-index: 20;
}
.fa-dpad {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(2, 42px);
  gap: 6px;
}
.fa-dpad-btn {
  border: 1px solid var(--fa-line);
  background: var(--fa-surface-2);
  color: var(--fa-ink);
  border-radius: 12px;
  font-size: 18px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: none;
}
.fa-dpad-btn:active, .fa-dpad-btn.pressed { background: var(--fa-accent-2); color: #fff; transform: scale(0.94); }
.fa-dpad-up { grid-column: 2; grid-row: 1; }
.fa-dpad-left { grid-column: 1; grid-row: 2; }
.fa-dpad-down { grid-column: 2; grid-row: 2; }
.fa-dpad-right { grid-column: 3; grid-row: 2; }

@media (max-width: 560px) {
  .fa-home span { display: none; }
  .fa-title { font-size: 14px; }
  .fa-pill { padding: 3px 8px; font-size: 11px; }
  .fa-bar { padding: 0 8px; gap: 6px; }
}
