/* Typing Racer on smaller screens (Nov 2026): tablets, phones and narrow laptop windows.
   The race page was laid out for a laptop (1366 wide); everything here only applies below 1000px wide, or to a
   touch screen, so laptops and desktops are untouched. Loaded last on games/typing-racer.php, after the dash
   and portrait rules (js/racer/portrait.js still plans an upright phone or tablet round its keyboard).
   Selectors start "html body#typingRacer" so they outrank the page's own short-window rules without !important
   where possible; the header's absolute positions come from several older layers, so those few use it. */

/* ================= The header: title, buttons and coins on one line, the lead ad under it ================= */
@media (max-width:999px){
	html body#typingRacer #topModule{padding:0;}
	html body#typingRacer #topModule > .leftCol{display:none;}
	html body#typingRacer #trgInterfaceContainer{position:relative; float:none; width:100%; height:auto; margin:0; padding:calc(var(--chatTop, 47px) + 8px) 10px 8px; box-sizing:border-box;}		/* (clear of the site's fixed menu: --chatTop is its foot, taller on a phone) */
	html.trHeadAuto body#typingRacer #trgInterfaceContainer{padding-top:calc(var(--trHeadH, 47px) + 10px);}		/* (the menu tucks away: css/racer-autohead.css moves #topModule up by its height; a phone's menu is taller than a laptop's) */
	html body#typingRacer #centerEntryModule{position:relative !important; inset:auto !important; height:auto !important; display:flex; align-items:center; gap:10px; margin:0 0 8px; padding:0 !important; overflow:visible; pointer-events:auto;}
	html body#typingRacer #centerEntryModule h1{position:static !important; order:0; flex:0 1 auto; min-width:0; width:auto !important; margin:0 auto 0 0 !important; padding:0 !important;
		font-size:26px !important; line-height:1.1 !important; letter-spacing:.06em !important; white-space:nowrap !important; text-align:left !important;}
	html body#typingRacer #leftOfTitle, html body#typingRacer #rightOfTitle{position:static !important; inset:auto !important; display:flex; flex:none; align-items:center; gap:8px; margin:0;}
	html body#typingRacer #leftOfTitle{order:1;}
	html body#typingRacer #rightOfTitle{order:2;}
	html body#typingRacer .topLeftLink{display:block !important;}
	html body#typingRacer .topLeftLink a{width:36px; height:36px; margin:0; font-size:17px;}
	html body#typingRacer #leftOfTitle .topLeftLink{gap:8px;}
	html body#typingRacer #leftOfTitle button.racerSnd{width:36px; height:36px; min-width:36px; margin:0; font-size:16px;}
	html body#typingRacer #topSlot .topPill, html body#typingRacer #myGarageLink a{height:36px !important; padding:0 12px !important; font-size:14.5px !important; gap:7px !important;}
	html body#typingRacer #userSpeedCoinBank{height:38px !important; padding:0 12px 0 5px !important; gap:7px !important;}
	html body#typingRacer #userSpeedCoinBank.canBuy{padding-right:5px !important;}
	html body#typingRacer #userSpeedCoinBank img{width:26px !important;}
	html body#typingRacer #userSpeedCoinBank span{font-size:18px !important;}
	html body#typingRacer #userSpeedCoinBank .coinPlus{width:24px !important; height:24px !important; font-size:17px !important; line-height:24px !important;}
	html body#typingRacer #leadPlug{width:min(728px, 100%); margin:0 auto;}
}
/* tablets upright: the buttons drop their words (each keeps its icon and its name for screen readers) */
@media (max-width:859px){
	html body#typingRacer #leftOfTitle .tlWord{display:none;}
	html body#typingRacer #topSlot .topPill, html body#typingRacer #myGarageLink a{width:40px; padding:0 !important; justify-content:center;}
}
/* small windows: _u_trg.css gives every page body a 600px minimum, which made a phone lay the page out 600 wide
   (and a 600px window scroll sideways once it has a scroll bar) */
@media (max-width:699px){
	html body#typingRacer{min-width:0;}
	html body#typingRacer #centerEntryModule h1{font-size:22px !important;}
}
/* the lead ad: a phone-sized unit where a leaderboard does not fit (the unit is responsive, so it fills the box) */
@media (max-width:759px){
	html body#typingRacer #leadPlug{width:320px; height:100px;}
}
/* phones: the title and coins on the first line, the buttons (with their words again) on the second */
@media (max-width:599px){
	html body#typingRacer #trgInterfaceContainer{padding-left:8px; padding-right:8px; padding-bottom:6px;}
	html body#typingRacer #centerEntryModule{flex-wrap:wrap; gap:8px; margin-bottom:6px;}
	html body#typingRacer #centerEntryModule h1{font-size:22px !important;}
	html body#typingRacer #leftOfTitle{order:3; flex:1 1 100%; justify-content:flex-start;}
	html body#typingRacer #leftOfTitle > *{margin:0;}
	html body#typingRacer #leftOfTitle .tlWord{display:inline;}
	html body#typingRacer #topSlot .topPill, html body#typingRacer #myGarageLink a{width:auto; padding:0 12px !important;}
}
/* a tablet whose row is too full (the title squeezed under the buttons): the same two lines as a phone
   (body.trTopWrap, from RacerTopFit in games/typing-racer.php) */
@media (max-width:999px){
	html body#typingRacer.trTopWrap #centerEntryModule{flex-wrap:wrap; gap:8px;}
	html body#typingRacer.trTopWrap #rightOfTitle{margin-left:auto;}
	html body#typingRacer.trTopWrap #leftOfTitle{order:3; flex:1 1 100%; justify-content:flex-start;}
	html body#typingRacer.trTopWrap #leftOfTitle > *{margin:0;}
	html body#typingRacer.trTopWrap #leftOfTitle .tlWord{display:inline;}
	html body#typingRacer.trTopWrap #topSlot .topPill, html body#typingRacer.trTopWrap #myGarageLink a{width:auto; padding:0 12px !important;}
}

/* A phone (owner, 2026-11-25, as the garage's header): two rows instead of three. The title with Help, Settings and
   Sound at its right; then the coins, the race tanks, and Standings and Garage as icons (their names in their labels
   and tooltips). Two ids, as RacerTopFit's body.trTopWrap / trTopIcons rules (games/typing-racer.php) put the words back. */
@media (max-width:599px){
	html body#typingRacer#typingRacer #centerEntryModule{flex-wrap:wrap; gap:8px 6px; margin-bottom:6px;}
	html body#typingRacer#typingRacer #centerEntryModule::after{content:""; order:2; flex:0 0 100%; height:0;}		/* the break between the rows */
	html body#typingRacer#typingRacer #centerEntryModule h1{order:0; flex:1 1 auto; margin:0 !important; font-size:22px !important;}
	html body#typingRacer#typingRacer #leftOfTitle{display:contents;}
	html body#typingRacer#typingRacer #leftOfTitle .topLeftLink{order:1; display:flex !important; flex:none; gap:6px; margin:0;}
	html body#typingRacer#typingRacer #leftOfTitle .topLeftLink > *{flex:none; width:36px; min-width:36px; height:36px;}
	html body#typingRacer#typingRacer #rightOfTitle{order:3; flex:0 1 auto; gap:6px; margin:0;}
	html body#typingRacer#typingRacer #topSlot{order:4; margin:0 0 0 auto;}
	html body#typingRacer#typingRacer #myGarageLink{order:5; margin:0;}
	html body#typingRacer#typingRacer #leftOfTitle .tlWord{display:none;}
	html body#typingRacer#typingRacer #topSlot .topPill, html body#typingRacer#typingRacer #myGarageLink a{width:36px; padding:0 !important; justify-content:center;}
}
@media (max-width:379px){		/* the smallest phones: a smaller title keeps its three buttons beside it */
	html body#typingRacer#typingRacer #centerEntryModule h1{font-size:18px !important; letter-spacing:.04em !important;}
}

/* ================= The lobby ================= */
/* The lobby is a container (css/_u_trg.css: container-name lobby), so these go by its own width. One card a row, each as
   tall as it needs; the buttons a finger's height; open races and the racers here under the cards. */
@container lobby (max-width:640px){
	#lobbyCards{grid-template-columns:minmax(0, 1fr); gap:12px;}
	#lobbyCards .lbCard{height:auto; min-height:0; gap:6px; padding:12px 14px 14px;}
	#lobbyCards .lbCard.humans .lbDesc{display:block;}
	#lobbyCards .lbGo, #lobbyCards .lbBottom{margin-top:8px;}
	#lobbyCards .lbGo .lbBtn{height:46px; font-size:16px;}
	#lobbyCards .lbChip, #lobbyCards .lbTab{min-height:32px;}
	#lobbyCards .lbLevels .lbChip{min-height:30px; font-size:12px;}
	#lobbyCards select{height:34px;}
	#lbCode, #lobbyCards .lbBottom .lbBtn{height:42px;}
	#lobbyLower{flex-direction:column; flex:none; gap:12px;}
	#lobbyRecent{flex:none;}
	#lobbyRecentList{max-height:none;}
	#lobbyTrackMenu{position:fixed; left:12px; right:12px; top:auto; grid-template-columns:repeat(2, minmax(0, 1fr));}
}
/* A phone's lobby: its chips on one line (owner, 2026-11-25, with the header above): the track's name gives way first
   (it ends in "...") and the online count is its dot and number (the word kept for screen readers) */
@container lobby (max-width:560px){
	#racerLobby #lobbyStats{flex-wrap:nowrap; gap:6px;}
	#racerLobby #lobbyStats .lsChip{padding:0 8px;}
	#racerLobby #lobbyTrack{flex:0 1 auto; min-width:0;}
	#racerLobby #lobbyScene{flex:0 1 auto; min-width:0; max-width:100%;}
	#racerLobby #lobbySceneName{min-width:0; overflow:hidden; text-overflow:ellipsis;}
	#racerLobby #lobbyCounts{flex:none; margin-left:auto;}
	#racerLobby #lobbyCounts > span:nth-child(2){margin:0; font-size:0;}
	#racerLobby #lobbyCounts > span:nth-child(2) b{font-size:14px;}
}
/* On a phone (or a window too short for the lobby's box) the lobby is as tall as it needs and the page scrolls (FitRace keeps it at true size there), instead
   of a box of the screen's height scrolling inside the page. In a room the race panel is as before. */
@media (max-width:699px), (max-height:559px){
	html body#typingRacer:not(.hudFull) #gameGraphics{height:auto !important; min-height:300px;}
	html body#typingRacer:not(.hudFull) #racerLobby{position:relative; inset:auto; height:auto; min-height:300px; overflow:visible;}
	html body#typingRacer:not(.hudFull) #theRoad{position:absolute; left:0; right:0; top:0;}		/* (the road is in the flow: out of it here, at the same place it has in a room) */
}

/* ================= In a room on an upright phone or tablet (js/racer/portrait.js) =================
   The planner scrolls the race up to sit just over the dash, with the keyboard's share kept below it. The page needs
   that much room under the race to scroll into, which the body's padding was meant to give, but _e_footer.css sets
   every page's "html > body" padding-bottom to 0 !important; the race panel carries it instead. */
html.trPortrait body#typingRacer.hudFull #gameGraphics{margin-bottom:calc(var(--hudH, 157px) + var(--hudLift, 0px));}

/* ================= In a room on a short window (FitRace in games/typing-racer.php: html.trShort) =================
   The race fills the room between the site menu and the dash and the page scrolls the title and ad up out of sight;
   the room under the race to scroll into is carried by the panel, as for an upright phone above. */
html.trShort body#typingRacer.hudFull #gameGraphics{margin-bottom:200px;}
/* its results (a phone on its side): the dash slides down out of sight, so they have the screen under the menu; the results
   have their own Next Race and Lobby (FitRace leaves the dash out; its typing field stays focusable for Next Race) */
html.trShort.trgPodium body#typingRacer.hudFull.racerTouch #racerHud{transform:translateY(calc(100% + 12px)); pointer-events:none;}

/* ================= The lobby's slim dash on a small screen =================
   The "Your ride" bay and the saved rides are a laptop's showcase; on a phone or a short window they covered half the
   lobby, and what is left of it there (a greyed Next Race) says nothing: in the lobby it is put away. The title bar's
   My Garage button opens the same place. (An upright phone keeps its own one-line lobby dash, js/racer/portrait.js.) */
@media (max-width:759px), (max-height:559px){
	html:not(.trPortrait) body#typingRacer #racerHud.slim{display:none;}
}
/* an upright phone or tablet keeps its one-line lobby dash on the screen's foot: the page ends that much lower, so
   the footer is never under it (--hudH: js/racer/portrait.js) */
html.trPortrait body#typingRacer:not(.hudFull) > footer{margin-bottom:var(--hudH, 50px);}
/* a tablet or narrow window: the bay stays, the saved rides go (My Garage has them), so the bay and Next Race fit */
@media (max-width:999px){
	html:not(.trPortrait) body#typingRacer #racerHud.slim #hudPresets{display:none;}
	html:not(.trPortrait) body#typingRacer #racerHud.slim #hudRide #lobbyRide{width:220px;}
}

/* Race Points beside the coins (css/_u_trg.css #userRpBank): as tall as the coins here; phones leave it out */
@media (max-width:999px){
	html body#typingRacer #userRpBank{height:38px; padding:0 12px 0 5px; gap:6px;}
	html body#typingRacer #userRpBank img{width:24px;}
	html body#typingRacer #userRpBank span{font-size:18px;}
}
@media (max-width:599px){
	html body#typingRacer #userRpBank{display:none;}
}
/* Fuel right of the coins (css/_u_trg.css #userFuelBank, look H, 2026-11-25): as tall as the coins */
@media (max-width:999px){
	html body#typingRacer #userFuelBank{height:38px; padding:0 3px;}
	html body#typingRacer #userFuelBank .ufSeg{gap:5px; padding:0 6px;}
}
/* narrower, the title needs the room: the Race Points go (the lobby's Race Pass chip has them) */
@media (max-width:739px){
	html body#typingRacer #userRpBank{display:none;}
}

/* ================= The chat tab on a phone or tablet =================
   The tab on the screen's edge covered the finish line and the results' right-hand card: here it is just the Discord
   mark, and from the countdown to the flag it is put away (html.trRacing, games/typing-racer.php). */
@media (max-width:999px), (max-height:559px), (pointer:coarse){
	html body#typingRacer #chatTab{width:32px; gap:0; padding:9px 0; border-radius:10px 0 0 10px;}
	html body#typingRacer #chatTab:hover{width:32px;}
	html body#typingRacer #chatTab > span:not(.bcDot){display:none;}
	html body#typingRacer #chatTab .chatTabLogo{width:18px; height:18px;}
	html body#typingRacer #chatTab .bcDot{margin-top:6px;}
	html.trRacing body#typingRacer.hudFull #chatTab{display:none;}
}
