/* ====== Base ====== */
body {
  font-family: sans-serif;
  margin: 0;
}

body>hr {
  margin-top: 20px;
}

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

/* ====== Header / Nav ====== */
nav {
  background: #fff;
  border-bottom: 1px solid #ccc;
  padding-top: env(safe-area-inset-top);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  text-align: center;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.site-header a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.site-header img {
  height: 40px;
}

.site-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #222;
}

/* ====== Menu / Mega ====== */
.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

.menu>li {
  position: relative;
}

.menu>li>a,
.menu>li>p.has-mega {
  display: block;
  padding: 8px 12px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
}

.menu>li>a:hover,
.menu>li>p.has-mega:hover {
  background: #f1f5f9;
}

/* スマホでもPCでも“ポップアップ”見た目を共通化 */
.mega {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .1);
  padding: 16px;
  min-width: 500px;
  max-width: calc(100vw - 20px);
  display: none;
  z-index: 10;
  text-align: center;
  max-height: min(70vh, 600px);
  overflow: auto;
}

/* PC（hover:可・精細ポインタ）だけホバーで開く */
@media (hover: hover) and (pointer: fine) {
  .menu>li:hover .mega {
    display: block;
  }
}

/* タップで .open が付いたら開く（スマホ・タブレット用） */
.menu>li.open .mega {
  display: block;
}

/* ====== Mega 内部（任意の例：縦並びセンター） ====== */
.mega-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mega-grid p {
  margin: 0;
}

.mega-grid a {
  display: inline-block;
  text-decoration: none;
}

/* ====== Tables / Content ====== */
table {
  margin-left: 1%;
  border-collapse: separate;
  border: 1px double #333;
}

table img,
table a {
  display: block;
  margin: 0 auto;
}

.table2 b {
  display: block;
  margin: 0 auto;
  line-height: 0.8;
}

a {
  font-size: 18px;
  font-weight: bold;
}

.td-center-text hr+.images,
.td-center-text hr+br+.images,
.td-center-text hr+img,
.td-center-text hr+br+img {
  margin-top: 12px;
}

.td-center-text .images+hr,
.td-center-text .images+br+hr,
.td-center-text img+hr,
.td-center-text img+br+hr {
  margin-top: 12px;
}

table td {
  padding-top: 2px;
  padding-bottom: 1px;
  vertical-align: middle;
}

.td-center-text {
  text-align: center !important;
}

.table2 {
  margin-left: 1%;
  border-collapse: separate;
  border: 1px double #333;
  text-align: center;
}

.table2 td {
  vertical-align: top;
  padding: 4px 6px;
}

.table2 a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1;
}

.table2 a:hover {
  opacity: 0.8;
}

.table2 .flag2 {
  display: block;
  margin: 0 auto;
}

th,
td {
  border: 1px double #333;
  padding: 4px;
  text-align: center;
}

td img,
td a {
  display: inline-block;
  text-align: left;
}

td:last-child {
  text-align: left;
  vertical-align: top;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-left: 1%;
}

.flag,
.map {
  border: 1px solid #000;
  margin-left: 1%;
}

.flag2 {
  border: 1px solid #000;
}

body>p {
  margin-left: 1%;
}

/* ====== Link blocks ====== */
.link-area {
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  font-size: 16px;
  margin-left: 1%;
}

.link-area p {
  margin: 10px 0;
  line-height: 1.6;
}

/* ====== Ads ====== */
.ad-area {
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.ad-area ins.adsbygoogle {
  max-width: 100% !important;
  height: auto !important;
}

/* ====== Back to top ====== */
#back-to-top {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0078d7;
  color: white;
  border: none;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#back-to-top:hover {
  transform: scale(1.1);
  background: #005bb5;
}

#back-to-top.show {
  opacity: 1;
  pointer-events: auto;
}

/* ====== Search box ====== */
.search-box {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto 10px;
  gap: 6px;

  /* PCでは広がらない（親がflexでも伸長しない） */
  flex: 0 0 auto;
  width: 340px;
  max-width: 100%;
}

.input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

#site-search {
  width: 100%;
  padding: 6px 32px 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

#clear-search {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: transparent;
  color: #666;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: none;
  line-height: 1;
  width: 24px;
  height: 24px;
}

#clear-search:hover {
  color: #000;
}

#search-button {
  white-space: nowrap;
  background: #0078d7;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  height: 100%;
}

#search-button:hover {
  background: #005bb5;
}

/* 小画面では可変に戻す（従来の挙動を維持） */
@media (max-width: 768px) {
  .search-box {
    width: auto;
    max-width: 90%;
  }

  #site-search {
    font-size: 16px;
    padding-right: 38px;
  }

  #clear-search {
    font-size: 22px;
    right: 10px;
  }

  #search-button {
    font-size: 16px;
    padding: 8px 18px;
  }
}

/* ====== Mobile / Touch tuning ====== */
@media screen and (max-device-width: 768px),
(hover: none) and (pointer: coarse) {
  a {
    font-size: 18px !important;
    line-height: 1.5;
  }

  .menu>li>a,
  .menu>li>p.has-mega {
    font-size: 25px !important;
    padding: 12px 16px !important;
    border-radius: 8px;
  }

  .mega-grid a,
  .link-area a {
    font-size: 25px !important;
    line-height: 1.4;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    text-decoration: underline !important;
    padding: 4px 6px !important;
  }

  .mega-grid a img,
  .link-area a img {
    height: 1em;
    width: auto;
    margin: 0;
    padding: 0;
    vertical-align: middle;
  }

  .link-area div p {
    text-indent: 0 !important;
    margin-left: 1.2em;
  }

  .link-area div p {
    font-size: 28px !important;
    /* ┗ を大きく */
  }

  .link-area div p a {
    font-size: 25px !important;
  }

  a,
  button {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
  }

  .map-link,
  div[style*="position:absolute"] a {
    font-size: 28px !important;
    line-height: 1.4;
    font-weight: bold;
    text-decoration: underline !important;
    padding: 8px 14px !important;
    border-radius: 10px;
    display: inline-block;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
  }

  div[style*="position:absolute"] a:active {
    background: rgba(0, 0, 0, 0.1);
  }

  div[style*="position:absolute"] p {
    margin: 0;
    line-height: 1.2;
  }

  img[alt="白世界地図"] {
    max-width: 100%;
    height: auto;
  }

  h2 a {
    font-size: 25px !important;
  }
}