.tab-button { padding: 14px 28px; font-size: 17px; background: none; border: none; border-bottom: 4px solid transparent; cursor: pointer; margin: 0 8px; font-weight: 600; }
.tab-button.active { border-bottom: 4px solid; font-weight: bold; }
.sc53-message { padding:14px; border:1px solid #ddd; border-radius:8px; background:#fafafa; }
.sc53-results-table { width:100%; border-collapse:collapse; font-size:15px; }
.sc53-results-table th { background:#1e3a8a; color:#fff; padding:12px; text-align:left; }
.sc53-results-table td { border-bottom:1px solid #e5e7eb; padding:12px; vertical-align:top; }
.sc53-results-table tr:nth-child(even) { background:#f8fafc; }
.sc53-result-title { margin-top:24px; color:#1e3a8a; }
.sc53-result-subtitle { margin:6px 0 18px; color:#374151; }
.sc53-athlete-heading { margin:24px 0 8px; padding:10px 12px; background:#eef2ff; border-left:4px solid #1e3a8a; color:#111827; font-size:19px; }
.sc53-date-heading { margin:22px 0 8px; font-size:20px; color:#111827; }
.sc53-results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.sc53-results-table th {
    background: #1e3a8a;
    color: white;
    padding: 12px 8px;
    text-align: center;
}

.sc53-results-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
}

.sc53-date-heading, .sc53-wettkampf-heading, .sc53-lauf-heading {
    margin-top: 25px;
    color: #1e3a8a;
}

/* สำหรับ protokoll: Wettkampf heading ใต้ AK ใช้ margin น้อยลง */
.sc53-ak-heading + .sc53-wettkampf-heading {
    margin-top: 8px;
    font-size: 15px;
    font-weight: 500;
}

.sc53-ak-heading {
    margin-top: 20px;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: #e0e7ff;
    border-left: 4px solid #1e3a8a;
    color: #1e3a8a;
    font-size: 18px;
    font-weight: 600;
}

/* === CLUB TABLE - ปรับตามต้องการ === */
.sc53-club-table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: fixed !important;
    margin: 12px 0 20px 0 !important;
}

.sc53-club-table th,
.sc53-club-table td {
    padding: 11px 8px !important;
    vertical-align: middle !important;
}

.sc53-club-table th {
    background: #1e3a8a !important;
    color: white !important;
    font-weight: 600 !important;
    text-align: center !important;
}

/* ปรับความกว้างและการจัดแนว */
.bahn-col {
    width: 9% !important;
    text-align: left !important;
    font-weight: 600 !important;
}

.name-col {
    width: 49% !important;
    text-align: left !important;
    font-size: 15.5px !important;     /* เพิ่มขนาดตัวอักษรชื่อ */
    font-weight: 500 !important;
    line-height: 1.45 !important;
}

.jg-col {
    width: 12% !important;
    text-align: center !important;
    font-weight: 500 !important;
}

.zeit-col {
    width: 18% !important;
    text-align: right !important;
    font-weight: 600 !important;
    color: #1e3a8a !important;
}

/* ชื่อยาวขึ้นบรรทัดใหม่ได้ */
.name-col {
    white-space: normal !important;
    word-break: break-word !important;
}

/* เส้นขอบ */
.sc53-club-table td,
.sc53-club-table th {
    border: 1px solid #e5e7eb !important;
}

/* ============================================================
   MOBILE RESPONSIVE FIXES (มือถือแนวตั้ง)
   - แก้ปัญหาช่อง input/select เล็กเกินไป
   - ลด padding 160px ที่บีบพื้นที่
   - ไม่แก้ logic เดิมใดๆ
   ============================================================ */
@media (max-width: 600px) {
  /* 1. แก้ container หลักที่มี padding:160px (ปัญหาหลักสุด)
     ใช้หลาย selector เพื่อให้ครอบคลุมธีมต่าง ๆ */
  body.page-template-template-wettkampf-suche-php div[style*="max-width: 1200px"],
  body.page-template-template-wettkampf-suche-php div[style*="padding: 160px"],
  div[style*="padding: 160px"][style*="max-width: 1200px"] {
    padding: 14px 10px !important;
    margin: 8px auto !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* 2. หัวข้อใหญ่เกินไปบนมือถือ */
  body.page-template-template-wettkampf-suche-php h1[style*="font-size: 38px"],
  h1[style*="font-size: 38px"] {
    font-size: 22px !important;
    margin-bottom: 0 !important;
    line-height: 1.15 !important;
  }
  body.page-template-template-wettkampf-suche-php h2[style*="font-size: 36px"],
  h2[style*="font-size: 36px"] {
    font-size: 20px !important;
    margin-bottom: 14px !important;
  }
  body.page-template-template-wettkampf-suche-php p[style*="font-size:18px"],
  p[style*="font-size:18px"] {
    font-size: 14px !important;
    margin-bottom: 18px !important;
  }

  /* 3. Tab bar - ให้เลื่อน horizontally ได้ (ดีกว่าเบียด) */
  body.page-template-template-wettkampf-suche-php div[style*="border-bottom: 2px solid #ddd"],
  div[style*="border-bottom: 2px solid #ddd"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    margin: 14px 0 10px !important;
    padding-bottom: 6px;
    border-bottom-width: 1px !important;
  }

  /* ปุ่ม Tab เล็กลงแต่กดง่าย */
  .tab-button {
    padding: 9px 12px !important;
    font-size: 13.5px !important;
    margin: 0 3px !important;
    min-height: 38px;
  }
  .tab-button.active {
    border-bottom-width: 3px !important;
  }

  /* 4. ช่องกรอกข้อมูลหลัก (select + input) - แก้ปัญหา "ช่องเล็กมาก" */
  select[id^="eventSelect_"],
  input[id^="searchInput_"] {
    font-size: 16px !important;           /* สำคัญ: ป้องกัน iOS zoom อัตโนมัติ */
    padding: 14px 13px !important;
    margin-bottom: 11px !important;
    border-radius: 10px !important;
    box-sizing: border-box;
    min-height: 48px;                     /* ขนาดสัมผัสที่เหมาะสม */
    width: 100% !important;
  }

  /* 5. ปุ่มค้นหาหลัก (SC53 อยู่ก่อน input, Namen suchen อยู่หลัง) */
  button[onclick^="searchClubResults"],
  button[onclick^="searchResults"] {
    padding: 15px 18px !important;
    font-size: 15px !important;
    margin: 5px 0 10px !important;
    border-radius: 10px !important;
    min-height: 48px;
  }

  /* ปุ่มพิมพ์ */
  button[onclick^="printResults"] {
    padding: 8px 14px !important;
    font-size: 13px !important;
    min-height: 38px;
  }

  /* 6. ปรับผลการค้นหาให้อ่านง่ายขึ้นบนมือถือ */
  .sc53-athlete-heading {
    font-size: 15.5px !important;
    padding: 7px 9px !important;
    margin: 16px 0 6px !important;
  }
  .sc53-date-heading,
  .sc53-wettkampf-heading,
  .sc53-lauf-heading {
    font-size: 15px !important;
    margin-top: 14px !important;
  }

  .sc53-result-title {
    font-size: 16px !important;
    margin-top: 14px !important;
  }
  .sc53-result-subtitle {
    font-size: 13.5px !important;
    margin-bottom: 10px !important;
  }

  /* ตารางผลลัพธ์ - ทำให้เลื่อนได้แนวนอนเมื่อเนื้อหากว้าง */
  #results_schwimmen,
  #results_tauchen,
  #results_triathlon,
  #results_beachvolleyball {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sc53-results-table,
  .sc53-club-table {
    font-size: 12.5px !important;
    min-width: 460px; /* บังคับให้มี scroll ถ้าจำเป็น */
  }

  .sc53-results-table th,
  .sc53-results-table td {
    padding: 6px 5px !important;
  }

  .sc53-club-table th,
  .sc53-club-table td {
    padding: 7px 5px !important;
  }

  /* ปรับคอลัมน์ club table ให้เหมาะกับจอเล็ก */
  .bahn-col {
    width: 11% !important;
    font-size: 12px !important;
  }
  .name-col {
    width: 51% !important;
    font-size: 13.5px !important;
  }
  .jg-col {
    width: 11% !important;
    font-size: 12px !important;
  }
  .zeit-col {
    width: 20% !important;
    font-size: 12.5px !important;
  }

  /* ข้อความแจ้งเตือน */
  .sc53-message {
    padding: 11px !important;
    font-size: 14px !important;
  }
}

/* สำหรับจอเล็กมาก (เช่น iPhone SE, Android 360px) */
@media (max-width: 380px) {
  body.page-template-template-wettkampf-suche-php div[style*="padding: 160px"] {
    padding: 10px 8px !important;
  }

  select[id^="eventSelect_"],
  input[id^="searchInput_"] {
    font-size: 16px !important;
    padding: 12px 11px !important;
    min-height: 46px;
  }

  .tab-button {
    padding: 8px 10px !important;
    font-size: 12.5px !important;
  }

  .sc53-results-table,
  .sc53-club-table {
    font-size: 11.5px !important;
    min-width: 420px;
  }
}