/* CSS Variables */
:root {
    --bg-color: #1e2a38;
    --board-bg: #151f2b;
    --text-orange: #ff9900;
    --text-white: #e0e0e0;
    --border-color: #ff9900;
    --panel-black: #0a0a0a;

    /* Status Colors */
    --status-blue: #00ccff;
    --status-green: #00ff66;
    --status-yellow: #ffcc00;
    --status-red: #ff3300;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-orange);
    font-family: 'Teko', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 0;
    /* Creates space around the board when scrolling */
    /* overflow: hidden; Removed to allow scrolling */
}

.app-container {
    width: 95%;
    max-width: 1400px;
    background-color: var(--board-bg);
    border: none;
    /* Removed border */
    border-radius: 10px;
    padding: 60px 20px 20px 20px;
    /* Added more top padding */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    background-image: linear-gradient(to bottom, #1a2533, #151f2b);
}

/* --- Header Section --- */
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 35px;
    /* Added to push clocks down and show labels */
    margin-bottom: 20px;
}

/* Date Box */
.date-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Space between Month and Day */
    border: 2px solid var(--border-color);
    padding: 0 15px;
    /* Match digital time box */
    text-align: center;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(255, 153, 0, 0.2);
    font-family: 'Oswald', sans-serif;
    /* Match digital time box font */
    height: 60px;
    /* Force consistent height */
    box-sizing: border-box;
}

.date-box .month,
.date-box .day {
    font-size: 2.5rem;
    /* Match digital time box size */
    font-weight: 400;
    /* Regular weight to match digital clock */
    line-height: 1.2;
    color: var(--text-orange);
}

/* Clocks Container */
.clocks-container {
    display: flex;
    gap: 40px;
    align-items: center;
    /* Changed from flex-end to center to align properly */
}

.clock-wrapper {
    text-align: center;
}

.city-name {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--text-orange);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Analog Clock Face */
.analog-clock {
    width: 80px;
    height: 80px;
    background-color: #e0e0e0;
    border-radius: 50%;
    position: relative;
    border: 4px solid #333;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.main-clock .analog-clock {
    width: 120px;
    height: 120px;
    border: 6px solid #333;
}

.main-clock .city-name {
    font-size: 1.2rem;
    font-weight: 700;
}

/* Hands */
.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    background-color: #333;
    border-top-left-radius: 50%;
    border-top-right-radius: 50%;
    z-index: 10;
}

.hour-hand {
    width: 4px;
    height: 25%;
    transform: translateX(-50%);
}

.minute-hand {
    width: 3px;
    height: 40%;
    transform: translateX(-50%);
}

.second-hand {
    width: 1px;
    height: 45%;
    background-color: #cc0000;
    transform: translateX(-50%);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

.center-dot {
    width: 6px;
    height: 6px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Face Container */
.face {
    position: relative;
    width: 100%;
    height: 100%;
}

/* AM/PM Indicator */
.am-pm {
    font-size: 0.9rem;
    font-weight: 700;
    margin-top: 5px;
    color: var(--text-orange);
    text-shadow: 0 0 3px rgba(255, 153, 0, 0.5);
    font-family: 'Oswald', sans-serif;
    letter-spacing: 1px;
}

/* Hide AM/PM for Main Clock */
.main-clock .am-pm {
    display: none;
}

/* Clock Numbers */
.analog-clock .number {
    position: absolute;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    color: #333;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    z-index: 1;
}

.main-clock .number {
    font-size: 1.2rem;
}

.sub-clock .number {
    font-size: 0.9rem;
}

/* Sub Clock Styles */
.sub-clock .analog-clock {
    width: 70px;
    height: 70px;
}

.sub-clock .hour-hand {
    width: 3px;
}

.sub-clock .minute-hand {
    width: 2px;
}

/* Digital Time */
.digital-time-box {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--status-red);
    color: var(--status-red);
    font-family: 'Oswald', sans-serif;
    /* Monospace-like */
    font-size: 2.5rem;
    padding: 0 15px;
    background-color: #100000;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(255, 51, 0, 0.3);
    height: 60px;
    /* Force consistent height */
    line-height: 1;
}

/* --- Title Section --- */
.board-title h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: 2px;
    margin-bottom: 20px;
    color: var(--text-orange);
    text-shadow: 0 0 5px rgba(255, 153, 0, 0.5);
}

/* --- Flight Table --- */
.flight-table {
    width: 100%;
    border-collapse: collapse;
}

.table-header {
    display: grid;
    grid-template-columns: 100px 1fr 130px 140px 100px 300px;
    /* Adjust cols: Widen Flight, Airline, Gate */
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px 0;
    font-size: 0.9rem;
    border-radius: 5px 5px 0 0;
    margin-bottom: 5px;
}

.col {
    text-align: center;
    border-right: 1px solid rgba(255, 153, 0, 0.3);
    overflow: hidden;
    /* Hide text sliding up from below */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    /* Prevent text from hitting edges */
}

.col:last-child {
    border-right: none;
}

.table-row {
    display: grid;
    /* Removed padding/border to ensure precise fit */
    grid-template-columns: 100px 1fr 130px 140px 100px 300px;
    margin-bottom: 8px;
    background-color: #0a0e14;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    height: 60px;
    /* Height for split-flap look */
    align-items: center;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    padding: 0;
    /* Removed padding to fix alignment */
}

/* --- Slide Up Animation --- */
@keyframes slideUpIn {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-up-anim .col span {
    display: inline-block;
    animation: slideUpIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.slide-up-anim .col img {
    animation: slideUpIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.table-row .col {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1px;
    /* Space between flaps */
    font-family: 'Oswald', sans-serif;
    color: var(--text-orange);
    height: 100%;
    /* Fill the row height */
}

.col.dest {
    justify-content: flex-start;
    /* Align destination left */
    padding-left: 20px;
}

/* --- Status Text Animations --- */
@keyframes blinkStatus {

    0%,
    100% {
        opacity: 1;
        text-shadow: 0 0 5px currentColor;
    }

    50% {
        opacity: 0.5;
        text-shadow: none;
    }
}

.table-row .col.status-blue span {
    color: var(--status-blue);
    font-size: 1.2rem;
    font-weight: bold;
    animation: blinkStatus 1.5s infinite ease-in-out;
}

.table-row .col.status-green span {
    color: var(--status-green);
    font-size: 1.2rem;
    font-weight: bold;
}

.table-row .col.status-yellow span {
    color: var(--status-yellow);
    font-size: 1.2rem;
    font-weight: bold;
    animation: blinkStatus 1.5s infinite ease-in-out;
}

.table-row .col.status-red span {
    color: var(--status-red);
    font-size: 1.2rem;
    font-weight: bold;
}

/* --- Digital Text Display --- */
.table-row .col span {
    font-family: 'Oswald', sans-serif;
    font-size: 28px;
    color: #e0e0e0;
    letter-spacing: 2px;
}

.col.time span {
    color: var(--status-yellow);
}

.col.dest span {
    color: var(--text-orange);
}

/* Hide Mute Button */
#mute-btn {
    display: none;
}

/* Airline Logo */
.airline-logo {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    margin-right: 10px;
    object-fit: contain;
    /* Changed to contain to show full logo */
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #fff;
    /* White background for logos */
    padding: 2px;
}

/* --- Footer --- */
.board-footer {
    position: absolute;
    bottom: 20px;
    right: 20px;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.board-footer:hover {
    opacity: 1;
}

.control-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-orange);
    margin-left: 10px;
}

/* --- Responsive Design for Mobile --- */
/* --- Responsive Design for Mobile --- */
@media screen and (max-width: 1024px) {
    .clocks-container {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media screen and (max-width: 768px) {
    .app-container {
        padding: 20px 10px;
        border-radius: 0;
        height: auto;
        min-height: 100vh;
    }

    body {
        overflow-y: auto;
        align-items: flex-start;
    }

    .board-header {
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* Two columns for top row */
        grid-template-rows: auto auto;
        /* Two rows */
        gap: 15px;
        align-items: center;
        justify-items: center;
        width: 100%;
    }

    .header-left {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        width: 100%;
        display: flex;
        justify-content: flex-end;
        /* Push towards center */
        padding-right: 5px;
    }

    .header-right {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        width: 100%;
        display: flex;
        justify-content: flex-start;
        /* Push towards center */
        padding-left: 5px;
    }

    .header-center {
        grid-column: 1 / 3;
        /* Span full width on bottom row */
        grid-row: 2 / 3;
        width: 100%;
    }

    .date-box {
        margin-bottom: 0;
        /* Remove old margin */
    }

    .clocks-container {
        gap: 20px;
        justify-content: center;
    }

    /* Make clocks properly smaller without transform zooming */
    .main-clock .analog-clock {
        width: 80px;
        height: 80px;
        border-width: 4px;
    }

    .sub-clock .analog-clock {
        width: 50px;
        height: 50px;
        border-width: 2px;
    }

    /* Scale Clocks Typography container */
    .analog-clock .number {
        font-size: 0.8rem;
    }

    .main-clock .number {
        font-size: 1rem;
    }

    .sub-clock .number {
        font-size: 0.6rem;
    }

    .main-clock .city-name {
        font-size: 1rem;
    }

    .sub-clock .city-name {
        font-size: 0.7rem;
    }

    .digital-time-box {
        font-size: 2rem;
        padding: 0 10px;
    }

    .board-title h2 {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }

    /* Make table scrollable horizontally on mobile, do NOT squeeze columns */
    .board-main {
        overflow-x: auto;
        padding-bottom: 20px;
    }

    /* Keep width large enough so data doesnt wrap and overlap */
    .flight-table {
        min-width: 800px;
    }

    /* Custom Scrollbar for touch */
    .board-main::-webkit-scrollbar {
        height: 8px;
    }

    .board-main::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }

    .board-main::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 4px;
    }
}

@media screen and (max-width: 768px) {

    /* Enforce strict table width for horizontal scrolling */
    .flight-table {
        min-width: 900px !important;
        width: 900px !important;
    }

    .table-header,
    .table-row {
        grid-template-columns: 80px 1fr 100px 120px 80px 250px !important;
    }

    /* Make SURE destination names do not wrap */
    .col.dest span {
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Slight padding adjustment for main container to remove horizontal scroll on the BODY */
    .app-container {
        padding: 20px 0 !important;
        /* Remove horizontal padding on mobile so table can touch edges */
    }

    .board-header {
        padding: 0 10px;
        /* Keep padding for header elements */
    }

    .board-title {
        padding: 0 10px;
    }
}

@media screen and (max-width: 768px) {

    /* Hide specific sub-clocks on mobile to reduce clutter (keeping 4) */
    /* Hide Singapore and Los Angeles visually. */
    .clock-wrapper:has(#clock-sin),
    .clock-wrapper:has(#clock-la) {
        display: none !important;
    }
}

/* Try a more compatible selector just in case */
@media screen and (max-width: 768px) {
    .clock-wrapper.sub-clock:nth-child(3),
    /* Singapore */
    .clock-wrapper.sub-clock:nth-child(6)

    /* Los Angeles */
        {
        display: none !important;
    }
}

@media screen and (max-width: 768px) {

    /* Hide English translations on mobile for destinations and remarks */
    .col.dest .lang-en,
    .col.remarks .lang-en {
        display: none !important;
    }

    /* Make the Japanese text smaller as requested */
    .table-row .col span.lang-ja,
    .table-row .col span {
        font-size: 1.2rem !important;
        /* Reduce from 28px/1.8rem */
        letter-spacing: 1px;
    }

    /* Also reduce font size for status colors (remarks) */
    .table-row .col.status-blue span.lang-ja,
    .table-row .col.status-green span.lang-ja,
    .table-row .col.status-yellow span.lang-ja,
    .table-row .col.status-red span.lang-ja,
    .table-row .col.status-blue span,
    .table-row .col.status-green span,
    .table-row .col.status-yellow span,
    .table-row .col.status-red span {
        font-size: 1.1rem !important;
    }

    /* Adjust grid columns since text is smaller and English is gone */
    .table-header,
    .table-row {
        /* Reduce width of destination and remarks, we don't need 900px anymore */
        grid-template-columns: 80px 1fr 100px 120px 80px 150px !important;
    }

    .flight-table {
        min-width: 700px !important;
        /* Shrink min width back down to fit mobile better */
        width: 100% !important;
    }

    /* Revert padding from dest column */
    .col.dest {
        padding-left: 10px !important;
    }
}

@media screen and (max-width: 768px) {

    /* Extreme shrink to fit without horizontal scroll */
    .flight-table {
        min-width: 100% !important;
        width: 100% !important;
    }

    .board-main {
        overflow-x: hidden !important;
    }

    /* Adjust grid columns to be extremely tight */
    /* Time(40), Dest(1fr), Flight(55), Airline(65), Gate(35), Remarks(60) */
    .table-header,
    .table-row {
        grid-template-columns: 40px 1fr 50px 65px 35px 60px !important;
        height: 40px !important;
        /* Shorter rows */
    }

    .table-header {
        font-size: 0.65rem !important;
    }

    .table-row .col span,
    .table-row .col span.lang-ja {
        font-size: 0.85rem !important;
        letter-spacing: 0px !important;
    }

    /* Status colors font size */
    .table-row .col.status-blue span.lang-ja,
    .table-row .col.status-green span.lang-ja,
    .table-row .col.status-yellow span.lang-ja,
    .table-row .col.status-red span.lang-ja,
    .table-row .col.status-blue span,
    .table-row .col.status-green span,
    .table-row .col.status-yellow span,
    .table-row .col.status-red span {
        font-size: 0.8rem !important;
    }

    .airline-logo {
        width: 18px !important;
        height: 18px !important;
        margin-right: 3px !important;
    }

    .col.dest {
        padding-left: 5px !important;
    }
}

@media screen and (max-width: 768px) {

    /* Ensure the date box shrinks appropriately on mobile just like the digital clock */
    .date-box .month,
    .date-box .day {
        font-size: 2rem !important;
    }
}

/* --- Clock Grid Alignment --- */
.clock-wrapper {
    display: grid !important;
    /* Create 3 rows: City Name (auto), Clock Face (fixed 120px to match main clock text/size), AM/PM (auto) */
    grid-template-rows: 25px 120px 20px;
    align-items: center;
    justify-items: center;
    text-align: center;
}

/* --- Title Split for Mobile --- */
.board-title h2 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

@media screen and (max-width: 768px) {

    /* Clocks Mobile Grid Adjustment */
    .clock-wrapper {
        /* On mobile, main clock is 80px tall */
        grid-template-rows: 20px 80px 20px !important;
    }

    /* Stack Title on Mobile */
    .board-title h2 {
        flex-direction: column;
        gap: 2px;
    }

    .title-separator {
        display: none;
    }

    .title-en {
        font-size: 0.85rem;
        color: var(--text-orange);
        opacity: 0.8;
    }
}