/* PTF mobile layer.
   Only takes effect on pages that set $mobileReady = true before including
   template_inc.php: those get a device-width viewport, so the media query
   below matches on phones. All other pages keep viewport width=1000 and
   render exactly as the desktop site. */

#m_top { display: none; }
.lineup_sheet_bar { display: none; }
.ros_cards { display: none; }

@media (max-width: 760px) {

	body {
		background-image: none;
		-webkit-text-size-adjust: 100%;
		text-size-adjust: 100%;
	}

	/* ---------- Site frame ---------- */
	#site_frame,
	#site_frame > tbody > tr > td > table {
		width: 100% !important;
		table-layout: fixed;
	}
	#site_frame td[width="1000"] { width: auto !important; height: auto !important; }

	.team_links_bar,
	.banner_table,
	.mem_bar,
	.footer_shadow,
	#dropmenudiv { display: none !important; }

	.top_bar {
		height: auto;
		background: #050c1e none;
		border: 0;
	}
	.top_bar .login { padding: 8px; }
	.top_bar .sign_in_block { float: none; width: auto; }
	.top_bar .login_box { width: 38% !important; height: 32px; }

	.content_main {
		padding: 6px 4px 0 4px;
		border: 0;
		background-image: none;
	}
	.content_scroll {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.footer_bar { height: auto; background-image: none; }

	/* Wide tables: mobile.js wraps any table still wider than the screen in
	   .m_scroll so it scrolls sideways on its own, not the whole page. */
	.m_scroll {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		margin-bottom: 6px;
		border-right: 3px solid #c9a227;	/* hint: more to the right */
	}

	/* Layout tables marked class="m_stack": columns stack top to bottom.
	   Cells with m_order_N are re-ordered (flex order). */
	table.m_stack, table.m_stack > tbody, table.m_stack > tbody > tr, table.m_stack > tbody > tr > td {
		display: block;
		width: auto !important;
		box-sizing: border-box;
	}
	table.m_stack > tbody > tr { display: flex; flex-direction: column; }
	table.m_stack > tbody > tr > td { margin-bottom: 6px; }
	table.m_stack > tbody > tr > td.m_order_last { order: 99; }

	/* Readable table text (desktop uses 10px) */
	.content_scroll .smallbold, .content_scroll .smallboldNoOutline,
	.content_scroll .smallboldWithOutline { font-size: 12px; }

	.content_scroll input[type="text"], .content_scroll input[type="password"],
	.content_scroll input[type="number"], .content_scroll textarea, .content_scroll select {
		max-width: 100%;
		box-sizing: border-box;
	}
	.content_scroll iframe { max-width: 100%; }

	/* iOS zooms in on focus when inputs are under 16px */
	input[type="text"], input[type="password"], input[type="number"],
	input[type="email"], select, textarea { font-size: 16px; }

	/* ---------- Mobile header + menu ---------- */
	#m_top {
		display: block;
		position: sticky;
		top: 0;
		z-index: 1000;
	}
	#m_header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background: #050c1e;
		border-bottom: 2px solid #c9a227;
		padding: 6px 10px;
		padding-top: calc(6px + env(safe-area-inset-top));
	}
	#m_header .m_logo {
		display: flex;
		align-items: center;
		color: #f2d27a;
		font: bold 17px Verdana, Arial, Helvetica, sans-serif;
		text-decoration: none;
	}
	#m_header .m_logo img { width: 36px; height: 36px; margin-right: 8px; border-radius: 6px; }
	#m_menu_btn {
		background: none;
		border: 1px solid #c9a227;
		border-radius: 6px;
		color: #f2d27a;
		font-size: 22px;
		line-height: 1;
		padding: 6px 12px;
		cursor: pointer;
	}

	.m_header_right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
	#m_teams {
		-webkit-appearance: none;
		appearance: none;
		background: #050c1e;
		border: 1px solid #c9a227;
		border-radius: 6px;
		color: #f2d27a;
		font: bold 16px Verdana, Arial, Helvetica, sans-serif;	/* 16px+ stops iPhone zooming in */
		padding: 7px 26px 7px 10px;
		max-width: 110px;
		background-image: linear-gradient(45deg, transparent 50%, #c9a227 50%), linear-gradient(135deg, #c9a227 50%, transparent 50%);
		background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
		background-size: 5px 5px, 5px 5px;
		background-repeat: no-repeat;
	}
	#m_teams option { color: #000; background: #fff; font-weight: normal; }
	@media (max-width: 400px) {
		#m_header .m_logo { font-size: 14px; }
		#m_header .m_logo img { width: 30px; height: 30px; margin-right: 6px; }
	}

	#m_nav { display: none; }
	#m_nav.open {
		display: block;
		max-height: calc(100vh - 70px);
		overflow-y: auto;
		background: #0b1530;
		border-bottom: 2px solid #c9a227;
		font-family: Verdana, Arial, Helvetica, sans-serif;
	}
	#m_nav a, #m_nav .m_sec_btn {
		display: block;
		width: 100%;
		box-sizing: border-box;
		text-align: left;
		padding: 13px 16px;
		color: #fff;
		font: bold 15px Verdana, Arial, Helvetica, sans-serif;
		text-decoration: none;
		background: none;
		border: 0;
		border-top: 1px solid #1d2a4d;
		cursor: pointer;
	}
	#m_nav .m_sec_btn:after { content: "+"; float: right; color: #c9a227; }
	#m_nav .m_sec.open .m_sec_btn:after { content: "\2212"; }
	#m_nav .m_sec_items { display: none; background: #050c1e; }
	#m_nav .m_sec.open .m_sec_items { display: block; }
	#m_nav .m_sec_items a { font-weight: normal; padding-left: 30px; font-size: 14px; }
	#m_nav .m_sec_items .textWhite { display: block; padding: 10px 16px 4px; color: #c9a227; font-size: 11px; }
	#m_nav .m_sec_items .textWhite br { display: none; }
	#m_nav .arrow_right { display: none; }


	/* ---------- Lineups (coach_lineup.php / includes_lg/coach_lineup_inc.php) ----------
	   The depth tables keep their exact row/cell structure (the page JS moves players
	   by row and cell index); only their presentation changes here. */
	table.lineup_layout { margin-bottom: 8px; }
	.lineup_depthTable { width: auto !important; }
	#offense > tbody, #offense > tbody > tr, #offense > tbody > tr > td,
	#defense > tbody, #defense > tbody > tr, #defense > tbody > tr > td,
	#special_teams > tbody, #special_teams > tbody > tr, #special_teams > tbody > tr > td {
		display: block;
		width: auto !important;
	}
	#offense > tbody > tr > td, #defense > tbody > tr > td, #special_teams > tbody > tr > td {
		padding: 0 0 10px 0;
	}
	#help p { font-size: 14px; line-height: 1.4; }

	/* one card per position */
	table[id^="depthTable_"] { scroll-margin-top: 64px; }
	table[id^="depthTable_"] td.statCell { padding: 9px 6px; font-size: 14px; }
	table[id^="depthTable_"] tr:first-child td.statCell { padding: 0; }
	table[id^="depthTable_"] tr:first-child a {
		display: block;
		padding: 11px 12px;
		font-size: 16px;
		text-decoration: none;
	}
	table[id^="depthTable_"] tr:first-child a:after {
		content: "choose players \25B8";
		float: right;
		font-size: 12px;
		font-weight: normal;
		color: #fff;
		opacity: .85;
	}
	table[id^="depthTable_"] td[width="5%"] { width: 34px; text-align: center; }
	table[id^="depthTable_"] img,
	.lineup_availTable img { width: 24px; height: 24px; image-rendering: pixelated; }

	/* fixed bottom bar: Offense / Defense / Special Teams, Help / Load Last / Submit */
	table.lu_dmenu {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 960;
		width: 100% !important;
		display: block;
		background: #050c1e;
		border: 0;
		border-top: 2px solid #c9a227;
	}
	table.lu_dmenu > tbody {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 5px;
		padding: 6px;
	}
	table.lu_dmenu tr { display: block; background: none; }
	table.lu_dmenu tr.lm_title { display: none; }
	table.lu_dmenu tr.lm_off { order: 1; }
	table.lu_dmenu tr.lm_def { order: 2; }
	table.lu_dmenu tr.lm_st { order: 3; }
	table.lu_dmenu tr.lm_help { order: 4; }
	table.lu_dmenu tr.lm_load { order: 5; }
	table.lu_dmenu tr.lm_submit { order: 6; }
	table.lu_dmenu td { display: block; padding: 0; border: 0; background: none; }
	table.lu_dmenu a,
	table.lu_dmenu input[type="submit"] {
		display: block;
		width: 100%;
		box-sizing: border-box;
		margin: 0;
		padding: 11px 2px;
		border: 0;
		border-radius: 6px;
		background: #0b1530 !important;
		color: #fff !important;
		font: bold 13px Verdana, Arial, Helvetica, sans-serif;
		text-align: center;
		text-decoration: none;
		-webkit-appearance: none;
		appearance: none;
	}
	table.lu_dmenu tr.on a { background: #c9a227 !important; color: #050c1e !important; }
	table.lu_dmenu input[type="submit"] { background: #1d7a35 !important; }
	body.m_lineup { padding-bottom: 104px; }
	/* the depth cards stack to screen width, so the content box needn't scroll;
	   as a scroll box it can trap the fixed bar on iPhone */
	body.m_lineup .content_scroll { overflow: visible; -webkit-overflow-scrolling: auto; }

	/* available players: bottom sheet above the bar */
	.lineup_availTable {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 98px;
		z-index: 950;
		width: auto !important;
		max-height: 42vh;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		background: #fff;
		border-top: 3px solid #c9a227;
		box-shadow: 0 -6px 18px rgba(0, 0, 0, .45);
	}
	.lineup_sheet_bar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: sticky;
		top: 0;
		z-index: 1;
		background: #050c1e;
		color: #fff;
		padding: 8px 12px;
		font: bold 14px Verdana, Arial, Helvetica, sans-serif;
	}
	.lineup_sheet_bar a {
		background: #c9a227;
		color: #050c1e;
		padding: 7px 16px;
		border-radius: 5px;
		text-decoration: none;
	}
	.lineup_availTable td.statCell { padding: 9px 6px; font-size: 14px; }
	.lineup_availTable tr:first-child { display: none; }	/* title is in the sheet bar */
	body.m_sheet_open { padding-bottom: calc(42vh + 110px); }


	/* ---------- Manage Roster (includes_lg/gm_manage_inc.php outputRosterCards) ---------- */
	.ros_table { display: none; }
	.ros_cards { display: block; text-align: left; font-family: Verdana, Arial, Helvetica, sans-serif; }
	.ros_tools {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 4px 0 8px;
		font-size: 13px;
		font-weight: bold;
	}
	.ros_tools select { margin-left: 6px; }
	.ros_filter {
		display: flex;
		flex-wrap: wrap;
		gap: 6px;
		margin-bottom: 10px;
	}
	.ros_filter a {
		flex: 0 0 auto;
		padding: 7px 11px;
		border-radius: 16px;
		background: #e6e9f0;
		color: #050c1e;
		font-size: 13px;
		font-weight: bold;
		text-decoration: none;
	}
	.ros_filter a.on { background: #050c1e; color: #f2d27a; }
	.ros_card {
		border: 1px solid #cfd4de;
		border-left: 4px solid #050c1e;
		border-radius: 6px;
		padding: 9px 10px;
		margin-bottom: 8px;
		background: #fff;
	}
	.ros_top { display: flex; align-items: center; gap: 8px; }
	.ros_pos {
		flex: 0 0 auto;
		min-width: 38px;
		text-align: center;
		padding: 3px 4px;
		border-radius: 4px;
		background: #050c1e;
		color: #f2d27a;
		font-size: 12px;
		font-weight: bold;
	}
	.ros_name { flex: 1 1 auto; font-size: 16px; font-weight: bold; }
	.ros_name a { text-decoration: none; }
	.ros_ovr { flex: 0 0 auto; font-size: 20px; font-weight: bold; color: #050c1e; }
	.ros_meta { margin-top: 5px; font-size: 13px; color: #444; line-height: 1.45; }
	.ros_badges { margin-top: 6px; }
	.ros_badges span {
		display: inline-block;
		margin: 0 5px 3px 0;
		padding: 2px 8px;
		border-radius: 10px;
		background: #fff3cd;
		color: #7a5600;
		font-size: 12px;
		font-weight: bold;
	}
	.ros_actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
	.ros_actions a {
		flex: 1 1 auto;
		text-align: center;
		padding: 9px 8px;
		border-radius: 6px;
		background: #0b1530;
		color: #fff !important;
		font-size: 13px;
		font-weight: bold;
		text-decoration: none;
	}
	.ros_actions a.ros_cut { flex: 0 0 auto; background: #fff; color: #b00020 !important; border: 1px solid #b00020; }

	/* ---------- GM desk header + menu (includes_lg/gm_menu_inc.php) ---------- */
	.gm_desk_title h1 { font-size: 20px; margin: 6px 0; }
	.gm_desk_title h1 img { width: 40px; height: auto; vertical-align: middle; }
	.gm_desk_title h1 img:last-child { display: none; }

	.gm_desk_menu {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 6px;
		margin: 8px 0 12px;
		text-align: center;
	}
	.gm_desk_menu .sep, .gm_desk_menu br { display: none; }
	.gm_desk_menu a {
		display: block;
		padding: 12px 6px;
		background: #0b1530;
		color: #fff !important;
		border-radius: 6px;
		font-size: 14px;
		text-decoration: none;
	}
	.gm_desk_menu a:active { background: #c9a227; color: #050c1e !important; }

	/* ---- Player card header (player.php and the GM contract pages) ---- */
	.content_scroll .smallboldWithOutline h1 { font-size: 22px; margin: 4px 0; }
	.content_scroll .smallboldWithOutline img.logoclass { width: 56px; height: auto; }
}
