* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
}

.game-shell {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 8px;
}

canvas {
  background: #111;
  border: 2px solid #fff;
  max-width: 100%;
  height: auto;
  touch-action: none;
}

canvas:focus {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

.control-pad {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 8px 0 2px;
  user-select: none;
  -webkit-user-select: none;
}

.control-btn {
  min-width: 64px;
  min-height: 38px;
  border: 1px solid rgba(100, 181, 246, 0.65);
  border-radius: 999px;
  background: #0d47a1;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.control-btn:hover,
.control-btn:focus-visible {
  background: #1565c0;
  outline: 2px solid #90caf9;
  outline-offset: 2px;
}

.control-btn:active {
  transform: translateY(1px);
}

.fire-btn {
  min-width: 86px;
}

a {
  text-decoration: none;
  color: inherit;
}

.site-footer {
  width: 100%;
  margin-top: 8px;
  padding: 8px 0 10px;
  color: #1565c0;
  text-align: center;
  background: #050505;
  border-top: 1px solid rgba(21, 101, 192, 0.28);
  font-size: 0.88rem;
  line-height: 1.4;
}

.site-footer p,
.site-footer a {
  color: #1565c0;
  margin: 0;
}

.site-footer,
.site-footer a {
  user-select: none;
  -webkit-user-select: none;
}

.site-footer a:hover {
  color: #64b5f6;
}

.ad-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
}

.ad-overlay.active {
  display: flex;
}

.ad-panel {
  width: min(92vw, 720px);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid #d7e6f8;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2d3d;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.ad-panel[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.ad-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  background: #f4f8ff;
  border-bottom: 1px solid #d7e6f8;
}

.ad-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: #4f6f91;
  line-height: 1;
}

.ad-wait-message {
  flex: 1 1 auto;
  color: #4f6f91;
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: right;
}

.ad-close-btn {
  flex: 0 0 auto;
  margin: 0;
  padding: 3px 8px;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  border: none;
  border-radius: 999px;
  background: #1565c0;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.ad-close-btn:hover,
.ad-close-btn:focus-visible {
  background: #0d47a1;
  outline: 2px solid #90caf9;
  outline-offset: 2px;
}

.ad-close-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ad-body {
  min-height: 180px;
  padding: 8px;
  background: #ffffff;
}

.ad-help {
  margin: 0;
  padding: 8px 10px 10px;
  border-top: 1px solid #edf3fb;
  color: #4f6f91;
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 520px) {
  body {
    padding-top: 4px;
  }

  .game-shell {
    padding: 0 4px;
  }

  .control-pad {
    gap: 8px;
    padding-top: 6px;
  }

  .control-btn {
    min-width: 56px;
    min-height: 34px;
    font-size: 0.9rem;
  }

  .fire-btn {
    min-width: 76px;
  }

  .site-footer {
    font-size: 0.8rem;
    padding: 6px 0 8px;
  }

  .ad-overlay {
    padding: 12px;
  }

  .ad-panel {
    width: 96vw;
  }
}
