/* Trauma Lab Game — traumalabgame.com */
/* Palette: background #14181b, accent #e9c46a. Mobile-first, no web fonts. */

:root {
  --bg: #14181b;
  --bg-2: #1b2126;
  --bg-3: #222a30;
  --text: #e6e9ec;
  --muted: #9aa4ad;
  --accent: #e9c46a;
  --accent-dark: #c9a244;
  --danger: #d64545;
  --danger-text: #ff6b6b; /* 6.4:1 on --bg, 5.3:1 on --bg-3 */
  --border: #2c353d;
  --radius: 10px;
  --maxw: 760px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

code {
  background: var(--bg-3);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(20, 24, 27, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
}

.logo {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; color: var(--accent); }

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  flex: 1 1 auto;
  font-size: 0.92rem;
}
.main-nav a {
  color: var(--muted);
  padding: 8px 2px; /* taller tap target */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.main-nav a:hover, .main-nav a:focus-visible { color: var(--accent); text-decoration: none; }

.age-badge {
  border: 2px solid var(--danger-text);
  color: var(--danger-text);
  font-weight: 800;
  font-size: 0.8rem;
  border-radius: 6px;
  padding: 2px 7px;
  line-height: 1.4;
  white-space: nowrap;
}

.lang-switcher {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lang-switcher a { color: var(--muted); padding: 10px 2px; min-height: 44px; display: inline-flex; align-items: center; }
.lang-switcher a[aria-current="page"] { color: var(--accent); pointer-events: none; }
.lang-switcher span { color: var(--border); }

/* ---------- Language hint ---------- */
.lang-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 0.95rem;
}
.lang-hint[hidden] { display: none; }
.lang-hint button {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  font-size: 1rem;
}

/* ---------- Main ---------- */
main {
  display: block;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px calc(48px + env(safe-area-inset-bottom));
}

h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.3rem);
  line-height: 1.25;
  margin: 24px auto 20px;
  max-width: var(--maxw);
  text-align: center;
}

h2 {
  font-size: 1.45rem;
  line-height: 1.3;
  margin: 44px 0 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

h3 { font-size: 1.15rem; margin: 28px 0 10px; }

p { margin: 0 0 14px; }

ul, ol { padding-left: 1.4em; margin: 0 0 14px; }
li { margin-bottom: 6px; }

.content { max-width: var(--maxw); margin: 0 auto; }

.intro {
  max-width: var(--maxw);
  margin: 28px auto 0;
  font-size: 1.02rem;
}

blockquote.warning {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--danger);
  background: var(--bg-2);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
}
blockquote.warning p { margin: 0; }

.screenshot { margin: 18px 0; }
.screenshot img { border-radius: var(--radius); border: 1px solid var(--border); display: block; }
.screenshot figcaption, .caption {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 0 16px; -webkit-overflow-scrolling: touch; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  min-width: 480px;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--bg-3); color: var(--accent); font-weight: 700; white-space: nowrap; }
td:first-child { white-space: nowrap; font-weight: 600; }
tbody tr:nth-child(even) { background: var(--bg-2); }

/* ---------- Game box ---------- */
.game-section { margin: 0 auto; max-width: 1100px; }

.game-stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
}

/* Desktop: cap the stage so the toolbar stays above the fold at 1366×768.
   Keep 16:9 by limiting the width to match the capped height. */
@media (min-width: 601px) {
  .game-stage {
    max-height: calc(100vh - 210px);
    max-width: min(1100px, calc((100vh - 210px) * 16 / 9));
  }
}

/* Phones in portrait: the game has its own phone layout */
@media (max-width: 600px) and (orientation: portrait) {
  .game-stage { aspect-ratio: 9 / 16; max-height: 80vh; margin: 0 auto; }
}

.game-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(20, 24, 27, 0.55);
  padding: 16px;
  text-align: center;
}

.play-btn {
  font: inherit;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 800;
  color: #14181b;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 16px 34px;
  min-height: 56px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(233, 196, 106, 0.35);
  transition: transform 0.12s ease, background 0.12s ease;
}
.play-btn:hover, .play-btn:focus-visible { background: var(--accent-dark); transform: scale(1.03); }
.play-btn:active { transform: scale(0.98); }

.game-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(20, 24, 27, 0.75);
  border-radius: 6px;
  padding: 4px 12px;
}

.game-stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.game-fail {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(20, 24, 27, 0.96);
  padding: 24px;
  text-align: center;
}
.game-fail[hidden] { display: none; }
.game-fail p { max-width: 46ch; margin: 0; }

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px auto 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover, .btn:focus-visible { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-accent { background: var(--accent); color: #14181b; border-color: var(--accent); }
.btn-accent:hover, .btn-accent:focus-visible { background: var(--accent-dark); color: #14181b; }

.version-chip {
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

.game-credit {
  margin: 8px auto 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Fullscreen & iOS pseudo-fullscreen */
.game-stage:fullscreen { border-radius: 0; border: none; max-width: none; max-height: none; }

.game-stage.pseudo-fs {
  position: fixed;
  inset: 0;
  z-index: 9999;
  height: 100dvh;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
}

.fs-exit {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 10;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: rgba(20, 24, 27, 0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.fs-exit[hidden] { display: none; }

/* Hide all ads while fullscreen */
body.is-fullscreen .ad-slot,
body.is-fullscreen .site-footer .ad-slot { display: none !important; }

/* ---------- Ad slots ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.ad-rect { width: 300px; max-width: 100%; min-height: 250px; margin: 24px auto; }
.ad-native { margin: 16px auto 24px; max-width: 760px; min-height: 300px; }
.ad-banner { margin: 8px auto 16px; max-width: 760px; min-height: 90px; }

@media (max-width: 767px) {
  .ad-banner { min-height: 50px; }
}

.sidebar { display: none; }

@media (min-width: 1280px) {
  .page-grid {
    display: grid;
    grid-template-columns: minmax(0, var(--maxw)) 300px;
    gap: 48px;
    justify-content: center;
  }
  .content { margin: 0; }
  .sidebar { display: block; }
  .ad-sidebar {
    position: sticky;
    top: 90px;
    width: 160px;
    min-height: 600px;
  }
}

/* Social Bar slot removed — .ad-social styles intentionally deleted */

/* ---------- FAQ accordion ---------- */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  margin-bottom: 10px;
  overflow: hidden;
}
summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 44px 14px 16px;
  min-height: 44px;
  position: relative;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 400;
}
details[open] summary::after { content: "−"; }
details p { padding: 0 16px 14px; margin: 0; }

/* ---------- YouTube lite embed ---------- */
.yt-lite {
  position: relative;
  max-width: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  margin: 16px 0 6px;
  aspect-ratio: 4 / 3;
  background: var(--bg-2);
}
.yt-lite img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  color: #fff;
  background: rgba(20, 24, 27, 0.35);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}
.yt-lite iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Breadcrumb & guide links ---------- */
.breadcrumb {
  max-width: var(--maxw);
  margin: 18px auto 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover, .breadcrumb a:focus-visible { color: var(--accent); }
.breadcrumb span[aria-current="page"] { color: var(--text); }

.more-link {
  display: inline-block;
  margin: 4px 0 8px;
  font-weight: 600;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  font-size: 0.88rem;
  color: var(--muted);
}
.site-footer p { max-width: var(--maxw); margin: 0 auto 12px; }
.site-footer a { color: var(--accent); }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .header-inner { padding: 8px 12px; }
  main { padding-left: 12px; padding-right: 12px; }
}

/* Mobile header: row 1 = logo + 18+ + EN|RU, row 2 = one horizontally
   scrollable nav row (no 3-row wrap pushing the game down). */
@media (max-width: 600px) {
  .logo { margin-right: auto; }
  .main-nav {
    order: 10;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0 16px;
    padding-bottom: 2px;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { white-space: nowrap; min-height: 44px; }
}
