* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

html,
body {
  position: relative;
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  font-family: "Arial Black", Arial, sans-serif;
  color: white;
  background:
    radial-gradient(circle at top left, rgba(255, 45, 45, .35), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, .16), transparent 30%),
    linear-gradient(135deg, #080808 0%, #171717 46%, #2b0505 100%);
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
}

.app {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  margin: 0 auto;
  padding: 22px 12px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.hero {
  text-align: center;
  margin-bottom: 8px;
}

.logo {
  display: inline-block;
  font-size: 14px;
  letter-spacing: 2.3px;
  margin-bottom: 8px;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  background: rgba(0,0,0,.3);
}

h1 {
  margin: 0;
  padding: 12px 16px;
  font-size: 34px;
  line-height: 1.05;
  text-shadow: 0 5px 0 rgba(0, 0, 0, .55);
  background: linear-gradient(135deg, #ff1d1d, #b90000);
  border-radius: 999px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}

.hero p {
  margin: 7px 0 0;
  font-family: Arial, sans-serif;
  font-weight: 800;
  font-size: 14px;
  opacity: .86;
}

.panel {
  padding: 12px;
  border-radius: 26px;
  background: rgba(0, 0, 0, .62);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 70px rgba(0,0,0,.45);
  display: grid;
  gap: 8px;
  align-content: start;
}

.hidden {
  display: none !important;
}

button {
  -webkit-appearance: none;
  appearance: none;
}

.option {
  border: 0;
  background: rgba(255,255,255,.04);
  color: white;
  font: inherit;
  display: flex;
  align-items: center;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
  text-align: left;
  overflow: hidden;
}

.option:hover,
.option:focus {
  background: rgba(255, 255, 255, .14);
  outline: none;
}

.option:active {
  transform: scale(.98);
}

.logoIcon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex: 0 0 auto;
}

.googleLogo {
  background: transparent;
}

.facebookLogo {
  background: white;
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.tiktokLogo {
  background: #000;
  border-radius: 10px;
  padding: 6px;
}

.naverLogo {
  background: #03c75a;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.kakaoLogo {
  background: #fee500;
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.raLogo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.raFallback {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  place-items: center;
  flex: 0 0 auto;
  background: #111;
  color: white;
  font-size: 15px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,.25);
}

.emojiIcon,
.otherIcon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.emojiIcon {
  font-size: 25px;
}

.otherIcon {
  background: rgba(255,255,255,.15);
  font-size: 23px;
}

#platformScreen {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 58px;
  align-content: start;
  align-items: center;
  max-height: calc(100svh - 128px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#platformScreen .platform {
  height: 58px;
  min-height: 58px;
  max-height: 58px;
  padding: 8px 9px;
  gap: 9px;
}

#platformScreen .platform span:last-child {
  font-size: 19px;
  line-height: 1.05;
  white-space: normal;
  overflow-wrap: anywhere;
}

.regionPanel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 58px;
  align-content: start;
  max-height: calc(100svh - 128px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mapRegion {
  height: 58px;
  min-height: 58px;
  max-height: 58px;
  padding: 8px;
  justify-content: center;
  text-align: center;
  background: rgba(255,255,255,.08);
  display: grid;
  place-items: center;
}

.mapRegion strong {
  font-size: 18px;
  line-height: 1.05;
}

.countryPanel {
  max-height: calc(100svh - 128px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#countryButtons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 48px;
  align-content: start;
  gap: 8px;
}

.country {
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  padding: 6px 6px;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  line-height: 1.08;
  background: rgba(255,255,255,.1);
  border-radius: 14px;
  word-break: keep-all;
  white-space: normal;
}

.genderPanel,
.peoplePanel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 56px;
  align-content: start;
  max-height: calc(100svh - 128px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gender,
.people {
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 8px;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  line-height: 1.1;
  background: rgba(255,255,255,.08);
}

.backBtn {
  grid-column: 1 / -1;
  width: 220px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  justify-self: center;
  margin-top: 6px;
  padding: 0 16px;
  background: rgba(255,255,255,.2);
  color: white;
  font-size: 14px;
}

.backBtn,
.adminOpen,
#closeAdmin,
.danger,
.exportBtn {
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
}

.thankyou {
  text-align: center;
  padding: 34px 22px;
  border-radius: 28px;
  background: rgba(0,0,0,.72);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 20px 70px rgba(0,0,0,.45);
}

.thankyou h2 {
  margin: 0 0 12px;
  font-size: 42px;
}

.thankyou p {
  font-family: Arial, sans-serif;
  font-size: 20px;
}

.adminOpen {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 80px;
  height: 40px;
  opacity: .36;
  background: white;
  color: black;
  z-index: 2;
}

.adminOpen:hover {
  opacity: .9;
}

.admin {
  position: fixed;
  inset: 0;
  overflow: auto;
  padding: 24px;
  background: #111;
  color: white;
  z-index: 10;
  font-family: Arial, sans-serif;
}

.adminHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#closeAdmin {
  width: 86px;
  height: 40px;
  background: white;
  color: black;
}

.admin h2 {
  font-size: 34px;
  margin: 0 0 20px;
}

.admin h3 {
  margin-top: 28px;
  border-bottom: 1px solid rgba(255,255,255,.2);
  padding-bottom: 8px;
}

.statCards {
  display: grid;
  gap: 12px;
}

.card {
  background: rgba(255,255,255,.1);
  padding: 18px;
  border-radius: 18px;
}

.card span {
  display: block;
  opacity: .7;
}

.card strong {
  display: block;
  font-size: 42px;
  margin-top: 6px;
}

.statRow {
  margin: 10px 0;
}

.statTop {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.bar {
  height: 12px;
  margin-top: 6px;
  background: rgba(255,255,255,.15);
  border-radius: 999px;
  overflow: hidden;
}

.barFill {
  height: 100%;
  width: 0%;
  background: white;
  border-radius: 999px;
}

.crossItem {
  background: rgba(255,255,255,.08);
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 10px;
}

.crossItem strong {
  display: block;
  font-size: 18px;
  margin-bottom: 8px;
}

.crossItem ul {
  margin: 0;
  padding-left: 20px;
}

.crossNested {
  margin-top: 10px;
}

.crossNested strong {
  font-size: 15px;
  margin-bottom: 4px;
}

.exportBtn {
  width: 100%;
  height: 46px;
  margin-top: 24px;
  background: white;
  color: black;
  font-size: 15px;
}

.exportBtn + .exportBtn {
  margin-top: 10px;
}

.danger {
  width: 100%;
  height: 46px;
  margin-top: 12px;
  background: #ff2b2b;
  color: white;
  font-size: 15px;
}

.country,
.mapRegion,
.gender,
.people,
.platform,
.backBtn,
.option,
.adminOpen,
.exportBtn,
.danger {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@media (hover: none) {
  .option:hover,
  .option:focus,
  .mapRegion:hover,
  .mapRegion:focus,
  .country:hover,
  .country:focus {
    transform: none;
  }
}

@media (max-width: 430px) {
  .app {
    width: 100%;
    padding: 10px;
  }

  h1 {
    font-size: 26px;
    padding: 10px 12px;
  }

  .logo {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .hero p {
    font-size: 13px;
  }

  #platformScreen .platform {
    height: 54px;
    min-height: 54px;
    max-height: 54px;
    padding: 7px;
    gap: 7px;
  }

  #platformScreen .platform span:last-child {
    font-size: 15px;
  }

  .logoIcon,
  .raLogo,
  .raFallback,
  .emojiIcon,
  .otherIcon {
    width: 32px;
    height: 32px;
  }

  .emojiIcon {
    font-size: 22px;
  }

  .otherIcon {
    font-size: 20px;
  }

  .mapRegion {
    height: 52px;
    min-height: 52px;
    max-height: 52px;
  }

  .mapRegion strong {
    font-size: 15px;
  }

  .country {
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    font-size: 13px;
  }

  .gender,
  .people {
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    font-size: 17px;
  }

  .backBtn {
    width: 180px;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    font-size: 13px;
  }
}

@media (max-width: 340px) {
  #platformScreen,
  .regionPanel,
  #countryButtons,
  .genderPanel,
  .peoplePanel {
    grid-template-columns: 1fr;
  }
}


/* iPad landscape / Safari tab bar対策：余白と行間を詰める */
@media (orientation: landscape) and (max-height: 700px) {
  .app {
    padding-top: 10px;
    gap: 6px;
  }

  .hero {
    margin-bottom: 6px;
  }

  .logo {
    font-size: 12px;
    margin-bottom: 6px;
    padding: 5px 12px;
  }

  h1 {
    font-size: 30px;
    padding: 10px 14px;
  }

  .hero p {
    margin-top: 5px;
    font-size: 13px;
  }

  .panel {
    padding: 10px;
  }

  #platformScreen {
    grid-auto-rows: 54px;
    max-height: calc(100svh - 112px);
  }

  #platformScreen .platform {
    height: 54px;
    min-height: 54px;
    max-height: 54px;
  }

  .regionPanel {
    grid-auto-rows: 54px;
  }

  .mapRegion {
    height: 54px;
    min-height: 54px;
    max-height: 54px;
  }

  .genderPanel,
  .peoplePanel {
    grid-auto-rows: 52px;
  }

  .gender,
  .people {
    height: 52px;
    min-height: 52px;
    max-height: 52px;
  }
}

@media (min-width: 901px) {
  .app {
    width: min(100%, 860px);
  }

  .regionPanel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #countryButtons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  h1 {
    font-size: 38px;
  }
}

/* =========================================================
   iPad / Safari vertical centering fix
   - ボタン行間は固定したまま、画面全体を中央寄せ
   - Safariの表示領域をJSの --app-height で安定化
========================================================= */
:root {
  --app-height: 100vh;
}

body {
  min-height: var(--app-height);
}

.app {
  height: var(--app-height);
  min-height: var(--app-height);
  justify-content: center;
  overflow-y: auto;
  padding-top: 12px;
  padding-bottom: 12px;
}

#platformScreen,
.regionPanel,
.countryPanel,
.genderPanel,
.peoplePanel {
  max-height: calc(var(--app-height) - 145px);
}

/* 画面がかなり低い時だけ上寄せに逃がす */
@media (max-height: 620px) {
  .app {
    justify-content: flex-start;
  }

  #platformScreen,
  .regionPanel,
  .countryPanel,
  .genderPanel,
  .peoplePanel {
    max-height: calc(var(--app-height) - 118px);
  }
}
