:root {
    --color-surface: #f5f5f5;
    --color-on-surface: #000000;
    --color-surface-variant: #E7E0Ec;
    --button-green: #4CAF50;
    --label-bg-tint: #E0E0E0;
    --nth-bg: #E14158;
}

@font-face {
    font-family: MHeiHK-Bold;
    src: url("/MHeiHK-Bold.otf") format("opentype");
}

@font-face {
    font-family: CaseyReplica-Bold;
    src: url("/CaseyReplica.ttf") format("truetype");
}
@font-face {
    font-family: MyriadPro-Semibold-13;
    src: url("/MyriadPro-Semibold-13.otf") format("opentype");
}

@font-face {
    font-family: MHeiHK-Bold;
    font-weight: bold;
    src: url("/MHeiHK-Bold.otf") format("opentype");
}

#info-train {
	font-family: MHeiHK-Bold, CaseyReplica-Bold;
}

body {
	margin: 0;
    padding: 0;
    background-color: var(--color-surface);
    color: var(--color-on-surface);
    overflow: hidden;
	display: flex;
    justify-content: center; /* Centers horizontally */
    align-items: center;     /* Centers vertically */
    height: 100vh;
    width: 100vw
}

body::-webkit-scrollbar {
  display: none;
}

#nested_scroll_view {
    position: absolute;
    top: 0;
    left: 0;
    scroll-behavior: smooth;
	height: 100vh;           /* Uses full height of the screen */
    aspect-ratio: 4 / 3;     /* Standard 4:3 ratio */
    
    /* Responsive fallback for older browsers */
    width: auto;
    max-width: 133.33vh; 
    
    position: relative;
    overflow-y: auto;        /* Allows the Tuen Ma Line list to scroll inside the 4:3 box */
    overflow-x: hidden;
	
	-ms-overflow-style: none;  /* IE and Edge */
	scrollbar-width: none;
}

.top {
	display: block;
	justify-content: center;
	align-items: center;
	font-family: "Orbitron";
	text-align: center; !important
}
.top img{
	height: 150px;
	vertical-align: middle;
	border-style: none;
}

.top h2 {
	margin: 20px 0;
	font-size: xx-large;
	text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
	color: #2c3e50
}

.detailMSG {
	display: flex;
	border-radius: 10px;
	background: white;
	padding: 20px;
	box-shadow: 0 4px 6px rgba(0,0,0,0.1);
	margin: 20px auto;
	max-width: 1200px
}
.item {
	display: flex;
	border-radius: 10px;
	background: var(--color-surface);
	padding: 20px;
	gap: 30px;
	box-shadow: 0 4px 6px rgba(0,0,0,0.1);
	margin: 20px;
	align-items: center;
	justify-content: center;
}

.item img {
	user-select: none;
	-drag: none;
	-moz-user-select: none;
	-webkit-user-drag: none;
	-webkit-user-select: none;
	width: 50px;
	height: auto;
}

.item button{
	background: linear-gradient(#A3238F, #923011);
	color: white;
	font-size: 18px;
	border-radius: 6px;
	border: none;
	height: 80%;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	cursor: pointer;
	font-family: "Orbitron"
}


#line_banner {
    height: 56px;
    background-color: var(--color-surface);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.banner-content {
    display: flex;
    align-items: center;
}

#line_color_badge {
    width: 32px;
    height: 32px;
    margin-right: 8px;
    background-color: #5DE2FF;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
}

#tv_line_code_badge {
    width: 26px;
    height: 26px;
    background-color: #FFFFFF;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    color: #000000;
}

#tv_banner_name {
    font-size: 18px;
    font-weight: bold;
}

.banner-button {
    position: absolute;
    top: 4px;
    width: 48px;
    height: 48px;
    background: transparent;
    border: none;
    color: #92ADBB;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.banner-button .material-icons {
    font-size: 32px;
}

#btn_guide {
    left: 4px;
}

#btn_close {
    right: 4px;
}

#btn_close_sheet {
    right: 4px;
}

#btn_close_guide {
    right: 4px;
}

/* Refresh time */
#tv_refresh_time {
    position: fixed;
    top: 50px;
    right: 0;
    padding: 16px;
    font-size: 12px;
    color: gray;
    z-index: 5;
    pointer-events: none;
}

/* Direction label */
.direction-label {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    background-color: var(--label-bg-tint);
    padding: 4px 10px;
    border-radius: 16px;
	font-family: MHeiHK-Bold;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#tv_up_dir {
    top: 80px;
}

#tv_dn_dir {
    bottom: 20px;
}


/* Non-traffic Hour banner */
#layout-nth {
    height: 80px;
    margin-top: 56px;
    background-color: var(--nth-bg);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.nth-title {
    font-weight: bold;
}


/* --- THE ULTIMATE ALIGNMENT FIX --- */

/* 1. Make the rail zone stay exactly in the middle no matter what */
.rail-svg-zone {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 240px;
    height: 100%;
    z-index: 0; /* Ensures it stays behind the station dots */
}

/* 2. Fix the gaps: Stretch the SVG slightly so it links/sticks together */
.rail-svg-zone svg {
    position: absolute !important;
    height: calc(100% + 2px) !important; /* 2px taller to overlap gaps */
    top: -1px !important; /* Shifts it up 1px to center the overlap */
    left: 0;
    width: 100%;
    display: block;
}

/* 3. Container setup */
.item-row-container {
    position: relative !important;
    display: flex !important;
    justify-content: center !important;
}

/* 4. Shift the station text block to the LEFT side */
.item-station .item-row-container > div:first-child {
    position: absolute !important;
    right: calc(50% + 20px) !important; /* Anchors the text to the LEFT side of the line */
    left: auto !important; /* Clears the old rule */
    width: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important; /* Pushes the text right up against the rail */
    padding-right: 10px; /* Space between the text and the dot */
}

.station-name-col {
    display: flex;
    flex-direction: column; /* Stacks the text top-to-bottom */
    align-items: flex-end;  /* Aligns the text to the right side (close to the rail) */
    text-align: end;
    line-height: 1.2;       /* Adjust spacing between the two lines */
}

/* Optional: Make the English text a little smaller and lighter */
.station-name-col .name-en {
    font-size: 20px;
	text-align: end;
	font-family: MyriadPro-Semibold-13;
	
}

.station-name-col .name-zh {
    font-size: 30px;
	text-align: end;
    font-weight: bold;
	font-family: MHeiHK-Bold;
}

/* --- Train Detail Popup --- */
#train-detail-popup {
    position: absolute;
    background-color: var(--color-surface);
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Soft shadow */
    z-index: 9999; /* Ensures it stays on top of everything */
    display: none; /* Hidden by default */
    min-width: 140px;
}

#train-detail-popup .popup-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

#train-detail-popup .popup-content {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

/* Train Badge */
.train-badge-wrapper {
    width: 65px;
    height: 80px;
    filter: drop-shadow(0px 2px 3px rgba(0, 0, 0, 0.1));
    pointer-events: auto !important;
    cursor: pointer;
    z-index: 10;
}

.train-badge {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: white;
    overflow: hidden;
}

.train-badge.up {
    clip-path: polygon(50% 0%, 100% 15%, 100% 100%, 0% 100%, 0% 15%);
}

.train-badge.dn {
    clip-path: polygon(0% 0%, 100% 0%, 100% 85%, 50% 100%, 0% 85%);
}

.train-badge-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.train-badge-crowd {
    display: flex;
    gap: 3px;
}

.train-badge.up .train-badge-crowd {
    margin-top: 6px;
}

.train-badge.dn .train-badge-crowd {
    margin-bottom: 6px;
}

.train-badge-dot {
    width: 2px;
    height: 6px;
}

.train-badge-info {
    width: 100%;
    color: white;
    padding: 2px 0;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    box-sizing: border-box;
}


/* RecyclerView Items */
.recycler-view {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Rows */
.item-station {
    background-color: var(--color-surface-variant);
    align-items: center;
}

.item-between {
    background-color: var(--color-surface);
    align-items: center;
}

.item-branch {
    background-color: var(--color-surface);
    align-items: center;
}

.item-parallel {
    background-color: var(--color-surface-variant);
    align-items: center;
}

/* Station name */
.station-name-col {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
	font-family: MHeiHK-Bold;
    font-weight: bold;
    color: var(--color-on-surface);
}

/* Station dot */
.station-dot-outer {
    width: 14px;
    height: 14px;
    background-color: #000000;
    border-radius: 50%;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.station-dot-inner {
    width: 8px;
    height: 8px;
    background-color: #FFFFFF;
    border-radius: 50%;
}

/* Train badge container */
#train_up,
#train_dn,
#train_up_main,
#train_dn_main,
#train_up_spur,
#train_dn_spur {
    width: 15% !important;
    height: 100%;
    position: absolute;
    top: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

#train_up {
    left: 20%;
    justify-content: flex-start;
}

#train_dn {
    right: 20%;
    justify-content: flex-end;
}

#train_up_main {
    left: 10px;
    justify-content: flex-start;
}

#train_dn_main {
    left: 80px;
    justify-content: flex-start;
}

#train_up_spur {
    right: 80px;
    justify-content: flex-end;
}

#train_dn_spur {
    right: 10px;
    justify-content: flex-end;
}

/* Bottom Sheet */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: none;
}

.bottom-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 80%;
    background: var(--color-surface);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    z-index: 101;
    transition: bottom 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.bottom-sheet.show {
    bottom: 0;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-surface-variant);
}

.sheet-title {
    font-weight: bold;
    font-size: 18px;
    text-align: center;
    flex: 1;
}

.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.train-detail-card {
    background: var(--color-surface-variant);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.train-detail-header {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 8px;
}

.train-crowd-layout {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.car-box {
    width: 24px;
    height: 26px;
    border-radius: 4px;
}

.app-footer {
    width: 100%;
    border-top: 1px solid #eee;
    padding: 20px 16px;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #666;
    box-sizing: border-box;
    /* Removed position: fixed and bottom: 0 */
}

.footer-content {
	max-width: 600px;
	margin: 0 auto;
}

.footer-top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
}