/* ==========================================================================
   1. CSS Variables & Reset
   ========================================================================== */
:root {
    --primary: #2F3136;
    --secondary: #B8BDC5;
    --accent: #FFFFFF;
    --silver: #D9D9D9;
    --bg-light: #f8f9fa;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --font-main: 'Poppins', sans-serif;
    --transition: all 0.3s ease;

    /* Responsive spacing scale */
    --space-xs: clamp(0.5rem, 1vw, 0.75rem);
    --space-sm: clamp(0.75rem, 1.5vw, 1rem);
    --space-md: clamp(1rem, 2vw, 1.5rem);
    --space-lg: clamp(1.5rem, 3vw, 2.5rem);
    --space-xl: clamp(2rem, 5vw, 4rem);
    --space-2xl: clamp(3rem, 8vw, 6rem);

    /* Container widths */
    --container-max: 1200px;
    --container-wide: 1440px;
    --container-narrow: 800px;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    /* Prevent font inflation on iOS */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-main);
    color: var(--text-main);
    line-height: 1.6;
    background-color: var(--accent);
    overflow-x: hidden;
    /* Improve rendering on all devices */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   2. Typography & Utilities
   ========================================================================== */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Container — fluid with a sensible max */
.container {
    width: 90%;
    max-width: var(--container-max);
    margin: 0 auto;
}

/* Wider container variant for special sections */
.container--wide {
    width: 92%;
    max-width: var(--container-wide);
    margin: 0 auto;
}

.section {
    padding: clamp(60px, 10vw, 120px) 0;
}

.bg-light {
    background-color: var(--bg-light);
}

.bg-dark {
    background-color: var(--primary);
    color: var(--accent);
}

.section-header {
    text-align: center;
    margin-bottom: clamp(40px, 6vw, 70px);
}

.section-header h2 {
    font-size: clamp(1.6rem, 4vw, 2.5rem);
    color: var(--primary);
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

.dark-header h2 {
    color: var(--accent);
}

.divider {
    height: 4px;
    width: 60px;
    background-color: var(--primary);
    margin: 0 auto 20px;
    border-radius: 2px;
}

.light-divider {
    background-color: var(--silver);
}

.section-subtitle {
    color: var(--text-muted);
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ==========================================================================
   3. Buttons
   ========================================================================== */
.btn {
    display: inline-block;
    padding: clamp(10px, 1.5vw, 12px) clamp(20px, 3vw, 28px);
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 2px solid transparent;
    /* Minimum tap target — accessibility */
    min-height: 44px;
    min-width: 44px;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--silver);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-secondary:hover {
    background-color: var(--accent);
    color: var(--primary);
    transform: translateY(-2px);
}

.btn-disabled {
    background-color: #555;
    color: #999;
    cursor: not-allowed;
    border-color: #555;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--primary);
    color: var(--primary);
}

.light-outline {
    border-color: var(--accent);
    color: var(--accent);
}

.light-outline:hover {
    background-color: var(--accent);
    color: var(--primary);
}

.disabled-form {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #777;
    color: #777;
}

/* ==========================================================================
   4. Navigation & Logo System
   ========================================================================== */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    padding: 20px 0;
    transition: var(--transition);
}

nav.scrolled {
    background-color: var(--primary);
    padding: 15px 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.nav-container {
    width: 90%;
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 12px;
    /* Prevent logo text from wrapping on small screens */
    flex-shrink: 0;
}

/* Truncate long logo text gracefully */
.logo span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: clamp(140px, 30vw, 400px);
}

.logo img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex-shrink: 0;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: clamp(16px, 2.5vw, 30px);
    align-items: center;
}

.nav-links a {
    color: var(--accent);
    font-weight: 500;
    font-size: clamp(0.85rem, 1.2vw, 0.95rem);
    position: relative;
    padding-bottom: 5px;
    white-space: nowrap;
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--silver);
    transition: var(--transition);
}

.nav-links a:hover::after {
    width: 100%;
}

.hamburger {
    display: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 6px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    position: relative;
    z-index: 1100;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background-color: var(--accent);
    border-radius: 2px;
    transform-origin: center;
    transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1),
                opacity   0.25s ease,
                width     0.25s ease;
    pointer-events: none;
}

/* Hamburger → X animation */
.hamburger.toggle span:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}
.hamburger.toggle span:nth-child(2) {
    opacity: 0;
    width: 0;
}
.hamburger.toggle span:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}

/* ==========================================================================
   5. Hero Section
   ========================================================================== */
#hero {
    height: 100vh;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    
    /* 🎯 แต่ยังคงต้องเก็บ 3 บรรทัดนี้ไว้เพื่อให้รูปแสดงผลสวยงามครับ */
    background-size: cover;          /* ยืดรูปให้เต็มพื้นที่โดยไม่เสียสัดส่วน */
    background-position: center;     /* จัดให้จุดกึ่งกลางภาพอยู่ตรงกลางจอ */
    background-repeat: no-repeat;    /* ป้องกันไม่ให้ภาพแสดงซ้ำ */
    
    color: var(--accent);
    text-align: center;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMDUiLz4KPC9zdmc+') repeat;
    opacity: 0.5;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: var(--container-narrow);
    width: 90%;
    padding: 0 20px;
    /* Ensure content stays within hero */
    overflow: hidden;
}

.hero-logo {
    width: clamp(100px, 20vw, 180px);
    height: clamp(100px, 20vw, 180px);
    object-fit: contain;
    margin: 0 auto clamp(16px, 3vw, 28px);
    filter: drop-shadow(0 10px 25px rgba(0,0,0,.35));
    animation: floatLogo 5s ease-in-out infinite;
    display: block;
}

.school-name {
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    font-weight: 500;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 10px;
    opacity: 0.85;
}

.house-name {
    font-size: clamp(2.4rem, 7vw, 6rem);
    font-weight: 800;
    line-height: 1;
    margin: 12px 0 20px 0;
    text-shadow: 0 10px 20px rgba(0,0,0,0.3);
    /* Prevent overflow on tiny screens */
    overflow-wrap: break-word;
    word-break: break-word;
}

.house-subtitle {
    margin-top: 10px;
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #c5c5c5;
}

.slogan {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 300;
    color: var(--silver);
    margin-bottom: clamp(24px, 4vw, 40px);
    font-style: italic;
    line-height: 1.5;
}

.hero-buttons {
    display: flex;
    gap: clamp(12px, 2vw, 20px);
    justify-content: center;
    flex-wrap: wrap;
}

/* Ensure hero buttons each have decent width on mobile */
.hero-buttons .btn {
    flex: 1 1 auto;
    max-width: 220px;
    min-width: 140px;
    text-align: center;
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.mouse {
    width: 30px;
    height: 50px;
    border: 2px solid var(--accent);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    padding-top: 10px;
}

.wheel {
    width: 4px;
    height: 8px;
    background-color: var(--accent);
    border-radius: 2px;
    animation: scrollWheel 2s infinite;
}

/* ==========================================================================
   6. About Section
   ========================================================================== */
.about-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(16px, 3vw, 30px);
}

.about-card {
    background: var(--accent);
    padding: clamp(24px, 4vw, 40px);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    transition: var(--transition);
    border: 1px solid #eee;
}

.about-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.about-card h3 {
    color: var(--primary);
    font-size: clamp(1.15rem, 2vw, 1.5rem);
    margin-bottom: 15px;
}

.about-card p {
    color: var(--text-muted);
    font-size: clamp(0.875rem, 1.3vw, 1rem);
    line-height: 1.7;
}

/* ==========================================================================
   7. Committee Section
   ========================================================================== */
.committee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: clamp(24px, 4vw, 40px);
}

.committee-card {
    background: var(--accent);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: var(--transition);
    text-align: center;
    padding-bottom: 30px;
}

.committee-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}

/* Profile photos — keep circular & consistent */
.card-image-placeholder {
    width: clamp(110px, 18vw, 150px);
    height: clamp(110px, 18vw, 150px);
    background: linear-gradient(135deg, var(--secondary), var(--silver));
    border-radius: 50%;
    margin: clamp(24px, 4vw, 40px) auto 20px;
    border: 5px solid var(--accent);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    object-fit: cover;
    display: block;
    /* Maintain aspect ratio */
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

.card-info {
    padding: 0 clamp(12px, 2.5vw, 20px);
}

.badge {
    display: inline-block;
    background-color: var(--primary);
    color: var(--accent);
    font-size: clamp(0.7rem, 1vw, 0.8rem);
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    margin-bottom: 15px;
    text-transform: uppercase;
    /* Prevent very long Thai text from overflowing */
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
    max-width: 100%;
}

.committee-card h3 {
    font-size: clamp(1.1rem, 1.8vw, 1.3rem);
    color: var(--primary);
    margin-bottom: 5px;
    overflow-wrap: break-word;
}

.grade {
    color: var(--secondary);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.desc {
    color: var(--text-muted);
    font-size: clamp(0.85rem, 1.2vw, 0.95rem);
    line-height: 1.6;
}

.advisor-card {
    grid-column: 1 / -1;
    max-width: 400px;
    margin: 0 auto;
}

/* ==========================================================================
   8. Activities Timeline & Matchboard Component
   ========================================================================== */
/* ==========================================================================
   PREMIUM TIMELINE COMPONENT (SPACIOUS & MODERN)
   ========================================================================== */

.timeline {
    position: relative;
    max-width: var(--container-narrow);
    margin: 40px auto;
}

/* Vertical axis line */
.timeline::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, var(--silver) 0%, rgba(200,200,200,0.2) 100%);
    left: 20px;
    top: 0;
}

.timeline-item {
    position: relative;
    padding-left: 65px;
    margin-bottom: 56px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: var(--primary);
    border: 3.5px solid #ffffff;
    border-radius: 50%;
    left: 13px;
    top: 28px;
    box-shadow: 0 0 0 2px var(--primary), 0 4px 10px rgba(0,0,0,0.15);
    z-index: 2;
    transition: all 0.3s ease;
}

.timeline-item:hover .timeline-dot {
    background-color: var(--accent);
    transform: scale(1.15);
}

.timeline-content {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: clamp(20px, 3vw, 32px) clamp(20px, 3.5vw, 36px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.03);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* Prevent content overflow */
    overflow: hidden;
    word-break: break-word;
}

.timeline-content:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.07);
    border-color: rgba(0, 0, 0, 0.1);
}

.timeline-date {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    font-weight: 700;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    opacity: 0.8;
}

.timeline-content h3 {
    font-size: clamp(1.05rem, 2vw, 1.35rem);
    font-weight: 700;
    line-height: 1.5;
    color: #1e2022;
    margin: 0 0 14px 0;
    letter-spacing: -0.3px;
}

.timeline-content p {
    font-size: clamp(0.875rem, 1.3vw, 0.95rem);
    color: #5f6368;
    line-height: 1.7;
    margin: 0;
}

/* Match Wrapper */
.matches-wrapper {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.match-entry {
    width: 100%;
}

.match-entry + .match-entry {
    border-top: 1px dashed rgba(0, 0, 0, 0.15);
    padding-top: 25px;
}

.bg-dark .match-entry + .match-entry {
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.match-meta {
    display: table;
    width: 100%;
    margin-bottom: 20px;
}

/* Override for match-meta context — keeps its own inline-block behavior */
.match-meta .timeline-date {
    display: inline-block;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0;
    opacity: 1;
}

.match-badge {
    float: right;
    background: var(--primary);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 12px;
    border-radius: 20px;
}

/* Match Board Center Layout */
.match-board {
    display: table;
    width: 100%;
    background: #fdfdfd;
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: clamp(16px, 2.5vw, 24px) clamp(8px, 2vw, 16px);
    margin-bottom: 18px;
    box-sizing: border-box;
}

.team-side {
    display: table-cell;
    width: 38%;
    vertical-align: middle;
    text-align: center;
}

.score-center {
    display: table-cell;
    width: 24%;
    vertical-align: middle;
    text-align: center;
}

/* Team Logo Wrapper */
.team-logo-wrapper {
    width: clamp(48px, 8vw, 64px);
    height: clamp(48px, 8vw, 64px);
    background: #ffffff;
    border-radius: 14px;
    margin: 0 auto clamp(8px, 1.5vw, 12px) auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative;
}

.team-logo-wrapper:not(:has(img[src]))::after,
.team-logo-wrapper:has(img[style*="display: none"])::after {
    content: "SFX";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: 1px;
}

.team-side.away .team-logo-wrapper:not(:has(img[src]))::after,
.team-side.away .team-logo-wrapper:has(img[style*="display: none"])::after {
    content: "VS";
}

.team-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.team-name {
    font-size: clamp(0.75rem, 1.5vw, 1.1rem);
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-main);
    text-transform: uppercase;
    /* Prevent overflow */
    overflow-wrap: break-word;
    word-break: break-all;
}

/* Score Dashboard */
.score-display {
    background: #1e2022;
    color: #ffffff;
    display: inline-block;
    padding: clamp(4px, 0.8vw, 6px) clamp(10px, 2vw, 18px);
    border-radius: 8px;
    font-weight: 700;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    letter-spacing: 2px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.score-number {
    display: inline-block;
    transition: all 0.3s ease;
    min-width: 20px;
    color: #ffffff;
}

.score-divider {
    color: rgba(255, 255, 255, 0.3);
    animation: pulseBlink 2s infinite;
}

.vs-text {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-top: 8px;
}

.match-desc {
    font-size: clamp(0.875rem, 1.3vw, 0.95rem);
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

/* ==========================================================================
   9. Merchandise Section
   ========================================================================== */
.merch-showcase {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(30px, 5vw, 60px);
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: clamp(24px, 4vw, 40px);
    border: 1px solid rgba(255,255,255,0.1);
}

.merch-image-placeholder {
    width: 100%;
    aspect-ratio: 4/5;
    background: linear-gradient(135deg, #4a4d54, #1a1b1e);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    overflow: hidden;
    /* Prevent placeholder text overflow */
    padding: 20px;
    text-align: center;
    word-break: break-all;
}

.status-badge {
    display: inline-block;
    background-color: var(--silver);
    color: var(--primary);
    padding: 6px 15px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.product-name {
    font-size: clamp(1.5rem, 3.5vw, 2.5rem);
    margin-bottom: 20px;
    line-height: 1.2;
    overflow-wrap: break-word;
}

.product-desc {
    color: var(--secondary);
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    margin-bottom: 30px;
    line-height: 1.7;
}

.availability {
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    margin-bottom: 30px;
    color: var(--secondary);
}

.availability strong {
    color: #ff6b6b;
}

.merch-details .btn {
    margin-right: 15px;
    margin-bottom: 15px;
}

/* ==========================================================================
   10. Gallery Section
   ========================================================================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: clamp(12px, 2vw, 20px);
}

.gallery-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

.gallery-placeholder {
    width: 100%;
    height: 100%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
    font-weight: 600;
    font-size: clamp(0.85rem, 1.5vw, 1.2rem);
    transition: var(--transition);
    padding: 10px;
    text-align: center;
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(47, 49, 54, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.gallery-overlay span {
    color: var(--accent);
    font-weight: 600;
    border: 2px solid var(--accent);
    padding: 10px 25px;
    border-radius: 4px;
    transform: translateY(20px);
    transition: var(--transition);
}

.gallery-item:hover .gallery-placeholder {
    transform: scale(1.1);
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-item:hover .gallery-overlay span {
    transform: translateY(0);
}

/* ==========================================================================
   11. Footer
   ========================================================================== */
footer {
    background-color: #1a1b1e;
    color: var(--accent);
    padding: clamp(50px, 8vw, 80px) 0 30px;
}

.footer-logo {
    width: clamp(50px, 8vw, 70px);
    height: clamp(50px, 8vw, 70px);
    object-fit: contain;
    margin-bottom: 15px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(40px, 6vw, 60px);
    flex-wrap: wrap;
    gap: clamp(24px, 4vw, 40px);
}

.footer-brand h2 {
    font-size: clamp(1.3rem, 3vw, 2rem);
    margin-bottom: 5px;
    overflow-wrap: break-word;
}

.footer-brand p {
    color: var(--secondary);
    font-size: clamp(0.85rem, 1.3vw, 1rem);
}

.footer-social {
    text-align: right;
}

.ig-handle {
    display: block;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 700;
    margin: 10px 0 20px;
    color: var(--silver);
    transition: var(--transition);
    word-break: break-all;
}

.ig-handle:hover {
    color: var(--accent);
}

.footer-bottom {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: var(--secondary);
    font-size: clamp(0.8rem, 1.2vw, 0.9rem);
}

/* ==========================================================================
   12. Modals & Lightbox
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Ensure modal sits above safe-area insets */
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--accent);
    padding: clamp(24px, 4vw, 40px);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-content h3 {
    color: var(--primary);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    margin-bottom: 15px;
}

.modal-content p {
    font-size: clamp(0.875rem, 1.3vw, 1rem);
    color: var(--text-muted);
    line-height: 1.6;
}

.close-modal, .close-lightbox {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    /* Ensure close buttons are easy to tap */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    line-height: 1;
}

.close-modal:hover,
.close-lightbox:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary);
}

.lightbox-content {
    width: 90%;
    max-width: 900px;
    aspect-ratio: 16/9;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.lightbox-placeholder {
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--primary);
    font-weight: 700;
    text-align: center;
    padding: 20px;
}

.close-lightbox {
    color: var(--accent);
    top: 20px;
    right: 40px;
    font-size: 3rem;
}

/* ==========================================================================
   13. Core System Animations
   ========================================================================== */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

@keyframes floatLogo {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
    100% { transform: translateY(0px); }
}

@keyframes scrollWheel {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(15px); opacity: 0; }
}

@keyframes pulseBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
    .hero-logo { animation: none; }
    .wheel { animation: none; }
    .score-divider { animation: none; }
    .reveal { transition: opacity 0.4s ease; transform: none; }
    .reveal.active { transform: none; }
    .marquee-track { animation-play-state: paused; }
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ==========================================================================
   TIMELINE STATES (PAST & CURRENT HIGHLIGHT)
   ========================================================================== */

/* STATE 1: PAST EVENTS */
.timeline-item.is-past {
    opacity: 0.55;
    transition: opacity 0.3s ease;
}

.timeline-item.is-past:hover {
    opacity: 0.9;
}

.timeline-item.is-past .timeline-dot {
    background-color: #a0a5ad;
    border-color: #ffffff;
    box-shadow: 0 0 0 2px #a0a5ad;
}

.timeline-item.is-past .timeline-content {
    background: #f8f9fa;
    box-shadow: none;
    border-color: rgba(0, 0, 0, 0.03);
}

/* STATE 2: CURRENT / NEXT EVENT */
.timeline-item.is-current .timeline-content {
    border-color: var(--primary);
    box-shadow: 0 15px 40px rgba(30, 32, 34, 0.1),
                0 0 0 1px var(--primary);
    background: #ffffff;
}

.timeline-item.is-current .timeline-dot {
    background-color: var(--accent);
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--accent);
    animation: dotPulse 2s infinite ease-in-out;
}

.live-tag {
    float: right;
    font-size: 0.7rem;
    font-weight: 800;
    background: var(--primary);
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

@keyframes dotPulse {
    0% { box-shadow: 0 0 0 0px rgba(30, 32, 34, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(30, 32, 34, 0.0); }
    100% { box-shadow: 0 0 0 0px rgba(30, 32, 34, 0.0); }
}

/* ==========================================================================
   HOUSE MARQUEE SECTION
   ========================================================================== */
.house-marquee {
    overflow: hidden;
    width: 100%;
    padding: clamp(16px, 3vw, 25px) 0;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marqueeScroll 35s linear infinite;
}

.marquee-track:hover {
    animation-play-state: paused;
}

.house-item {
    display: flex;
    align-items: center;
    padding: 0 clamp(20px, 4vw, 40px);
    flex-shrink: 0;
}

.house-item img {
    height: clamp(36px, 6vw, 60px);
    width: auto;
    object-fit: contain;
    filter: grayscale(30%) brightness(0.9);
    opacity: 0.7;
    transition: all 0.3s ease-out;
}

.house-item img:hover {
    filter: grayscale(0%) brightness(1);
    opacity: 1;
    transform: scale(1.15);
}

@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ==========================================================================
   UPDATE LIVE SCORE DISPLAY
   ========================================================================== */
.score-pulse {
    animation: pulse 0.5s ease-in-out;
    color: #ffd700 !important;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   DOWNLOADS SECTION
   ========================================================================== */
.downloads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.download-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: clamp(1.5rem, 3vw, 2.5rem) clamp(1.25rem, 2.5vw, 2rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.download-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 215, 0, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.preview-thumb {
    width: clamp(56px, 10vw, 80px);
    height: auto;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.download-info h3 {
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    color: #ffffff;
    margin-bottom: 0.75rem;
    font-weight: 600;
    overflow-wrap: break-word;
}

.download-info p {
    font-size: clamp(0.82rem, 1.2vw, 0.9rem);
    color: #a0aec0;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    min-height: 70px;
}

/* ==========================================================================
   14. Media Queries
   ========================================================================== */

/* --- Large Desktops & Ultrawide (1536px+) --- */
@media (min-width: 1536px) {
    .container {
        max-width: 1320px;
    }
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .committee-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .nav-close-item {
        display: none;
    }
}

/* --- 4K (2560px+) --- */
@media (min-width: 2560px) {
    .container {
        max-width: 1600px;
    }
    .gallery-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .nav-close-item {
        display: none;
    }
}

/* --- Standard Laptop & Desktop (1024px–1440px) --- */
@media (max-width: 1280px) {
    .committee-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    .nav-close-item {
        display: none;
    }
}

/* จอคอมพิวเตอร์ ให้เป็น 3 แถว */
@media (min-width: 1024px) {
    .committee-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .nav-close-item {
        display: none;
    }
}

/* --- Tablet Landscape & Small Laptop (992px–1024px) --- */
@media (max-width: 992px) {
    .merch-showcase {
        grid-template-columns: 1fr;
        max-width: 560px;
        margin: 0 auto;
    }
    .about-grid {
        grid-template-columns: 1fr;
    }
    .advisor-card {
        grid-column: auto;
        max-width: 100%;
        margin: 0;
    }
    .nav-close-item {
        display: none;
    }
}

/* --- Tablet Portrait (768px–912px) --- */
@media (max-width: 912px) {
    .committee-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .advisor-card {
        grid-column: 1 / -1;
        max-width: 380px;
        margin: 0 auto;
    }
    .nav-close-item {
        display: none;
    }
}

/* --- Mobile Navigation Break (768px) --- */
@media (max-width: 768px) {
    /* Navigation */
/* ใน @media (max-width: 768px) — แทนที่ .nav-links และ .nav-links.active เดิม */

.hamburger {
    display: flex;
}

.nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(75%, 300px);
    height: 100dvh;                     /* dynamic viewport height — กันแถบ browser mobile */
    background-color: var(--primary);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    transition: right 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    padding-top: max(env(safe-area-inset-top, 0px), 24px);
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 24px);
    overflow-y: auto;
}

.nav-links.active {
    right: 0;
}

/* Close button แสดงเฉพาะ mobile drawer */
.nav-close-item {
    display: flex;
    position: absolute;
    top: 16px;
    right: 16px;
}

.nav-links li {
    width: 100%;
    text-align: center;
    margin: 0;
}

.nav-links li:not(.nav-close-item) a {
    display: block;
    padding: 16px 40px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.75;
    transition: opacity 0.2s ease, letter-spacing 0.2s ease;
}

.nav-links li:not(.nav-close-item) a:hover {
    opacity: 1;
    letter-spacing: 2px;
}

/* ซ่อน underline pseudo-element ใน drawer */
.nav-links li:not(.nav-close-item) a::after {
    display: none;
}

    /* Nav close button — visible only inside mobile drawer */
    .nav-close-item {
        display: none;
    }

    .nav-close-btn {
        background: transparent;
        border: none;
        color: var(--accent);
        font-size: 2rem;
        line-height: 1;
        cursor: pointer;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background 0.2s ease, transform 0.2s ease;
        padding: 0;
    }

    .nav-close-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: rotate(90deg);
    }

    /* Overlay backdrop behind drawer */
    .nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.35s ease;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    .nav-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Logo text — shorten to avoid overflow */
/* ค้นหาใน style4.css ส่วนของมือถือ */
.logo span {
    /* ถ้ามีคำสั่งพวกนี้ ให้ลบทิ้ง หรือเปลี่ยนค่า */
    /* overflow: hidden; */          /* ลบออก */
    /* text-overflow: ellipsis; */   /* ลบออก */
    /* max-width: 100px; */          /* ลบออก หรือเพิ่มค่าให้กว้างขึ้น */
    
    /* ให้ใช้ค่านี้แทน */
    display: block; 
    font-size: 0.93rem; /* ลดขนาดลงเพื่อให้ตัวอักษรไม่เบียดกัน */
    white-space: normal; /* เปลี่ยนจาก nowrap เป็น normal เพื่อให้ขึ้นบรรทัดใหม่ได้ถ้าที่ว่างไม่พอ */
}

    /* Hero */
    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }
   
    .hero-buttons .btn {
        max-width: 260px;
        width: 100%;
    }

    /* Layout */
    .section {
        padding: 60px 0;
    }

    .section-header h2 {
        font-size: clamp(1.4rem, 5vw, 2rem);
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .committee-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .advisor-card {
        grid-column: 1 / -1;
        max-width: 320px;
        margin: 0 auto;
    }

    /* Footer */
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 24px;
    }

    .footer-social {
        text-align: center;
    }

    /* Nav logo image */
    .logo img {
        width: 34px;
        height: 34px;
    }

    /* Match meta — prevent badge overflow */
    .match-badge {
        float: none;
        display: block;
        margin-top: 6px;
        text-align: right;
        width: fit-content;
        margin-left: auto;
    }

    /* Live tag */
    .live-tag {
        float: none;
        display: inline-block;
        margin-bottom: 8px;
    }
    .team-name {
        font-size: 0.7rem;
    }
}

/* --- Small Mobile (576px) --- */
@media (max-width: 576px) {
    /* Match board */
    .match-board {
        padding: 16px 8px;
    }

    .team-name {
        font-size: 0.8rem;
        letter-spacing: 0.5px;
    }

    .score-display {
        font-size: 1.3rem;
        padding: 4px 12px;
    }

    .team-logo-wrapper {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }
    .team-name {
        font-size: 0.67rem;
    }

    /* Timeline */
    .timeline::before {
        left: 15px;
    }

    .timeline-item {
        padding-left: 45px;
        margin-bottom: 40px;
    }

    .timeline-dot {
        left: 8px;
        top: 24px;
    }

    .timeline-content {
        padding: 20px;
        border-radius: 14px;
    }

    .timeline-content h3 {
        font-size: 1.05rem;
    }

    /* Committee — stack to single column on small phones */
    .committee-grid {
        grid-template-columns: 1fr;
    }

    .advisor-card {
        grid-column: auto;
        max-width: 100%;
    }

    /* Live tag */
    .live-tag {
        float: none;
        display: inline-block;
        margin-bottom: 8px;
    }

    /* Downloads */
    .downloads-grid {
        grid-template-columns: 1fr;
    }

    /* Merch */
    .merch-showcase {
        padding: 20px;
        gap: 24px;
    }

    .product-name {
        font-size: 1.5rem;
    }

    /* Marquee */
    .house-item {
        padding: 0 20px;
    }

    .house-item img {
        height: 36px;
    }
}

/* --- Extra Small Mobile (480px) --- */
@media (max-width: 480px) {
    .timeline-item {
        padding-left: 40px;
    }

    .timeline::before {
        left: 10px;
    }

    .team-name {
        font-size: 0.65rem;
    }

    .timeline-dot {
        left: 3px;
    }

    /* Footer IG handle — avoid overflow */
    .ig-handle {
        font-size: 1rem;
    }

    /* Gallery — 2 per row on phones */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Modal close button larger for thumbs */
    .close-modal, .close-lightbox {
        font-size: 1.75rem;
        width: 48px;
        height: 48px;
    }
}

/* --- Tiny Phones (360px and below) --- */
@media (max-width: 375px) {
    .hero-buttons .btn {
        padding: 10px 16px;
        font-size: 0.8rem;
        letter-spacing: 0.5px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.82rem;
    }

    .nav-links {
        width: 85%;
    }

    .team-name {
        font-size: 0.6rem;
    }

    .merch-details .btn {
        margin-right: 8px;
        margin-bottom: 10px;
        width: 100%;
        text-align: center;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .section-header h2 {
        font-size: 1.35rem;
    }
}

/* --- Print --- */
@media print {
    nav,
    .scroll-indicator,
    .hero-buttons,
    .hamburger,
    .modal,
    .house-marquee {
        display: none !important;
    }

    body {
        color: #000;
        background: #fff;
    }

    .section {
        padding: 40px 0;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    .about-card,
    .committee-card,
    .timeline-content,
    .download-card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
}


/* ==========================================================================
   ส่วนเพิ่มเติม: ป้าย NEW สำหรับปุ่ม Track Live Scores
   ========================================================================== */
.btn-has-badge {
    position: relative; /* กำหนดให้ปุ่มเป็นฐานเพื่อให้ป้ายลอยอยู่ด้านบนได้แม่นยำ */
}

.badge-new {
    position: absolute;
    top: -14px; /* ปรับระดับความสูงต่ำที่ลอยเหนือขอบปุ่ม */
    left: 50%;
    transform: translateX(-50%); /* บังคับให้ป้ายอยู่กึ่งกลางปุ่มเสมอในทุกหน้าจอ */
    background: #ff3b30; /* สีแดงสดแนวสปอร์ตสากล */
    color: #ffffff; /* ตัวอักษรสีขาว */
    font-size: 0.65rem; /* ขนาดตัวอักษรพอเหมาะไม่แย่งซีนข้อความหลัก */
    font-weight: 800; /* ตัวหนาพิเศษเด่นชัด */
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    white-space: nowrap; /* ป้องกันข้อความตัดบรรทัด */
    line-height: 1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* เพิ่มมิติเงาให้ลอยเด่น */
    z-index: 10;
}

/* เพิ่มติ่งลูกศรชี้ลงด้านล่างใต้ป้าย (ถ้าไม่ชอบความหรูหราแบบนี้ สามารถลบออกได้) */
.badge-new::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #ff3b30;
}
