/* Theme Variables */
:root {
    --brand-start: #e74c3c; /* default JA */
    --brand-end: #f39c12;
    --brand-hover: #c0392b;
    --brand-on: #ffffff;
    --page-bg: #f6efe7; /* beige tone */
    --border-color: #e9ecef;
    --text-color: #333;
    --header-bg: #f6efe7; /* header background (can be tuned) */
    --header-height: 96px; /* used for fixed header and mobile menu offset */
}

body.theme-ja {
    --brand-start: #e74c3c;
    --brand-end: #f39c12;
    --brand-hover: #c0392b;
    --page-bg: #f6efe7;
    --header-bg: #f6efe7; /* adjust if logo beige differs */
}

body.theme-th {
    --brand-start: #d81b60; /* pink */
    --brand-end: #ff7043;   /* warm orange */
    --brand-hover: #ad1457;
    --page-bg: #f7eadf;
    --header-bg: #f7eadf; /* adjust if logo beige differs */
}
/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { 
    -webkit-text-size-adjust: 100%; /* iOS Safari auto-zoom prevention */
    text-size-adjust: 100%;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--page-bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: var(--header-bg, var(--page-bg));
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    height: var(--header-height);
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0; /* keep header exact height */
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    order: 0; /* place first */
    margin-right: auto; /* stick to the far left */
    height: var(--header-height);
}

.site-title {
    display: inline-block;
    text-decoration: none;
}

.site-title img {
    height: var(--header-height);
    display: block;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(-50%);
    }
    40% {
        transform: translateY(-60%);
    }
    60% {
        transform: translateY(-55%);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.nav-menu {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
    order: 1; /* center section */
}

.nav-menu ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-menu a:hover { color: var(--brand-start); }

.lang-switcher {
    display: flex;
    gap: 0.5rem;
    margin: 0 1rem;
    position: relative;
    z-index: 1002;
    order: 2;
}

.right-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    order: 2; /* place last on the right */
}

.desktop-auth-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.lang-btn {
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: Arial, sans-serif;
    color: #333;
    min-width: 40px;
    text-align: center;
}

.lang-btn:hover {
    background: #f8f9fa;
}

.lang-btn.active {
    background: #E74C3C;
    color: white;
    border-color: #E74C3C;
}


.btn-login, .btn-register {
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-login { color: #333; border: 1px solid var(--border-color); }

.btn-login:hover {
    background: #f8f9fa;
}

.btn-register {
    background: var(--brand-start);
    color: var(--brand-on);
    border: 1px solid var(--brand-start);
}

.btn-register:hover { background: var(--brand-hover); }

/* Hero Section */
.hero {
    position: relative;
    min-height: 90vh; /* leave room for long titles */
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: calc(var(--header-height) + 40px) 0 48px; /* offset fixed header and add bottom space */
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.7);
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand-start) 70%, transparent), color-mix(in srgb, var(--brand-end) 50%, transparent));
    z-index: -1;
}

.hero-content {
    text-align: center;
    color: white;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px; /* safe padding for mobile */
}

.hero-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    white-space: normal;            /* allow wrapping */
    overflow-wrap: anywhere;        /* break long words if needed */
    word-break: keep-all;           /* keep words intact when possible (good for Thai) */
    text-wrap: balance;             /* better multi-line balance in supporting browsers */
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin-bottom: 3rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Extra safety for very small screens */
@media (max-width: 480px) {
  .hero { min-height: 80vh; padding-top: 72px; }
  .hero-title { font-size: clamp(1.6rem, 8vw, 2.4rem); }
}

/* Search Form */
.search-form {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 800px;
    margin: 0 auto;
}

.search-tabs {
    display: flex;
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: #f8f9fa;
    color: #666;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn:first-child {
    border-radius: 10px 0 0 10px;
}

.tab-btn:last-child {
    border-radius: 0 10px 10px 0;
}

.tab-btn.active {
    background: #e74c3c;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.search-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-select, .search-input {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.search-select:focus, .search-input:focus { outline: none; border-color: var(--brand-start); }

.search-btn {
    padding: 1rem 2rem;
    background: var(--brand-start);
    color: var(--brand-on);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.search-btn:hover { background: var(--brand-hover); }

/* Features Section */
.features {
    padding: 5rem 0;
    background: #f8f9fa;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: white;
    font-size: 2rem;
}

.feature-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #333;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* Section Titles */
.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
    font-weight: 700;
}

/* Popular Courts Section */
.popular-courts {
    padding: 5rem 0;
}

.courts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.court-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.court-card:hover {
    transform: translateY(-5px);
}

.court-image-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #e74c3c, #f39c12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: white;
}

.court-info {
    padding: 1.5rem;
}

.court-info h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.court-location {
    color: #666;
    margin-bottom: 0.5rem;
}

.court-price { font-size: 1.2rem; font-weight: 600; color: var(--brand-start); margin-bottom: 1rem; }

.court-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stars {
    color: #f39c12;
}

.rating-text {
    color: #666;
    font-size: 0.9rem;
}

/* Events Section */
.events {
    padding: 5rem 0;
    background: #f8f9fa;
}

.events-grid {
    display: grid;
    gap: 1.5rem;
}

.event-card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.event-card:hover {
    transform: translateY(-3px);
}

.event-date {
    background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    color: white;
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    min-width: 80px;
}

.event-date .month {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
}

.event-date .day {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
}

.event-info {
    flex: 1;
}

.event-info h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.event-location, .event-time {
    color: #666;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.event-level {
    margin-bottom: 0.5rem;
}

.level-badge {
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.level-badge.beginner {
    background: #d4edda;
    color: #155724;
}

.level-badge.intermediate {
    background: #fff3cd;
    color: #856404;
}

.level-badge.all {
    background: #cce5ff;
    color: #004085;
}

.event-participants {
    color: #666;
    font-size: 0.9rem;
}

.event-action {
    min-width: 120px;
}

.btn-join {
    width: 100%;
    padding: 0.8rem 1.5rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-join:hover {
    background: #c0392b;
}

/* App Download Section */
.app-download {
    padding: 5rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.app-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.app-text h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.app-text p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.app-buttons {
    display: flex;
    gap: 1rem;
}

.app-store-btn img, .google-play-btn img {
    height: 60px;
    transition: transform 0.3s ease;
}

.app-store-btn:hover img, .google-play-btn:hover img {
    transform: scale(1.05);
}

.app-image img {
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
}

/* Footer */
.footer {
    background: #2c3e50;
    color: white;
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
    color: #ecf0f1;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: #bdc3c7;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: #ecf0f1;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #34495e;
    color: #bdc3c7;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    gap: 0.25rem;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background: #333;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Hide browser translation features and any translate-related elements */
#google_translate_element,
.goog-te-banner-frame,
.goog-te-menu-frame,
.goog-te-gadget,
.goog-te-combo,
[id*="google_translate"],
[class*="goog-te"],
[class*="google-translate"],
[title*="Send"],
[aria-label*="Send"],
button[title*="Send"],
button[aria-label*="Send"],
.translate-button,
.translation-button,
[data-translate],
[translate] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Mobile header/logo height */
  :root { --header-height: 84px; }
  /* Ensure hero content is fully visible below fixed header */
  .hero { padding-top: calc(var(--header-height) + 56px); min-height: 85svh; }
  .hero-title { font-size: clamp(1.8rem, 7vw, 2.6rem); line-height: 1.25; }
  .hero-subtitle { font-size: 1rem; }
    .nav-menu {
        position: fixed;
        top: var(--header-height);
        left: -100%;
        width: 100%;
        height: calc(100dvh - var(--header-height));
        background: white;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: 2rem;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu ul {
        flex-direction: column;
        gap: 2rem;
        width: 100%;
        text-align: center;
    }

    .nav-menu ul li a {
        font-size: 1.2rem;
        padding: 1rem;
        display: block;
        width: 100%;
    }

    /* Hide main navigation items on mobile (closed state) */
    .nav-menu ul { display: none; }
    /* Show items when menu is open */
    .nav-menu.active ul { display: flex; }

    /* Show auth buttons only when menu is open */
    .nav-menu .mobile-auth-buttons {
        display: none !important;
        flex-direction: column;
        gap: 1rem;
        width: 80%;
        margin-top: 2rem;
    }
    .nav-menu.active .mobile-auth-buttons { display: flex !important; }

/* Hide mobile auth buttons by default */
.mobile-auth-buttons {
    display: none !important;
}

/* Extra guard: never show mobile auth buttons on desktop */
.nav-menu .mobile-auth-buttons {
    display: none !important;
}

/* Desktop visibility guard */
@media (min-width: 769px) {
    .mobile-auth-buttons {
        display: none !important;
    }
    .desktop-auth-buttons {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .desktop-auth-buttons {
        display: none;
    }

    .nav-menu .mobile-auth-buttons .btn-login,
    .nav-menu .mobile-auth-buttons .btn-register {
        padding: 1rem;
        text-align: center;
        border-radius: 8px;
        text-decoration: none;
        font-weight: 500;
    }

    .nav-menu .mobile-auth-buttons .btn-login {
        background: transparent;
        color: #e74c3c;
        border: 2px solid #e74c3c;
    }

    .nav-menu .mobile-auth-buttons .btn-register {
        background: #e74c3c;
        color: white;
        border: 2px solid #e74c3c;
    }

    .right-section {
        display: flex;
        align-items: center;
    }

    .nav-menu a {
        display: block;
        padding: 1rem 2rem;
        color: #333;
        text-decoration: none;
    }
    
    .nav-menu a:hover { background-color: #f8f9fa; }
    
    
    .lang-switcher {
        order: 1;
        margin-right: 0.5rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .search-row {
        flex-direction: column;
    }
    
    .event-card {
        flex-direction: column;
        text-align: center;
    }
    
    .app-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .app-buttons {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .app-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .event-card {
        flex-direction: column;
        align-items: flex-start;
        text-align: center;
    }
    
    .courts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .events-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .search-form {
        padding: 1.5rem;
    }
    
    .section-title {
        font-size: 2rem;
    }
}


/* Final guard: show exactly one set of auth buttons */
.mobile-auth-buttons { 
    display: none !important; 
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}
.desktop-auth-buttons { display: flex !important; }

@media (max-width: 768px) {
  /* On mobile: show only the mobile buttons inside hamburger menu */
  .nav-menu .mobile-auth-buttons { 
    display: flex !important; 
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
  }
  .desktop-auth-buttons { display: none !important; }
}

@media (min-width: 769px) {
  /* On desktop: ensure mobile set never appears */
  .nav-menu .mobile-auth-buttons { 
    display: none !important; 
    visibility: hidden !important;
    opacity: 0 !important;
  }
  .desktop-auth-buttons { display: flex !important; }
}